@@ -482,8 +482,10 @@ namespace ts.formatting {
482
482
return findFirstNonWhitespaceCharacterAndColumn ( startPos , endPos , sourceFile , options ) . column ;
483
483
}
484
484
485
- function nodeContentIsAlwaysIndented ( kind : SyntaxKind ) : boolean {
486
- switch ( kind ) {
485
+ export function nodeWillIndentChild ( settings : FormatCodeSettings | undefined , parent : TextRangeWithKind , child : TextRangeWithKind | undefined , sourceFile : SourceFileLike | undefined , indentByDefault : boolean ) : boolean {
486
+ const childKind = child ? child . kind : SyntaxKind . Unknown ;
487
+
488
+ switch ( parent . kind ) {
487
489
case SyntaxKind . ExpressionStatement :
488
490
case SyntaxKind . ClassDeclaration :
489
491
case SyntaxKind . ClassExpression :
@@ -505,7 +507,6 @@ namespace ts.formatting {
505
507
case SyntaxKind . CallExpression :
506
508
case SyntaxKind . NewExpression :
507
509
case SyntaxKind . VariableStatement :
508
- case SyntaxKind . VariableDeclaration :
509
510
case SyntaxKind . ExportAssignment :
510
511
case SyntaxKind . ReturnStatement :
511
512
case SyntaxKind . ConditionalExpression :
@@ -528,24 +529,14 @@ namespace ts.formatting {
528
529
case SyntaxKind . NamedImports :
529
530
case SyntaxKind . ExportSpecifier :
530
531
case SyntaxKind . ImportSpecifier :
531
- case SyntaxKind . PropertyAssignment :
532
532
case SyntaxKind . PropertyDeclaration :
533
533
return true ;
534
- }
535
- return false ;
536
- }
537
-
538
- export function nodeWillIndentChild ( settings : FormatCodeSettings | undefined , parent : TextRangeWithKind , child : TextRangeWithKind | undefined , sourceFile : SourceFileLike | undefined , indentByDefault : boolean ) : boolean {
539
- const childKind = child ? child . kind : SyntaxKind . Unknown ;
540
-
541
- switch ( parent . kind ) {
542
534
case SyntaxKind . VariableDeclaration :
543
535
case SyntaxKind . PropertyAssignment :
544
- case SyntaxKind . ObjectLiteralExpression :
545
536
if ( ! settings . indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === SyntaxKind . ObjectLiteralExpression ) {
546
537
return rangeIsOnOneLine ( sourceFile , child ) ;
547
538
}
548
- break ;
539
+ return true ;
549
540
case SyntaxKind . DoStatement :
550
541
case SyntaxKind . WhileStatement :
551
542
case SyntaxKind . ForInStatement :
@@ -604,7 +595,7 @@ namespace ts.formatting {
604
595
* @param isNextChild If true, we are judging indent of a hypothetical child *after* this one, not the current child.
605
596
*/
606
597
export function shouldIndentChildNode ( settings : FormatCodeSettings | undefined , parent : TextRangeWithKind , child ?: Node , sourceFile ?: SourceFileLike , isNextChild = false ) : boolean {
607
- return ( nodeContentIsAlwaysIndented ( parent . kind ) || nodeWillIndentChild ( settings , parent , child , sourceFile , /*indentByDefault*/ false ) )
598
+ return nodeWillIndentChild ( settings , parent , child , sourceFile , /*indentByDefault*/ false )
608
599
&& ! ( isNextChild && child && isControlFlowEndingStatement ( child . kind , parent ) ) ;
609
600
}
610
601
0 commit comments