mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Function property assignments can also be generators.
Conflicts: src/services/syntax/SyntaxGenerator.js.map
This commit is contained in:
@@ -1759,6 +1759,7 @@ var definitions = [
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['IPropertyAssignmentSyntax'],
|
||||
children: [
|
||||
{ name: 'asterixToken', isToken: true, isOptional: true },
|
||||
{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
{ name: 'block', type: 'BlockSyntax' }
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -3217,16 +3217,19 @@ module TypeScript.Parser {
|
||||
}
|
||||
}
|
||||
|
||||
// All the rest of the property assignments start with property names. They are:
|
||||
// All the rest of the property assignments start with property names or an asterix token. They are:
|
||||
// id: e
|
||||
// [e1]: e2
|
||||
// id() { }
|
||||
// [e]() { }
|
||||
if (isPropertyName(/*peekIndex:*/ 0, inErrorRecovery)) {
|
||||
// *id() { }
|
||||
// *[e]() { }
|
||||
if (_currentToken.kind === SyntaxKind.AsteriskToken || isPropertyName(/*peekIndex:*/ 0, inErrorRecovery)) {
|
||||
var asterixToken = tryEatToken(SyntaxKind.AsteriskToken);
|
||||
var propertyName = parsePropertyName();
|
||||
|
||||
if (isCallSignature(/*peekIndex:*/ 0)) {
|
||||
return parseFunctionPropertyAssignment(propertyName);
|
||||
if (asterixToken !== undefined || isCallSignature(/*peekIndex:*/ 0)) {
|
||||
return parseFunctionPropertyAssignment(asterixToken, propertyName);
|
||||
}
|
||||
else {
|
||||
// PropertyName[?Yield] : AssignmentExpression[In, ?Yield]
|
||||
@@ -3249,6 +3252,7 @@ module TypeScript.Parser {
|
||||
|
||||
function isPropertyAssignment(inErrorRecovery: boolean): boolean {
|
||||
return isAccessor(modifierCount(), inErrorRecovery) ||
|
||||
currentToken().kind === SyntaxKind.AsteriskToken ||
|
||||
isPropertyName(/*peekIndex:*/ 0, inErrorRecovery);
|
||||
}
|
||||
|
||||
@@ -3320,8 +3324,9 @@ module TypeScript.Parser {
|
||||
eatToken(SyntaxKind.CloseBracketToken));
|
||||
}
|
||||
|
||||
function parseFunctionPropertyAssignment(propertyName: IPropertyNameSyntax): FunctionPropertyAssignmentSyntax {
|
||||
function parseFunctionPropertyAssignment(asterixToken: ISyntaxToken, propertyName: IPropertyNameSyntax): FunctionPropertyAssignmentSyntax {
|
||||
return new FunctionPropertyAssignmentSyntax(parseNodeData,
|
||||
asterixToken,
|
||||
propertyName,
|
||||
parseCallSignature(/*requireCompleteTypeParameterList:*/ false),
|
||||
parseFunctionBlock());
|
||||
|
||||
@@ -907,6 +907,7 @@ var definitions:ITypeDefinition[] = [
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['IPropertyAssignmentSyntax'],
|
||||
children: [
|
||||
<any>{ name: 'asterixToken', isToken: true, isOptional: true },
|
||||
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
<any>{ name: 'block', type: 'BlockSyntax' }
|
||||
|
||||
@@ -640,11 +640,12 @@ module TypeScript {
|
||||
export interface SimplePropertyAssignmentConstructor { new (data: number, propertyName: IPropertyNameSyntax, colonToken: ISyntaxToken, expression: IExpressionSyntax): SimplePropertyAssignmentSyntax }
|
||||
|
||||
export interface FunctionPropertyAssignmentSyntax extends ISyntaxNode, IPropertyAssignmentSyntax {
|
||||
asterixToken: ISyntaxToken;
|
||||
propertyName: IPropertyNameSyntax;
|
||||
callSignature: CallSignatureSyntax;
|
||||
block: BlockSyntax;
|
||||
}
|
||||
export interface FunctionPropertyAssignmentConstructor { new (data: number, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax): FunctionPropertyAssignmentSyntax }
|
||||
export interface FunctionPropertyAssignmentConstructor { new (data: number, asterixToken: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax): FunctionPropertyAssignmentSyntax }
|
||||
|
||||
export interface ParameterSyntax extends ISyntaxNode {
|
||||
dotDotDotToken: ISyntaxToken;
|
||||
|
||||
@@ -1741,22 +1741,25 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var FunctionPropertyAssignmentSyntax: FunctionPropertyAssignmentConstructor = <any>function(data: number, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax) {
|
||||
export var FunctionPropertyAssignmentSyntax: FunctionPropertyAssignmentConstructor = <any>function(data: number, asterixToken: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.asterixToken = asterixToken,
|
||||
this.propertyName = propertyName,
|
||||
this.callSignature = callSignature,
|
||||
this.block = block,
|
||||
asterixToken && (asterixToken.parent = this),
|
||||
propertyName.parent = this,
|
||||
callSignature.parent = this,
|
||||
block.parent = this;
|
||||
};
|
||||
FunctionPropertyAssignmentSyntax.prototype.kind = SyntaxKind.FunctionPropertyAssignment;
|
||||
FunctionPropertyAssignmentSyntax.prototype.childCount = 3;
|
||||
FunctionPropertyAssignmentSyntax.prototype.childCount = 4;
|
||||
FunctionPropertyAssignmentSyntax.prototype.childAt = function(index: number): ISyntaxElement {
|
||||
switch (index) {
|
||||
case 0: return this.propertyName;
|
||||
case 1: return this.callSignature;
|
||||
case 2: return this.block;
|
||||
case 0: return this.asterixToken;
|
||||
case 1: return this.propertyName;
|
||||
case 2: return this.callSignature;
|
||||
case 3: return this.block;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -572,6 +572,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public visitFunctionPropertyAssignment(node: FunctionPropertyAssignmentSyntax): void {
|
||||
this.visitOptionalToken(node.asterixToken);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
visitNodeOrToken(this, node.block);
|
||||
|
||||
Reference in New Issue
Block a user