@@ -482,6 +482,19 @@ namespace ts {
482482 return node ;
483483 }
484484
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+
485498 export function createFor ( initializer : ForInitializer , condition : Expression , incrementor : Expression , statement : Statement , location ?: TextRange ) {
486499 const node = < ForStatement > createNode ( SyntaxKind . ForStatement , location ) ;
487500 node . initializer = initializer ;
@@ -687,6 +700,22 @@ namespace ts {
687700 ) ;
688701 }
689702
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+
690719 export function createFunctionApply ( func : Expression , thisArg : Expression , argumentsExpression : Expression , location ?: TextRange ) {
691720 return createCall (
692721 createPropertyAccess ( func , "apply" ) ,
@@ -1349,8 +1378,11 @@ namespace ts {
13491378 return clone ;
13501379 }
13511380 }
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+ }
13541386 }
13551387
13561388 return expression ;
0 commit comments