Add missing brands to the syntax interfaces.

This commit is contained in:
Cyrus Najmabadi 2014-11-04 20:52:23 -08:00
parent a9a2fe501a
commit ba2bdc4124
6 changed files with 15 additions and 55 deletions

View File

@ -1134,7 +1134,7 @@ module TypeScript.Parser {
return isPropertyName(peekToken(modifierCount + 1), inErrorRecovery);
}
function parseAccessor(checkForStrictMode: boolean): ISyntaxNode {
function parseAccessor(checkForStrictMode: boolean): IPropertyAssignmentSyntax {
var modifiers = parseModifiers();
var _currenToken = currentToken();
var tokenKind = _currenToken.kind;

View File

@ -35,7 +35,7 @@ module TypeScript.PrettyPrinter {
return 1;
}
private newLineCountBetweenStatements(element1: IClassElementSyntax, element2: IClassElementSyntax): number {
private newLineCountBetweenStatements(element1: IStatementSyntax, element2: IStatementSyntax): number {
if (!element1 || !element2) {
return 0;
}

View File

@ -219,7 +219,7 @@ module TypeScript.Scanner {
}
class FixedWidthTokenWithNoTrivia implements ISyntaxToken {
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any;
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _nameBrand: any; public _syntaxNodeOrTokenBrand: any;
public parent: ISyntaxElement;
public childCount: number;
@ -254,7 +254,7 @@ module TypeScript.Scanner {
FixedWidthTokenWithNoTrivia.prototype.childCount = 0;
class LargeScannerToken implements ISyntaxToken {
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any;
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _nameBrand: any; public _syntaxNodeOrTokenBrand: any;
public parent: ISyntaxElement;
public childCount: number;

View File

@ -431,6 +431,7 @@ module TypeScript {
}
export interface IModuleElementSyntax extends ISyntaxNode {
_moduleElementBrand: any;
}
export interface IStatementSyntax extends IModuleElementSyntax {
@ -438,15 +439,19 @@ module TypeScript {
}
export interface ITypeMemberSyntax extends ISyntaxNode {
_typeMemberBrand: any;
}
export interface IClassElementSyntax extends ISyntaxNode {
_classElementBrand: any;
}
export interface IMemberDeclarationSyntax extends IClassElementSyntax {
_memberDeclarationBrand: any;
}
export interface IPropertyAssignmentSyntax extends IClassElementSyntax {
_propertyAssignmentBrand: any;
}
export interface ISwitchClauseSyntax extends ISyntaxNode {
@ -488,5 +493,6 @@ module TypeScript {
}
export interface INameSyntax extends ITypeSyntax {
_nameBrand: any;
}
}

View File

@ -1055,54 +1055,6 @@ function getSafeName(child: IMemberDefinition) {
return child.name;
}
function generateBrands(definition: ITypeDefinition, accessibility: boolean): string {
var properties = "";
var types: string[] = [];
if (definition.interfaces) {
var ifaces = definition.interfaces.slice(0);
var i: number;
for (i = 0; i < ifaces.length; i++) {
var current = ifaces[i];
while (current !== undefined) {
if (!TypeScript.ArrayUtilities.contains(ifaces, current)) {
ifaces.push(current);
}
current = interfaces[current];
}
}
for (i = 0; i < ifaces.length; i++) {
var type = ifaces[i];
type = getStringWithoutSuffix(type);
if (isInterface(type)) {
type = "_" + type.substr(1, 1).toLowerCase() + type.substr(2) + "Brand";
}
types.push(type);
}
}
types.push("_syntaxNodeOrTokenBrand");
if (types.length > 0) {
properties += " ";
for (var i = 0; i < types.length; i++) {
if (accessibility) {
properties += " public ";
}
properties += types[i] + ": any;";
}
properties += "\r\n";
}
return properties;
}
function generateConstructorFunction(definition: ITypeDefinition) {
var result = " export var " + definition.name + ": " + getNameWithoutSuffix(definition) + "Constructor = <any>function(data: number";

View File

@ -304,7 +304,7 @@ module TypeScript.Syntax {
}
class EmptyToken implements ISyntaxToken {
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any;
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _nameBrand: any; public _syntaxNodeOrTokenBrand: any;
public parent: ISyntaxElement;
public childCount: number;
@ -418,13 +418,14 @@ module TypeScript.Syntax {
EmptyToken.prototype.childCount = 0;
class RealizedToken implements ISyntaxToken {
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _nameBrand: any; public _syntaxNodeOrTokenBrand: any;
private _fullStart: number;
private _isKeywordConvertedToIdentifier: boolean;
private _leadingTrivia: ISyntaxTriviaList;
private _text: string;
private _trailingTrivia: ISyntaxTriviaList;
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any;
public parent: ISyntaxElement;
public childCount: number;
@ -490,7 +491,8 @@ module TypeScript.Syntax {
RealizedToken.prototype.childCount = 0;
class ConvertedKeywordToken implements ISyntaxToken {
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any;
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _nameBrand: any; public _syntaxNodeOrTokenBrand: any;
public parent: ISyntaxElement;
public kind: SyntaxKind;
public childCount: number;