Skip to content

Commit 6895efc

Browse files
Function property assignments can also be generators.
Conflicts: src/services/syntax/SyntaxGenerator.js.map
1 parent e0c93a1 commit 6895efc

File tree

7 files changed

+27
-11
lines changed

7 files changed

+27
-11
lines changed

src/services/syntax/SyntaxGenerator.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/services/syntax/SyntaxGenerator.js.map

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/services/syntax/parser.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3217,16 +3217,19 @@ module TypeScript.Parser {
32173217
}
32183218
}
32193219

3220-
// All the rest of the property assignments start with property names. They are:
3220+
// All the rest of the property assignments start with property names or an asterix token. They are:
32213221
// id: e
32223222
// [e1]: e2
32233223
// id() { }
32243224
// [e]() { }
3225-
if (isPropertyName(/*peekIndex:*/ 0, inErrorRecovery)) {
3225+
// *id() { }
3226+
// *[e]() { }
3227+
if (_currentToken.kind === SyntaxKind.AsteriskToken || isPropertyName(/*peekIndex:*/ 0, inErrorRecovery)) {
3228+
var asterixToken = tryEatToken(SyntaxKind.AsteriskToken);
32263229
var propertyName = parsePropertyName();
32273230

3228-
if (isCallSignature(/*peekIndex:*/ 0)) {
3229-
return parseFunctionPropertyAssignment(propertyName);
3231+
if (asterixToken !== undefined || isCallSignature(/*peekIndex:*/ 0)) {
3232+
return parseFunctionPropertyAssignment(asterixToken, propertyName);
32303233
}
32313234
else {
32323235
// PropertyName[?Yield] : AssignmentExpression[In, ?Yield]
@@ -3249,6 +3252,7 @@ module TypeScript.Parser {
32493252

32503253
function isPropertyAssignment(inErrorRecovery: boolean): boolean {
32513254
return isAccessor(modifierCount(), inErrorRecovery) ||
3255+
currentToken().kind === SyntaxKind.AsteriskToken ||
32523256
isPropertyName(/*peekIndex:*/ 0, inErrorRecovery);
32533257
}
32543258

@@ -3320,8 +3324,9 @@ module TypeScript.Parser {
33203324
eatToken(SyntaxKind.CloseBracketToken));
33213325
}
33223326

3323-
function parseFunctionPropertyAssignment(propertyName: IPropertyNameSyntax): FunctionPropertyAssignmentSyntax {
3327+
function parseFunctionPropertyAssignment(asterixToken: ISyntaxToken, propertyName: IPropertyNameSyntax): FunctionPropertyAssignmentSyntax {
33243328
return new FunctionPropertyAssignmentSyntax(parseNodeData,
3329+
asterixToken,
33253330
propertyName,
33263331
parseCallSignature(/*requireCompleteTypeParameterList:*/ false),
33273332
parseFunctionBlock());

src/services/syntax/syntaxGenerator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,7 @@ var definitions:ITypeDefinition[] = [
907907
baseType: 'ISyntaxNode',
908908
interfaces: ['IPropertyAssignmentSyntax'],
909909
children: [
910+
<any>{ name: 'asterixToken', isToken: true, isOptional: true },
910911
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
911912
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
912913
<any>{ name: 'block', type: 'BlockSyntax' }

src/services/syntax/syntaxInterfaces.generated.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,11 +640,12 @@ module TypeScript {
640640
export interface SimplePropertyAssignmentConstructor { new (data: number, propertyName: IPropertyNameSyntax, colonToken: ISyntaxToken, expression: IExpressionSyntax): SimplePropertyAssignmentSyntax }
641641

642642
export interface FunctionPropertyAssignmentSyntax extends ISyntaxNode, IPropertyAssignmentSyntax {
643+
asterixToken: ISyntaxToken;
643644
propertyName: IPropertyNameSyntax;
644645
callSignature: CallSignatureSyntax;
645646
block: BlockSyntax;
646647
}
647-
export interface FunctionPropertyAssignmentConstructor { new (data: number, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax): FunctionPropertyAssignmentSyntax }
648+
export interface FunctionPropertyAssignmentConstructor { new (data: number, asterixToken: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax): FunctionPropertyAssignmentSyntax }
648649

649650
export interface ParameterSyntax extends ISyntaxNode {
650651
dotDotDotToken: ISyntaxToken;

src/services/syntax/syntaxNodes.concrete.generated.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,22 +1741,25 @@ module TypeScript {
17411741
}
17421742
}
17431743

1744-
export var FunctionPropertyAssignmentSyntax: FunctionPropertyAssignmentConstructor = <any>function(data: number, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax) {
1744+
export var FunctionPropertyAssignmentSyntax: FunctionPropertyAssignmentConstructor = <any>function(data: number, asterixToken: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax) {
17451745
if (data) { this.__data = data; }
1746+
this.asterixToken = asterixToken,
17461747
this.propertyName = propertyName,
17471748
this.callSignature = callSignature,
17481749
this.block = block,
1750+
asterixToken && (asterixToken.parent = this),
17491751
propertyName.parent = this,
17501752
callSignature.parent = this,
17511753
block.parent = this;
17521754
};
17531755
FunctionPropertyAssignmentSyntax.prototype.kind = SyntaxKind.FunctionPropertyAssignment;
1754-
FunctionPropertyAssignmentSyntax.prototype.childCount = 3;
1756+
FunctionPropertyAssignmentSyntax.prototype.childCount = 4;
17551757
FunctionPropertyAssignmentSyntax.prototype.childAt = function(index: number): ISyntaxElement {
17561758
switch (index) {
1757-
case 0: return this.propertyName;
1758-
case 1: return this.callSignature;
1759-
case 2: return this.block;
1759+
case 0: return this.asterixToken;
1760+
case 1: return this.propertyName;
1761+
case 2: return this.callSignature;
1762+
case 3: return this.block;
17601763
}
17611764
}
17621765

src/services/syntax/syntaxWalker.generated.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ module TypeScript {
572572
}
573573

574574
public visitFunctionPropertyAssignment(node: FunctionPropertyAssignmentSyntax): void {
575+
this.visitOptionalToken(node.asterixToken);
575576
visitNodeOrToken(this, node.propertyName);
576577
visitNodeOrToken(this, node.callSignature);
577578
visitNodeOrToken(this, node.block);

0 commit comments

Comments
 (0)