@@ -2520,64 +2520,64 @@ namespace ts {
2520
2520
}
2521
2521
2522
2522
function createEmitBinaryExpression ( ) {
2523
- class EmitBinaryExpressionState {
2524
- nested = false ;
2525
- preserveSourceNewlines : boolean | undefined = undefined ;
2526
- containerPos = - 1 ;
2527
- containerEnd = - 1 ;
2528
- declarationListContainerEnd = - 1 ;
2529
- emitFlags = EmitFlags . None ;
2530
- commentRange : TextRange | undefined = undefined ;
2531
- sourceMapRange : SourceMapRange | undefined = undefined ;
2532
- }
2533
-
2534
- return createBinaryExpressionTrampoline ( onEnter , maybeEmitExpression , onOperator , maybeEmitExpression , onExit , identity ) ;
2535
-
2536
- function onEnter ( node : BinaryExpression , prev : EmitBinaryExpressionState | undefined ) {
2537
- const state = new EmitBinaryExpressionState ( ) ;
2538
- if ( prev ) {
2539
- // `prev` is only defined when recuring. We can use this fact to indicate
2540
- // we are entering into a nested binary expression and can replicate the
2541
- // leading comment and sourcemap emit performed by `emitWithContext`.
2542
- state . nested = true ;
2543
- onBeforeEmitNode ?.( node ) ;
2544
-
2545
- state . emitFlags = getEmitFlags ( node ) ;
2546
- state . preserveSourceNewlines = preserveSourceNewlines ;
2547
- if ( preserveSourceNewlines && ( state . emitFlags & EmitFlags . IgnoreSourceNewlines ) ) {
2548
- preserveSourceNewlines = false ;
2549
- }
2550
-
2551
- state . containerPos = containerPos ;
2552
- state . containerEnd = containerEnd ;
2553
- state . declarationListContainerEnd = declarationListContainerEnd ;
2554
- state . commentRange = shouldEmitComments ( node ) ? getCommentRange ( node ) : undefined ;
2555
- state . sourceMapRange = shouldEmitSourceMaps ( node ) ? getSourceMapRange ( node ) : undefined ;
2556
-
2557
- // Emit leading comments
2558
- if ( state . commentRange ) {
2559
- emitLeadingCommentsOfNode ( node , state . emitFlags , state . commentRange . pos , state . commentRange . end ) ;
2560
- if ( state . emitFlags & EmitFlags . NoNestedComments ) {
2561
- commentsDisabled = true ;
2562
- }
2563
- }
2564
-
2565
- // Emit leading sourcemap
2566
- if ( state . sourceMapRange ) {
2567
- const source = state . sourceMapRange . source || sourceMapSource ;
2568
- if ( ( state . emitFlags & EmitFlags . NoLeadingSourceMap ) === 0
2569
- && state . sourceMapRange . pos >= 0 ) {
2570
- emitSourcePos ( state . sourceMapRange . source || sourceMapSource , skipSourceTrivia ( source , state . sourceMapRange . pos ) ) ;
2571
- }
2572
- if ( state . emitFlags & EmitFlags . NoNestedSourceMaps ) {
2573
- sourceMapsDisabled = true ;
2574
- }
2575
- }
2576
- }
2577
- return state ;
2578
- }
2579
-
2580
- function onOperator ( operatorToken : BinaryOperatorToken , _ : unknown , node : BinaryExpression ) {
2523
+ // class EmitBinaryExpressionState {
2524
+ // nested = false;
2525
+ // preserveSourceNewlines: boolean | undefined = undefined;
2526
+ // containerPos = -1;
2527
+ // containerEnd = -1;
2528
+ // declarationListContainerEnd = -1;
2529
+ // emitFlags = EmitFlags.None;
2530
+ // commentRange: TextRange | undefined = undefined;
2531
+ // sourceMapRange: SourceMapRange | undefined = undefined;
2532
+ // }
2533
+
2534
+ return createBinaryExpressionTrampoline ( noop , maybeEmitExpression , onOperator , maybeEmitExpression , onExit , identity ) ;
2535
+
2536
+ // function onEnter(_node : BinaryExpression, _prev : EmitBinaryExpressionState | undefined) {
2537
+ // const state = new EmitBinaryExpressionState();
2538
+ // if (prev) {
2539
+ // // `prev` is only defined when recuring. We can use this fact to indicate
2540
+ // // we are entering into a nested binary expression and can replicate the
2541
+ // // leading comment and sourcemap emit performed by `emitWithContext`.
2542
+ // state.nested = true;
2543
+ // onBeforeEmitNode?.(node);
2544
+
2545
+ // state.emitFlags = getEmitFlags(node);
2546
+ // state.preserveSourceNewlines = preserveSourceNewlines;
2547
+ // if (preserveSourceNewlines && (state.emitFlags & EmitFlags.IgnoreSourceNewlines)) {
2548
+ // preserveSourceNewlines = false;
2549
+ // }
2550
+
2551
+ // state.containerPos = containerPos;
2552
+ // state.containerEnd = containerEnd;
2553
+ // state.declarationListContainerEnd = declarationListContainerEnd;
2554
+ // state.commentRange = shouldEmitComments(node) ? getCommentRange(node) : undefined;
2555
+ // state.sourceMapRange = shouldEmitSourceMaps(node) ? getSourceMapRange(node) : undefined;
2556
+
2557
+ // // Emit leading comments
2558
+ // if (state.commentRange) {
2559
+ // emitLeadingCommentsOfNode(node, state.emitFlags, state.commentRange.pos, state.commentRange.end);
2560
+ // if (state.emitFlags & EmitFlags.NoNestedComments) {
2561
+ // commentsDisabled = true;
2562
+ // }
2563
+ // }
2564
+
2565
+ // // Emit leading sourcemap
2566
+ // if (state.sourceMapRange) {
2567
+ // const source = state.sourceMapRange.source || sourceMapSource;
2568
+ // if ((state.emitFlags & EmitFlags.NoLeadingSourceMap) === 0
2569
+ // && state.sourceMapRange.pos >= 0) {
2570
+ // emitSourcePos(state.sourceMapRange.source || sourceMapSource, skipSourceTrivia(source, state.sourceMapRange.pos));
2571
+ // }
2572
+ // if (state.emitFlags & EmitFlags.NoNestedSourceMaps) {
2573
+ // sourceMapsDisabled = true;
2574
+ // }
2575
+ // }
2576
+ // }
2577
+ // return state;
2578
+ // }
2579
+
2580
+ function onOperator ( operatorToken : BinaryOperatorToken , _state : unknown , node : BinaryExpression ) {
2581
2581
const isCommaOperator = operatorToken . kind !== SyntaxKind . CommaToken ;
2582
2582
const linesBeforeOperator = getLinesBetweenNodes ( node , node . left , operatorToken ) ;
2583
2583
const linesAfterOperator = getLinesBetweenNodes ( node , operatorToken , node . right ) ;
@@ -2588,44 +2588,44 @@ namespace ts {
2588
2588
writeLinesAndIndent ( linesAfterOperator , /*writeSpaceIfNotIndenting*/ true ) ;
2589
2589
}
2590
2590
2591
- function onExit ( node : BinaryExpression , state : EmitBinaryExpressionState ) {
2591
+ function onExit ( node : BinaryExpression , _state : unknown ) {
2592
2592
const linesBeforeOperator = getLinesBetweenNodes ( node , node . left , node . operatorToken ) ;
2593
2593
const linesAfterOperator = getLinesBetweenNodes ( node , node . operatorToken , node . right ) ;
2594
2594
decreaseIndentIf ( linesBeforeOperator , linesAfterOperator ) ;
2595
2595
2596
- if ( state . nested ) {
2597
- // If we are marked as nested, we are recurring. We can use this fact to indicate
2598
- // we are exiting from a nested binary expression and can replicate the trailing
2599
- // comment and sourcemap emit performed by `emitWithContext`.
2596
+ // if (state.nested) {
2597
+ // // If we are marked as nested, we are recurring. We can use this fact to indicate
2598
+ // // we are exiting from a nested binary expression and can replicate the trailing
2599
+ // // comment and sourcemap emit performed by `emitWithContext`.
2600
2600
2601
- // Emit trailing sourcemap
2602
- if ( state . sourceMapRange ) {
2603
- if ( state . emitFlags & EmitFlags . NoNestedSourceMaps ) {
2604
- sourceMapsDisabled = false ;
2605
- }
2606
- if ( ( state . emitFlags & EmitFlags . NoTrailingSourceMap ) === 0
2607
- && state . sourceMapRange . end >= 0 ) {
2608
- emitSourcePos ( state . sourceMapRange . source || sourceMapSource , state . sourceMapRange . end ) ;
2609
- }
2610
- }
2601
+ // // Emit trailing sourcemap
2602
+ // if (state.sourceMapRange) {
2603
+ // if (state.emitFlags & EmitFlags.NoNestedSourceMaps) {
2604
+ // sourceMapsDisabled = false;
2605
+ // }
2606
+ // if ((state.emitFlags & EmitFlags.NoTrailingSourceMap) === 0
2607
+ // && state.sourceMapRange.end >= 0) {
2608
+ // emitSourcePos(state.sourceMapRange.source || sourceMapSource, state.sourceMapRange.end);
2609
+ // }
2610
+ // }
2611
2611
2612
- // Emit trailing comments
2613
- if ( state . commentRange ) {
2614
- if ( state . emitFlags & EmitFlags . NoNestedComments ) {
2615
- commentsDisabled = false ;
2616
- }
2617
- emitTrailingCommentsOfNode ( node , state . emitFlags , state . commentRange . pos , state . commentRange . end , state . containerPos , state . containerEnd , state . declarationListContainerEnd ) ;
2618
- }
2612
+ // // Emit trailing comments
2613
+ // if (state.commentRange) {
2614
+ // if (state.emitFlags & EmitFlags.NoNestedComments) {
2615
+ // commentsDisabled = false;
2616
+ // }
2617
+ // emitTrailingCommentsOfNode(node, state.emitFlags, state.commentRange.pos, state.commentRange.end, state.containerPos, state.containerEnd, state.declarationListContainerEnd);
2618
+ // }
2619
2619
2620
- onAfterEmitNode ?.( node ) ;
2620
+ // onAfterEmitNode?.(node);
2621
2621
2622
- preserveSourceNewlines = state . preserveSourceNewlines ;
2623
- }
2622
+ // preserveSourceNewlines = state.preserveSourceNewlines;
2623
+ // }
2624
2624
}
2625
2625
2626
2626
function maybeEmitExpression ( next : Expression ) {
2627
2627
// Push a new frame for binary expressions, otherwise emit all other expressions.
2628
- if ( isBinaryExpression ( next ) ) {
2628
+ if ( isBinaryExpression ( next ) && ! shouldEmitComments ( next ) && ! shouldEmitSourceMaps ( next ) ) {
2629
2629
return next ;
2630
2630
}
2631
2631
0 commit comments