@@ -482,6 +482,19 @@ namespace ts {
482
482
return node ;
483
483
}
484
484
485
+ export function createSwitch ( expression : Expression , caseBlock : CaseBlock , location ?: TextRange ) : SwitchStatement {
486
+ const node = < SwitchStatement > createNode ( SyntaxKind . SwitchStatement , location ) ;
487
+ node . expression = parenthesizeExpressionForList ( expression ) ;
488
+ node . caseBlock = caseBlock ;
489
+ return node ;
490
+ }
491
+
492
+ export function createCaseBlock ( clauses : CaseClause [ ] , location ?: TextRange ) : CaseBlock {
493
+ const node = < CaseBlock > createNode ( SyntaxKind . CaseBlock , location ) ;
494
+ node . clauses = createNodeArray ( clauses ) ;
495
+ return node ;
496
+ }
497
+
485
498
export function createFor ( initializer : ForInitializer , condition : Expression , incrementor : Expression , statement : Statement , location ?: TextRange ) {
486
499
const node = < ForStatement > createNode ( SyntaxKind . ForStatement , location ) ;
487
500
node . initializer = initializer ;
@@ -687,6 +700,22 @@ namespace ts {
687
700
) ;
688
701
}
689
702
703
+ export function createBreak ( label ?: Identifier , location ?: TextRange ) : BreakStatement {
704
+ const node = < BreakStatement > createNode ( SyntaxKind . BreakStatement , location ) ;
705
+ if ( label ) {
706
+ node . label = label ;
707
+ }
708
+ return node ;
709
+ }
710
+
711
+ export function createContinue ( label ?: Identifier , location ?: TextRange ) : BreakStatement {
712
+ const node = < ContinueStatement > createNode ( SyntaxKind . ContinueStatement , location ) ;
713
+ if ( label ) {
714
+ node . label = label ;
715
+ }
716
+ return node ;
717
+ }
718
+
690
719
export function createFunctionApply ( func : Expression , thisArg : Expression , argumentsExpression : Expression , location ?: TextRange ) {
691
720
return createCall (
692
721
createPropertyAccess ( func , "apply" ) ,
@@ -1349,8 +1378,11 @@ namespace ts {
1349
1378
return clone ;
1350
1379
}
1351
1380
}
1352
- else if ( getLeftmostExpression ( expression ) . kind === SyntaxKind . ObjectLiteralExpression ) {
1353
- return createParen ( expression , /*location*/ expression ) ;
1381
+ else {
1382
+ const leftmostExpressionKind = getLeftmostExpression ( expression ) . kind ;
1383
+ if ( leftmostExpressionKind === SyntaxKind . ObjectLiteralExpression || leftmostExpressionKind === SyntaxKind . FunctionExpression ) {
1384
+ return createParen ( expression , /*location*/ expression ) ;
1385
+ }
1354
1386
}
1355
1387
1356
1388
return expression ;
0 commit comments