@@ -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 :
@@ -529,20 +531,12 @@ namespace ts.formatting {
529
531
case SyntaxKind . ImportSpecifier :
530
532
case SyntaxKind . PropertyDeclaration :
531
533
return true ;
532
- }
533
- return false ;
534
- }
535
-
536
- export function nodeWillIndentChild ( settings : FormatCodeSettings | undefined , parent : TextRangeWithKind , child : TextRangeWithKind | undefined , sourceFile : SourceFileLike | undefined , indentByDefault : boolean ) : boolean {
537
- const childKind = child ? child . kind : SyntaxKind . Unknown ;
538
-
539
- switch ( parent . kind ) {
540
534
case SyntaxKind . VariableDeclaration :
541
535
case SyntaxKind . PropertyAssignment :
542
536
if ( ! settings . indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === SyntaxKind . ObjectLiteralExpression ) {
543
537
return rangeIsOnOneLine ( sourceFile , child ) ;
544
538
}
545
- break ;
539
+ return true ;
546
540
case SyntaxKind . DoStatement :
547
541
case SyntaxKind . WhileStatement :
548
542
case SyntaxKind . ForInStatement :
@@ -595,7 +589,7 @@ namespace ts.formatting {
595
589
* @param isNextChild If true, we are judging indent of a hypothetical child *after* this one, not the current child.
596
590
*/
597
591
export function shouldIndentChildNode ( settings : FormatCodeSettings | undefined , parent : TextRangeWithKind , child ?: Node , sourceFile ?: SourceFileLike , isNextChild = false ) : boolean {
598
- return ( nodeContentIsAlwaysIndented ( parent . kind ) || nodeWillIndentChild ( settings , parent , child , sourceFile , /*indentByDefault*/ false ) )
592
+ return nodeWillIndentChild ( settings , parent , child , sourceFile , /*indentByDefault*/ false )
599
593
&& ! ( isNextChild && child && isControlFlowEndingStatement ( child . kind , parent ) ) ;
600
594
}
601
595
0 commit comments