mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
Remove IndexMemberDeclaration, we can just use IndexSignature instead.
Conflicts: src/services/syntax/SyntaxGenerator.js.map
This commit is contained in:
parent
749501e8bf
commit
aa91aa7f44
@ -1417,8 +1417,9 @@ var definitions = [
|
||||
{
|
||||
name: 'IndexSignatureSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['ITypeMemberSyntax'],
|
||||
interfaces: ['ITypeMemberSyntax', 'IClassElementSyntax'],
|
||||
children: [
|
||||
{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
{ name: 'openBracketToken', isToken: true },
|
||||
{ name: 'parameters', isSeparatedList: true, elementType: 'ParameterSyntax' },
|
||||
{ name: 'closeBracketToken', isToken: true },
|
||||
@ -1578,16 +1579,6 @@ var definitions = [
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
},
|
||||
{
|
||||
name: 'IndexMemberDeclarationSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['IClassElementSyntax'],
|
||||
children: [
|
||||
{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
{ name: 'indexSignature', type: 'IndexSignatureSyntax' }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
},
|
||||
{
|
||||
name: 'ThrowStatementSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1360,8 +1360,8 @@ module TypeScript.Parser {
|
||||
if (isConstructorDeclaration()) {
|
||||
return parseConstructorDeclaration(modifiers);
|
||||
}
|
||||
else if (isIndexMemberDeclaration()) {
|
||||
return parseIndexMemberDeclaration(modifiers);
|
||||
else if (isIndexSignature(/*peekIndex:*/ 0)) {
|
||||
return parseIndexSignature(modifiers);
|
||||
}
|
||||
else if (isAccessor(inErrorRecovery)) {
|
||||
return parseAccessor(modifiers);
|
||||
@ -1442,12 +1442,6 @@ module TypeScript.Parser {
|
||||
return isIndexSignature(/*peekIndex:*/ 0);
|
||||
}
|
||||
|
||||
function parseIndexMemberDeclaration(modifiers: ISyntaxToken[]): IndexMemberDeclarationSyntax {
|
||||
return new IndexMemberDeclarationSyntax(contextFlags,
|
||||
modifiers,
|
||||
parseIndexSignature());
|
||||
}
|
||||
|
||||
function isFunctionDeclaration(modifierCount: number): boolean {
|
||||
return peekToken(modifierCount).kind === SyntaxKind.FunctionKeyword;
|
||||
}
|
||||
@ -1593,7 +1587,7 @@ module TypeScript.Parser {
|
||||
return parseConstructSignature();
|
||||
}
|
||||
else if (isIndexSignature(/*tokenIndex:*/ 0)) {
|
||||
return parseIndexSignature();
|
||||
return parseIndexSignature(/*modifiers:*/ []);
|
||||
}
|
||||
else if (isMethodOrPropertySignature(inErrorRecovery)) {
|
||||
var propertyName = parsePropertyName();
|
||||
@ -1618,8 +1612,9 @@ module TypeScript.Parser {
|
||||
parseCallSignatureWithSemicolonOrComma(/*requireCompleteTypeParameterList:*/ false, /*yieldAndGeneratorParameterContext:*/ false, /*asyncContext:*/ false));
|
||||
}
|
||||
|
||||
function parseIndexSignature(): IndexSignatureSyntax {
|
||||
function parseIndexSignature(modifiers: ISyntaxToken[]): IndexSignatureSyntax {
|
||||
return new IndexSignatureSyntax(contextFlags,
|
||||
modifiers,
|
||||
eatToken(SyntaxKind.OpenBracketToken),
|
||||
parseSeparatedSyntaxList<ParameterSyntax>(ListParsingState.IndexSignature_Parameters),
|
||||
eatToken(SyntaxKind.CloseBracketToken),
|
||||
|
||||
@ -600,6 +600,7 @@ module TypeScript.PrettyPrinter {
|
||||
}
|
||||
|
||||
public visitIndexSignature(node: IndexSignatureSyntax): void {
|
||||
this.appendSpaceList(node.modifiers);
|
||||
this.appendToken(node.openBracketToken);
|
||||
this.appendSeparatorSpaceList(node.parameters)
|
||||
this.appendToken(node.closeBracketToken);
|
||||
@ -692,12 +693,6 @@ module TypeScript.PrettyPrinter {
|
||||
this.appendBody(node.body);
|
||||
}
|
||||
|
||||
public visitIndexMemberDeclaration(node: IndexMemberDeclarationSyntax): void {
|
||||
this.appendSpaceList(node.modifiers);
|
||||
this.ensureSpace();
|
||||
visitNodeOrToken(this, node.indexSignature);
|
||||
}
|
||||
|
||||
public visitMemberFunctionDeclaration(node: MemberFunctionDeclarationSyntax): void {
|
||||
this.appendSpaceList(node.modifiers);
|
||||
this.ensureSpace();
|
||||
|
||||
@ -555,8 +555,9 @@ var definitions:ITypeDefinition[] = [
|
||||
<any>{
|
||||
name: 'IndexSignatureSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['ITypeMemberSyntax'],
|
||||
interfaces: ['ITypeMemberSyntax', 'IClassElementSyntax'],
|
||||
children: [
|
||||
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
<any>{ name: 'openBracketToken', isToken: true },
|
||||
<any>{ name: 'parameters', isSeparatedList: true, elementType: 'ParameterSyntax' },
|
||||
<any>{ name: 'closeBracketToken', isToken: true },
|
||||
@ -717,16 +718,6 @@ var definitions:ITypeDefinition[] = [
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
},
|
||||
<any>{
|
||||
name: 'IndexMemberDeclarationSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['IClassElementSyntax'],
|
||||
children: [
|
||||
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
<any>{ name: 'indexSignature', type: 'IndexSignatureSyntax' }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
},
|
||||
<any>{
|
||||
name: 'ThrowStatementSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
|
||||
@ -174,12 +174,6 @@ module TypeScript {
|
||||
}
|
||||
export interface ConstructorDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], constructorKeyword: ISyntaxToken, callSignature: CallSignatureSyntax, body: BlockSyntax | ExpressionBody | ISyntaxToken): ConstructorDeclarationSyntax }
|
||||
|
||||
export interface IndexMemberDeclarationSyntax extends ISyntaxNode, IClassElementSyntax {
|
||||
modifiers: ISyntaxToken[];
|
||||
indexSignature: IndexSignatureSyntax;
|
||||
}
|
||||
export interface IndexMemberDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], indexSignature: IndexSignatureSyntax): IndexMemberDeclarationSyntax }
|
||||
|
||||
export interface GetAccessorSyntax extends ISyntaxNode, IAccessorSyntax {
|
||||
modifiers: ISyntaxToken[];
|
||||
getKeyword: ISyntaxToken;
|
||||
@ -220,14 +214,15 @@ module TypeScript {
|
||||
}
|
||||
export interface ConstructSignatureConstructor { new (data: number, newKeyword: ISyntaxToken, callSignature: CallSignatureSyntax): ConstructSignatureSyntax }
|
||||
|
||||
export interface IndexSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax {
|
||||
export interface IndexSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax, IClassElementSyntax {
|
||||
modifiers: ISyntaxToken[];
|
||||
openBracketToken: ISyntaxToken;
|
||||
parameters: ISeparatedSyntaxList<ParameterSyntax>;
|
||||
closeBracketToken: ISyntaxToken;
|
||||
typeAnnotation: TypeAnnotationSyntax;
|
||||
semicolonOrCommaToken: ISyntaxToken;
|
||||
}
|
||||
export interface IndexSignatureConstructor { new (data: number, openBracketToken: ISyntaxToken, parameters: ISeparatedSyntaxList<ParameterSyntax>, closeBracketToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, semicolonOrCommaToken: ISyntaxToken): IndexSignatureSyntax }
|
||||
export interface IndexSignatureConstructor { new (data: number, modifiers: ISyntaxToken[], openBracketToken: ISyntaxToken, parameters: ISeparatedSyntaxList<ParameterSyntax>, closeBracketToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, semicolonOrCommaToken: ISyntaxToken): IndexSignatureSyntax }
|
||||
|
||||
export interface MethodSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax {
|
||||
propertyName: IPropertyNameSyntax;
|
||||
|
||||
@ -182,7 +182,6 @@ module TypeScript {
|
||||
MemberFunctionDeclaration,
|
||||
MemberVariableDeclaration,
|
||||
ConstructorDeclaration,
|
||||
IndexMemberDeclaration,
|
||||
|
||||
// ClassElement and PropertyAssignment
|
||||
GetAccessor,
|
||||
|
||||
@ -475,22 +475,6 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var IndexMemberDeclarationSyntax: IndexMemberDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], indexSignature: IndexSignatureSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.indexSignature = indexSignature,
|
||||
modifiers.parent = this,
|
||||
indexSignature.parent = this;
|
||||
};
|
||||
IndexMemberDeclarationSyntax.prototype.kind = SyntaxKind.IndexMemberDeclaration;
|
||||
IndexMemberDeclarationSyntax.prototype.childCount = 2;
|
||||
IndexMemberDeclarationSyntax.prototype.childAt = function(index: number): ISyntaxElement {
|
||||
switch (index) {
|
||||
case 0: return this.modifiers;
|
||||
case 1: return this.indexSignature;
|
||||
}
|
||||
}
|
||||
|
||||
export var GetAccessorSyntax: GetAccessorConstructor = <any>function(data: number, modifiers: ISyntaxToken[], getKeyword: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, body: BlockSyntax | ExpressionBody | ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
@ -601,13 +585,15 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var IndexSignatureSyntax: IndexSignatureConstructor = <any>function(data: number, openBracketToken: ISyntaxToken, parameters: ISeparatedSyntaxList<ParameterSyntax>, closeBracketToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, semicolonOrCommaToken: ISyntaxToken) {
|
||||
export var IndexSignatureSyntax: IndexSignatureConstructor = <any>function(data: number, modifiers: ISyntaxToken[], openBracketToken: ISyntaxToken, parameters: ISeparatedSyntaxList<ParameterSyntax>, closeBracketToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, semicolonOrCommaToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.openBracketToken = openBracketToken,
|
||||
this.parameters = parameters,
|
||||
this.closeBracketToken = closeBracketToken,
|
||||
this.typeAnnotation = typeAnnotation,
|
||||
this.semicolonOrCommaToken = semicolonOrCommaToken,
|
||||
modifiers.parent = this,
|
||||
openBracketToken.parent = this,
|
||||
parameters.parent = this,
|
||||
closeBracketToken.parent = this,
|
||||
@ -615,14 +601,15 @@ module TypeScript {
|
||||
semicolonOrCommaToken && (semicolonOrCommaToken.parent = this);
|
||||
};
|
||||
IndexSignatureSyntax.prototype.kind = SyntaxKind.IndexSignature;
|
||||
IndexSignatureSyntax.prototype.childCount = 5;
|
||||
IndexSignatureSyntax.prototype.childCount = 6;
|
||||
IndexSignatureSyntax.prototype.childAt = function(index: number): ISyntaxElement {
|
||||
switch (index) {
|
||||
case 0: return this.openBracketToken;
|
||||
case 1: return this.parameters;
|
||||
case 2: return this.closeBracketToken;
|
||||
case 3: return this.typeAnnotation;
|
||||
case 4: return this.semicolonOrCommaToken;
|
||||
case 0: return this.modifiers;
|
||||
case 1: return this.openBracketToken;
|
||||
case 2: return this.parameters;
|
||||
case 3: return this.closeBracketToken;
|
||||
case 4: return this.typeAnnotation;
|
||||
case 5: return this.semicolonOrCommaToken;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -369,7 +369,8 @@ module TypeScript {
|
||||
|
||||
public visitIndexSignature(node: IndexSignatureSyntax): void {
|
||||
if (this.checkIndexSignatureParameter(node) ||
|
||||
this.checkForCommaInsteadOfSemicolon(node.semicolonOrCommaToken)) {
|
||||
this.checkForCommaInsteadOfSemicolon(node.semicolonOrCommaToken) ||
|
||||
this.checkIndexSignatureModifiers(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -624,15 +625,7 @@ module TypeScript {
|
||||
return false;
|
||||
}
|
||||
|
||||
public visitIndexMemberDeclaration(node: IndexMemberDeclarationSyntax): void {
|
||||
if (this.checkIndexMemberModifiers(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.visitIndexMemberDeclaration(node);
|
||||
}
|
||||
|
||||
private checkIndexMemberModifiers(node: IndexMemberDeclarationSyntax): boolean {
|
||||
private checkIndexSignatureModifiers(node: IndexSignatureSyntax): boolean {
|
||||
if (node.modifiers.length > 0) {
|
||||
return this.pushDiagnostic(node.modifiers[0], DiagnosticCode.Modifiers_cannot_appear_here);
|
||||
}
|
||||
@ -658,7 +651,7 @@ module TypeScript {
|
||||
public visitGetAccessor(node: GetAccessorSyntax): void {
|
||||
if (this.checkForAccessorDeclarationInAmbientContext(node) ||
|
||||
this.checkEcmaScriptVersionIsAtLeast(node.getKeyword, ts.ScriptTarget.ES5, DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) ||
|
||||
this.checkForDisallowedModifiers(node.modifiers) ||
|
||||
this.checkForDisallowedModifiersInBlockOrObjectLitera(node.modifiers) ||
|
||||
this.checkClassElementModifiers(node.modifiers) ||
|
||||
this.checkForDisallowedAccessorTypeParameters(node.callSignature) ||
|
||||
this.checkGetAccessorParameter(node) ||
|
||||
@ -749,7 +742,7 @@ module TypeScript {
|
||||
public visitSetAccessor(node: SetAccessorSyntax): void {
|
||||
if (this.checkForAccessorDeclarationInAmbientContext(node) ||
|
||||
this.checkEcmaScriptVersionIsAtLeast(node.setKeyword, ts.ScriptTarget.ES5, DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) ||
|
||||
this.checkForDisallowedModifiers(node.modifiers) ||
|
||||
this.checkForDisallowedModifiersInBlockOrObjectLitera(node.modifiers) ||
|
||||
this.checkClassElementModifiers(node.modifiers) ||
|
||||
this.checkForDisallowedAccessorTypeParameters(node.callSignature) ||
|
||||
this.checkForDisallowedSetAccessorTypeAnnotation(node) ||
|
||||
@ -1432,7 +1425,7 @@ module TypeScript {
|
||||
return false;
|
||||
}
|
||||
|
||||
private checkForDisallowedModifiers(modifiers: ISyntaxToken[]): boolean {
|
||||
private checkForDisallowedModifiersInBlockOrObjectLitera(modifiers: ISyntaxToken[]): boolean {
|
||||
if (this.inBlock || this.inObjectLiteralExpression) {
|
||||
if (modifiers.length > 0) {
|
||||
return this.pushDiagnostic(modifiers[0], DiagnosticCode.Modifiers_cannot_appear_here);
|
||||
@ -1444,7 +1437,7 @@ module TypeScript {
|
||||
|
||||
public visitFunctionDeclaration(node: FunctionDeclarationSyntax): void {
|
||||
if (this.checkForDisallowedDeclareModifier(node.modifiers) ||
|
||||
this.checkForDisallowedModifiers(node.modifiers) ||
|
||||
this.checkForDisallowedModifiersInBlockOrObjectLitera(node.modifiers) ||
|
||||
this.checkForRequiredDeclareModifier(node, node.identifier, node.modifiers) ||
|
||||
this.checkModuleElementModifiers(node.modifiers) ||
|
||||
this.checkForDisallowedEvalOrArguments(node, node.identifier) ||
|
||||
@ -1490,7 +1483,7 @@ module TypeScript {
|
||||
|
||||
public visitVariableStatement(node: VariableStatementSyntax): void {
|
||||
if (this.checkForDisallowedDeclareModifier(node.modifiers) ||
|
||||
this.checkForDisallowedModifiers(node.modifiers) ||
|
||||
this.checkForDisallowedModifiersInBlockOrObjectLitera(node.modifiers) ||
|
||||
this.checkForRequiredDeclareModifier(node, node.variableDeclaration.varConstOrLetKeyword, node.modifiers) ||
|
||||
this.checkModuleElementModifiers(node.modifiers) ||
|
||||
this.checkForDisallowedAsyncModifier(node.modifiers)) {
|
||||
|
||||
@ -100,7 +100,7 @@ module TypeScript {
|
||||
if (element) {
|
||||
switch (element.kind) {
|
||||
case SyntaxKind.ConstructorDeclaration:
|
||||
case SyntaxKind.IndexMemberDeclaration:
|
||||
case SyntaxKind.IndexSignature:
|
||||
case SyntaxKind.MemberFunctionDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
|
||||
@ -25,7 +25,6 @@ module TypeScript {
|
||||
case SyntaxKind.MemberFunctionDeclaration: return visitor.visitMemberFunctionDeclaration(<MemberFunctionDeclarationSyntax>element);
|
||||
case SyntaxKind.MemberVariableDeclaration: return visitor.visitMemberVariableDeclaration(<MemberVariableDeclarationSyntax>element);
|
||||
case SyntaxKind.ConstructorDeclaration: return visitor.visitConstructorDeclaration(<ConstructorDeclarationSyntax>element);
|
||||
case SyntaxKind.IndexMemberDeclaration: return visitor.visitIndexMemberDeclaration(<IndexMemberDeclarationSyntax>element);
|
||||
case SyntaxKind.GetAccessor: return visitor.visitGetAccessor(<GetAccessorSyntax>element);
|
||||
case SyntaxKind.SetAccessor: return visitor.visitSetAccessor(<SetAccessorSyntax>element);
|
||||
case SyntaxKind.PropertySignature: return visitor.visitPropertySignature(<PropertySignatureSyntax>element);
|
||||
@ -126,7 +125,6 @@ module TypeScript {
|
||||
visitMemberFunctionDeclaration(node: MemberFunctionDeclarationSyntax): any;
|
||||
visitMemberVariableDeclaration(node: MemberVariableDeclarationSyntax): any;
|
||||
visitConstructorDeclaration(node: ConstructorDeclarationSyntax): any;
|
||||
visitIndexMemberDeclaration(node: IndexMemberDeclarationSyntax): any;
|
||||
visitGetAccessor(node: GetAccessorSyntax): any;
|
||||
visitSetAccessor(node: SetAccessorSyntax): any;
|
||||
visitPropertySignature(node: PropertySignatureSyntax): any;
|
||||
|
||||
@ -170,11 +170,6 @@ module TypeScript {
|
||||
visitNodeOrToken(this, node.body);
|
||||
}
|
||||
|
||||
public visitIndexMemberDeclaration(node: IndexMemberDeclarationSyntax): void {
|
||||
this.visitList(node.modifiers);
|
||||
visitNodeOrToken(this, node.indexSignature);
|
||||
}
|
||||
|
||||
public visitGetAccessor(node: GetAccessorSyntax): void {
|
||||
this.visitList(node.modifiers);
|
||||
this.visitToken(node.getKeyword);
|
||||
@ -211,6 +206,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public visitIndexSignature(node: IndexSignatureSyntax): void {
|
||||
this.visitList(node.modifiers);
|
||||
this.visitToken(node.openBracketToken);
|
||||
this.visitList(node.parameters);
|
||||
this.visitToken(node.closeBracketToken);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user