@@ -193,12 +193,16 @@ module ts.formatting {
193
193
// Insert space after function keyword for anonymous functions
194
194
public SpaceAfterAnonymousFunctionKeyword : Rule ;
195
195
public NoSpaceAfterAnonymousFunctionKeyword : Rule ;
196
-
196
+
197
197
// Insert space after @ in decorator
198
198
public SpaceBeforeAt : Rule ;
199
199
public NoSpaceAfterAt : Rule ;
200
200
public SpaceAfterDecorator : Rule ;
201
201
202
+ // Generator: function*
203
+ public NoSpaceBetweenFunctionKeywordAndStar : Rule ;
204
+ public SpaceAfterStarInGenerator : Rule ;
205
+
202
206
constructor ( ) {
203
207
///
204
208
/// Common Rules
@@ -340,6 +344,9 @@ module ts.formatting {
340
344
this . NoSpaceAfterAt = new Rule ( RuleDescriptor . create3 ( SyntaxKind . AtToken , Shared . TokenRange . Any ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsSameLineTokenContext ) , RuleAction . Delete ) ) ;
341
345
this . SpaceAfterDecorator = new Rule ( RuleDescriptor . create4 ( Shared . TokenRange . Any , Shared . TokenRange . FromTokens ( [ SyntaxKind . Identifier , SyntaxKind . ExportKeyword , SyntaxKind . DefaultKeyword , SyntaxKind . ClassKeyword , SyntaxKind . StaticKeyword , SyntaxKind . PublicKeyword , SyntaxKind . PrivateKeyword , SyntaxKind . ProtectedKeyword , SyntaxKind . GetKeyword , SyntaxKind . SetKeyword , SyntaxKind . OpenBracketToken , SyntaxKind . AsteriskToken ] ) ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsEndOfDecoratorContextOnSameLine ) , RuleAction . Space ) ) ;
342
346
347
+ this . NoSpaceBetweenFunctionKeywordAndStar = new Rule ( RuleDescriptor . create1 ( SyntaxKind . FunctionKeyword , SyntaxKind . AsteriskToken ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsFunctionDeclarationOrFunctionExpressionContext ) , RuleAction . Delete ) ) ;
348
+ this . SpaceAfterStarInGenerator = new Rule ( RuleDescriptor . create3 ( SyntaxKind . AsteriskToken , Shared . TokenRange . FromTokens ( [ SyntaxKind . Identifier , SyntaxKind . OpenParenToken ] ) ) , RuleOperation . create2 ( new RuleOperationContext ( Rules . IsFunctionDeclarationOrFunctionExpressionContext ) , RuleAction . Space ) ) ;
349
+
343
350
// These rules are higher in priority than user-configurable rules.
344
351
this . HighPriorityCommonRules =
345
352
[
@@ -357,6 +364,7 @@ module ts.formatting {
357
364
this . NoSpaceAfterCloseBrace ,
358
365
this . SpaceAfterOpenBrace , this . SpaceBeforeCloseBrace , this . NewLineBeforeCloseBraceInBlockContext ,
359
366
this . SpaceAfterCloseBrace , this . SpaceBetweenCloseBraceAndElse , this . SpaceBetweenCloseBraceAndWhile , this . NoSpaceBetweenEmptyBraceBrackets ,
367
+ this . NoSpaceBetweenFunctionKeywordAndStar , this . SpaceAfterStarInGenerator ,
360
368
this . SpaceAfterFunctionInFuncDecl , this . NewLineAfterOpenBraceInBlockContext , this . SpaceAfterGetSetInMember ,
361
369
this . NoSpaceBetweenReturnAndSemicolon ,
362
370
this . SpaceAfterCertainKeywords ,
@@ -574,6 +582,10 @@ module ts.formatting {
574
582
return false ;
575
583
}
576
584
585
+ static IsFunctionDeclarationOrFunctionExpressionContext ( context : FormattingContext ) : boolean {
586
+ return context . contextNode . kind === SyntaxKind . FunctionDeclaration || context . contextNode . kind === SyntaxKind . FunctionExpression ;
587
+ }
588
+
577
589
static IsTypeScriptDeclWithBlockContext ( context : FormattingContext ) : boolean {
578
590
return Rules . NodeIsTypeScriptDeclWithBlockContext ( context . contextNode ) ;
579
591
}
0 commit comments