mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
merge with master
This commit is contained in:
@@ -84,12 +84,13 @@ module ts {
|
||||
if (symbolKind & SymbolFlags.Value && !symbol.valueDeclaration) symbol.valueDeclaration = node;
|
||||
}
|
||||
|
||||
// TODO(jfreeman): Implement getDeclarationName for property name
|
||||
function getDeclarationName(node: Declaration): string {
|
||||
if (node.name) {
|
||||
if (node.kind === SyntaxKind.ModuleDeclaration && node.name.kind === SyntaxKind.StringLiteral) {
|
||||
return '"' + node.name.text + '"';
|
||||
return '"' + (<LiteralExpression>node.name).text + '"';
|
||||
}
|
||||
return node.name.text;
|
||||
return (<Identifier>node.name).text;
|
||||
}
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Constructor: return "__constructor";
|
||||
@@ -100,7 +101,7 @@ module ts {
|
||||
}
|
||||
|
||||
function getDisplayName(node: Declaration): string {
|
||||
return node.name ? identifierToString(node.name) : getDeclarationName(node);
|
||||
return node.name ? declarationNameToString(node.name) : getDeclarationName(node);
|
||||
}
|
||||
|
||||
function declareSymbol(symbols: SymbolTable, parent: Symbol, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags): Symbol {
|
||||
|
||||
+112
-82
@@ -85,7 +85,7 @@ module ts {
|
||||
checkProgram: checkProgram,
|
||||
emitFiles: invokeEmitter,
|
||||
getParentOfSymbol: getParentOfSymbol,
|
||||
getTypeOfSymbol: getTypeOfSymbol,
|
||||
getNarrowedTypeOfSymbol: getNarrowedTypeOfSymbol,
|
||||
getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol,
|
||||
getPropertiesOfType: getPropertiesOfType,
|
||||
getPropertyOfType: getPropertyOfType,
|
||||
@@ -431,7 +431,7 @@ module ts {
|
||||
|
||||
if (!result) {
|
||||
if (nameNotFoundMessage) {
|
||||
error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : identifierToString(nameArg));
|
||||
error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -443,7 +443,7 @@ module ts {
|
||||
// to a local variable in the constructor where the code will be emitted.
|
||||
var propertyName = (<PropertyDeclaration>propertyWithInvalidInitializer).name;
|
||||
error(errorLocation, Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor,
|
||||
identifierToString(propertyName), typeof nameArg === "string" ? nameArg : identifierToString(nameArg));
|
||||
declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
|
||||
return undefined;
|
||||
}
|
||||
if (result.flags & SymbolFlags.BlockScopedVariable) {
|
||||
@@ -451,7 +451,7 @@ module ts {
|
||||
var declaration = forEach(result.declarations, d => d.flags & NodeFlags.BlockScoped ? d : undefined);
|
||||
Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
|
||||
if (!isDefinedBefore(declaration, errorLocation)) {
|
||||
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, identifierToString(declaration.name));
|
||||
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -483,7 +483,7 @@ module ts {
|
||||
// This function is only for imports with entity names
|
||||
function getSymbolOfPartOfRightHandSideOfImport(entityName: EntityName, importDeclaration?: ImportDeclaration): Symbol {
|
||||
if (!importDeclaration) {
|
||||
importDeclaration = getAncestor(entityName, SyntaxKind.ImportDeclaration);
|
||||
importDeclaration = <ImportDeclaration>getAncestor(entityName, SyntaxKind.ImportDeclaration);
|
||||
Debug.assert(importDeclaration !== undefined);
|
||||
}
|
||||
// There are three things we might try to look for. In the following examples,
|
||||
@@ -525,7 +525,7 @@ module ts {
|
||||
var symbol = getSymbol(namespace.exports, (<QualifiedName>name).right.text, meaning);
|
||||
if (!symbol) {
|
||||
error(location, Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace),
|
||||
identifierToString((<QualifiedName>name).right));
|
||||
declarationNameToString((<QualifiedName>name).right));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -963,11 +963,11 @@ module ts {
|
||||
getNodeLinks(declaration).isVisible = true;
|
||||
if (aliasesToMakeVisible) {
|
||||
if (!contains(aliasesToMakeVisible, declaration)) {
|
||||
aliasesToMakeVisible.push(declaration);
|
||||
aliasesToMakeVisible.push(<ImportDeclaration>declaration);
|
||||
}
|
||||
}
|
||||
else {
|
||||
aliasesToMakeVisible = [declaration];
|
||||
aliasesToMakeVisible = [<ImportDeclaration>declaration];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -987,7 +987,7 @@ module ts {
|
||||
var hasNamespaceDeclarationsVisibile = hasVisibleDeclarations(symbolOfNameSpace);
|
||||
return hasNamespaceDeclarationsVisibile ?
|
||||
{ accessibility: SymbolAccessibility.Accessible, aliasesToMakeVisible: hasNamespaceDeclarationsVisibile.aliasesToMakeVisible } :
|
||||
{ accessibility: SymbolAccessibility.NotAccessible, errorSymbolName: identifierToString(<Identifier>firstIdentifier) };
|
||||
{ accessibility: SymbolAccessibility.NotAccessible, errorSymbolName: declarationNameToString(<Identifier>firstIdentifier) };
|
||||
}
|
||||
|
||||
function releaseStringWriter(writer: StringSymbolWriter) {
|
||||
@@ -1060,7 +1060,7 @@ module ts {
|
||||
if (symbol.declarations && symbol.declarations.length > 0) {
|
||||
var declaration = symbol.declarations[0];
|
||||
if (declaration.name) {
|
||||
writer.writeSymbol(identifierToString(declaration.name), symbol);
|
||||
writer.writeSymbol(declarationNameToString(declaration.name), symbol);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1628,7 +1628,7 @@ module ts {
|
||||
return classType.typeParameters ? createTypeReference(<GenericType>classType, map(classType.typeParameters, _ => anyType)) : classType;
|
||||
}
|
||||
|
||||
function getTypeOfVariableDeclaration(declaration: VariableDeclaration): Type {
|
||||
function getTypeOfVariableOrPropertyDeclaration(declaration: VariableDeclaration | PropertyDeclaration): Type {
|
||||
// A variable declared in a for..in statement is always of type any
|
||||
if (declaration.parent.kind === SyntaxKind.ForInStatement) {
|
||||
return anyType;
|
||||
@@ -1638,7 +1638,7 @@ module ts {
|
||||
return getTypeFromTypeNode(declaration.type);
|
||||
}
|
||||
if (declaration.kind === SyntaxKind.Parameter) {
|
||||
var func = <FunctionDeclaration>declaration.parent;
|
||||
var func = <FunctionLikeDeclaration>declaration.parent;
|
||||
// For a parameter of a set accessor, use the type of the get accessor if one is present
|
||||
if (func.kind === SyntaxKind.SetAccessor) {
|
||||
var getter = <AccessorDeclaration>getDeclarationOfKind(declaration.parent.symbol, SyntaxKind.GetAccessor);
|
||||
@@ -1647,7 +1647,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
// Use contextual parameter type if one is available
|
||||
var type = getContextuallyTypedParameterType(declaration);
|
||||
var type = getContextuallyTypedParameterType(<ParameterDeclaration>declaration);
|
||||
if (type) {
|
||||
return type;
|
||||
}
|
||||
@@ -1695,7 +1695,7 @@ module ts {
|
||||
default:
|
||||
var diagnostic = Diagnostics.Variable_0_implicitly_has_an_1_type;
|
||||
}
|
||||
error(declaration, diagnostic, identifierToString(declaration.name), typeToString(type));
|
||||
error(declaration, diagnostic, declarationNameToString(declaration.name), typeToString(type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1713,7 +1713,7 @@ module ts {
|
||||
}
|
||||
// Handle variable, parameter or property
|
||||
links.type = resolvingType;
|
||||
var type = getTypeOfVariableDeclaration(<VariableDeclaration>declaration);
|
||||
var type = getTypeOfVariableOrPropertyDeclaration(<VariableDeclaration>declaration);
|
||||
if (links.type === resolvingType) {
|
||||
links.type = type;
|
||||
}
|
||||
@@ -2506,7 +2506,7 @@ module ts {
|
||||
returnType = getAnnotatedAccessorType(setter);
|
||||
}
|
||||
|
||||
if (!returnType && !(<FunctionDeclaration>declaration).body) {
|
||||
if (!returnType && !(<FunctionLikeDeclaration>declaration).body) {
|
||||
returnType = anyType;
|
||||
}
|
||||
}
|
||||
@@ -2536,7 +2536,7 @@ module ts {
|
||||
// Don't include signature if node is the implementation of an overloaded function. A node is considered
|
||||
// an implementation node if it has a body and the previous node is of the same kind and immediately
|
||||
// precedes the implementation node (i.e. has the same parent and ends where the implementation starts).
|
||||
if (i > 0 && (<FunctionDeclaration>node).body) {
|
||||
if (i > 0 && (<FunctionLikeDeclaration>node).body) {
|
||||
var previous = symbol.declarations[i - 1];
|
||||
if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) {
|
||||
break;
|
||||
@@ -2558,7 +2558,7 @@ module ts {
|
||||
var type = getUnionType(map(signature.unionSignatures, getReturnTypeOfSignature));
|
||||
}
|
||||
else {
|
||||
var type = getReturnTypeFromBody(<FunctionDeclaration>signature.declaration);
|
||||
var type = getReturnTypeFromBody(<FunctionLikeDeclaration>signature.declaration);
|
||||
}
|
||||
if (signature.resolvedReturnType === resolvingType) {
|
||||
signature.resolvedReturnType = type;
|
||||
@@ -2569,7 +2569,7 @@ module ts {
|
||||
if (compilerOptions.noImplicitAny) {
|
||||
var declaration = <Declaration>signature.declaration;
|
||||
if (declaration.name) {
|
||||
error(declaration.name, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, identifierToString(declaration.name));
|
||||
error(declaration.name, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, declarationNameToString(declaration.name));
|
||||
}
|
||||
else {
|
||||
error(declaration, Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions);
|
||||
@@ -4318,7 +4318,7 @@ module ts {
|
||||
function getNarrowedTypeOfSymbol(symbol: Symbol, node: Node) {
|
||||
var type = getTypeOfSymbol(symbol);
|
||||
// Only narrow when symbol is variable of a structured type
|
||||
if (symbol.flags & SymbolFlags.Variable && type.flags & TypeFlags.Structured) {
|
||||
if (node && (symbol.flags & SymbolFlags.Variable && type.flags & TypeFlags.Structured)) {
|
||||
while (true) {
|
||||
var child = node;
|
||||
node = node.parent;
|
||||
@@ -4665,7 +4665,7 @@ module ts {
|
||||
|
||||
// Return contextual type of parameter or undefined if no contextual type is available
|
||||
function getContextuallyTypedParameterType(parameter: ParameterDeclaration): Type {
|
||||
var func = <FunctionDeclaration>parameter.parent;
|
||||
var func = <FunctionLikeDeclaration>parameter.parent;
|
||||
if (func.kind === SyntaxKind.FunctionExpression || func.kind === SyntaxKind.ArrowFunction) {
|
||||
if (isContextSensitiveExpression(func)) {
|
||||
var contextualSignature = getContextualSignature(func);
|
||||
@@ -4811,7 +4811,8 @@ module ts {
|
||||
var declaration = <PropertyDeclaration>node.parent;
|
||||
var objectLiteral = <ObjectLiteral>declaration.parent;
|
||||
var type = getContextualType(objectLiteral);
|
||||
var name = declaration.name.text;
|
||||
// TODO(jfreeman): Handle this case for computed names and symbols
|
||||
var name = (<Identifier>declaration.name).text;
|
||||
if (type && name) {
|
||||
return getTypeOfPropertyOfContextualType(type, name) ||
|
||||
isNumericName(name) && getIndexTypeOfContextualType(type, IndexKind.Number) ||
|
||||
@@ -4889,8 +4890,9 @@ module ts {
|
||||
|
||||
// Return the contextual signature for a given expression node. A contextual type provides a
|
||||
// contextual signature if it has a single call signature and if that call signature is non-generic.
|
||||
// If the contextual type is a union type and each constituent type that has a contextual signature
|
||||
// provides the same contextual signature, then the union type provides that contextual signature.
|
||||
// If the contextual type is a union type, get the signature from each type possible and if they are
|
||||
// all identical ignoring their return type, the result is same signature but with return type as
|
||||
// union type of return types from these signatures
|
||||
function getContextualSignature(node: Expression): Signature {
|
||||
var type = getContextualType(node);
|
||||
if (!type) {
|
||||
@@ -4899,19 +4901,41 @@ module ts {
|
||||
if (!(type.flags & TypeFlags.Union)) {
|
||||
return getNonGenericSignature(type);
|
||||
}
|
||||
var result: Signature;
|
||||
var signatureList: Signature[];
|
||||
var types = (<UnionType>type).types;
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
// The signature set of all constituent type with call signatures should match
|
||||
// So number of signatures allowed is either 0 or 1
|
||||
if (signatureList &&
|
||||
getSignaturesOfObjectOrUnionType(types[i], SignatureKind.Call).length > 1) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var signature = getNonGenericSignature(types[i]);
|
||||
if (signature) {
|
||||
if (!result) {
|
||||
result = signature;
|
||||
if (!signatureList) {
|
||||
// This signature will contribute to contextual union signature
|
||||
signatureList = [signature];
|
||||
}
|
||||
else if (!compareSignatures(result, signature, /*compareReturnTypes*/ true, compareTypes)) {
|
||||
else if (!compareSignatures(signatureList[0], signature, /*compareReturnTypes*/ false, compareTypes)) {
|
||||
// Signatures arent identical, do not use
|
||||
return undefined;
|
||||
}
|
||||
else {
|
||||
// Use this signature for contextual union signature
|
||||
signatureList.push(signature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Result is union of signatures collected (return type is union of return types of this signature set)
|
||||
var result: Signature;
|
||||
if (signatureList) {
|
||||
result = cloneSignature(signatureList[0]);
|
||||
// Clear resolved return type we possibly got from cloneSignature
|
||||
result.resolvedReturnType = undefined;
|
||||
result.unionSignatures = signatureList;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -5078,7 +5102,7 @@ module ts {
|
||||
var prop = getPropertyOfType(apparentType, node.right.text);
|
||||
if (!prop) {
|
||||
if (node.right.text) {
|
||||
error(node.right, Diagnostics.Property_0_does_not_exist_on_type_1, identifierToString(node.right), typeToString(type));
|
||||
error(node.right, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(node.right), typeToString(type));
|
||||
}
|
||||
return unknownType;
|
||||
}
|
||||
@@ -5725,7 +5749,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getReturnTypeFromBody(func: FunctionDeclaration, contextualMapper?: TypeMapper): Type {
|
||||
function getReturnTypeFromBody(func: FunctionLikeDeclaration, contextualMapper?: TypeMapper): Type {
|
||||
var contextualSignature = getContextualSignature(func);
|
||||
if (func.body.kind !== SyntaxKind.FunctionBlock) {
|
||||
var unwidenedType = checkAndMarkExpression(func.body, contextualMapper);
|
||||
@@ -5759,7 +5783,7 @@ module ts {
|
||||
var typeName = typeToString(widenedType);
|
||||
|
||||
if (func.name) {
|
||||
error(func, Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, identifierToString(func.name), typeName);
|
||||
error(func, Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, declarationNameToString(func.name), typeName);
|
||||
}
|
||||
else {
|
||||
error(func, Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeName);
|
||||
@@ -5803,7 +5827,7 @@ module ts {
|
||||
// An explicitly typed function whose return type isn't the Void or the Any type
|
||||
// must have at least one return statement somewhere in its body.
|
||||
// An exception to this rule is if the function implementation consists of a single 'throw' statement.
|
||||
function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func: FunctionDeclaration, returnType: Type): void {
|
||||
function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func: FunctionLikeDeclaration, returnType: Type): void {
|
||||
if (!fullTypeCheck) {
|
||||
return;
|
||||
}
|
||||
@@ -6362,7 +6386,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (parameterDeclaration.initializer && !(<FunctionDeclaration>parameterDeclaration.parent).body) {
|
||||
if (parameterDeclaration.initializer && !(<FunctionLikeDeclaration>parameterDeclaration.parent).body) {
|
||||
error(parameterDeclaration, Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
|
||||
}
|
||||
}
|
||||
@@ -6371,16 +6395,16 @@ module ts {
|
||||
function checkReferencesInInitializer(n: Node): void {
|
||||
if (n.kind === SyntaxKind.Identifier) {
|
||||
var referencedSymbol = getNodeLinks(n).resolvedSymbol;
|
||||
// check FunctionDeclaration.locals (stores parameters\function local variable)
|
||||
// check FunctionLikeDeclaration.locals (stores parameters\function local variable)
|
||||
// if it contains entry with a specified name and if this entry matches the resolved symbol
|
||||
if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(parameterDeclaration.parent.locals, referencedSymbol.name, SymbolFlags.Value) === referencedSymbol) {
|
||||
if (referencedSymbol.valueDeclaration.kind === SyntaxKind.Parameter) {
|
||||
if (referencedSymbol.valueDeclaration === parameterDeclaration) {
|
||||
error(n, Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, identifierToString(parameterDeclaration.name));
|
||||
error(n, Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, declarationNameToString(parameterDeclaration.name));
|
||||
return;
|
||||
}
|
||||
var enclosingOrReferencedParameter =
|
||||
forEach((<FunctionDeclaration>parameterDeclaration.parent).parameters, p => p === parameterDeclaration || p === referencedSymbol.valueDeclaration ? p : undefined);
|
||||
forEach((<FunctionLikeDeclaration>parameterDeclaration.parent).parameters, p => p === parameterDeclaration || p === referencedSymbol.valueDeclaration ? p : undefined);
|
||||
|
||||
if (enclosingOrReferencedParameter === referencedSymbol.valueDeclaration) {
|
||||
// legal case - parameter initializer references some parameter strictly on left of current parameter declaration
|
||||
@@ -6389,7 +6413,7 @@ module ts {
|
||||
// fall through to error reporting
|
||||
}
|
||||
|
||||
error(n, Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, identifierToString(parameterDeclaration.name), identifierToString(<Identifier>n));
|
||||
error(n, Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, declarationNameToString(parameterDeclaration.name), declarationNameToString(<Identifier>n));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -6654,12 +6678,11 @@ module ts {
|
||||
|
||||
// TypeScript 1.0 spec (April 2014): 3.7.2.2
|
||||
// Specialized signatures are not permitted in conjunction with a function body
|
||||
if ((<FunctionDeclaration>signatureDeclarationNode).body) {
|
||||
if ((<FunctionLikeDeclaration>signatureDeclarationNode).body) {
|
||||
error(signatureDeclarationNode, Diagnostics.A_signature_with_an_implementation_cannot_use_a_string_literal_type);
|
||||
return;
|
||||
}
|
||||
|
||||
var symbol = getSymbolOfNode(signatureDeclarationNode);
|
||||
// TypeScript 1.0 spec (April 2014): 3.7.2.4
|
||||
// Every specialized call or construct signature in an object type must be assignable
|
||||
// to at least one non-specialized call or construct signature in the same object type
|
||||
@@ -6705,7 +6728,7 @@ module ts {
|
||||
return;
|
||||
}
|
||||
|
||||
function checkFlagAgreementBetweenOverloads(overloads: Declaration[], implementation: FunctionDeclaration, flagsToCheck: NodeFlags, someOverloadFlags: NodeFlags, allOverloadFlags: NodeFlags): void {
|
||||
function checkFlagAgreementBetweenOverloads(overloads: Declaration[], implementation: FunctionLikeDeclaration, flagsToCheck: NodeFlags, someOverloadFlags: NodeFlags, allOverloadFlags: NodeFlags): void {
|
||||
// Error if some overloads have a flag that is not shared by all overloads. To find the
|
||||
// deviations, we XOR someOverloadFlags with allOverloadFlags
|
||||
var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags;
|
||||
@@ -6741,14 +6764,14 @@ module ts {
|
||||
var someNodeFlags: NodeFlags = 0;
|
||||
var allNodeFlags = flagsToCheck;
|
||||
var hasOverloads = false;
|
||||
var bodyDeclaration: FunctionDeclaration;
|
||||
var lastSeenNonAmbientDeclaration: FunctionDeclaration;
|
||||
var previousDeclaration: FunctionDeclaration;
|
||||
var bodyDeclaration: FunctionLikeDeclaration;
|
||||
var lastSeenNonAmbientDeclaration: FunctionLikeDeclaration;
|
||||
var previousDeclaration: FunctionLikeDeclaration;
|
||||
|
||||
var declarations = symbol.declarations;
|
||||
var isConstructor = (symbol.flags & SymbolFlags.Constructor) !== 0;
|
||||
|
||||
function reportImplementationExpectedError(node: FunctionDeclaration): void {
|
||||
function reportImplementationExpectedError(node: FunctionLikeDeclaration): void {
|
||||
if (node.name && node.name.kind === SyntaxKind.Missing) {
|
||||
return;
|
||||
}
|
||||
@@ -6764,8 +6787,9 @@ module ts {
|
||||
});
|
||||
if (subsequentNode) {
|
||||
if (subsequentNode.kind === node.kind) {
|
||||
var errorNode: Node = (<FunctionDeclaration>subsequentNode).name || subsequentNode;
|
||||
if (node.name && (<FunctionDeclaration>subsequentNode).name && node.name.text === (<FunctionDeclaration>subsequentNode).name.text) {
|
||||
var errorNode: Node = (<FunctionLikeDeclaration>subsequentNode).name || subsequentNode;
|
||||
// TODO(jfreeman): These are methods, so handle computed name case
|
||||
if (node.name && (<FunctionLikeDeclaration>subsequentNode).name && (<Identifier>node.name).text === (<Identifier>(<FunctionLikeDeclaration>subsequentNode).name).text) {
|
||||
// the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members
|
||||
Debug.assert(node.kind === SyntaxKind.Method);
|
||||
Debug.assert((node.flags & NodeFlags.Static) !== (subsequentNode.flags & NodeFlags.Static));
|
||||
@@ -6773,8 +6797,8 @@ module ts {
|
||||
error(errorNode, diagnostic);
|
||||
return;
|
||||
}
|
||||
else if ((<FunctionDeclaration>subsequentNode).body) {
|
||||
error(errorNode, Diagnostics.Function_implementation_name_must_be_0, identifierToString(node.name));
|
||||
else if ((<FunctionLikeDeclaration>subsequentNode).body) {
|
||||
error(errorNode, Diagnostics.Function_implementation_name_must_be_0, declarationNameToString(node.name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -6794,7 +6818,7 @@ module ts {
|
||||
var duplicateFunctionDeclaration = false;
|
||||
var multipleConstructorImplementation = false;
|
||||
for (var i = 0; i < declarations.length; i++) {
|
||||
var node = <FunctionDeclaration>declarations[i];
|
||||
var node = <FunctionLikeDeclaration>declarations[i];
|
||||
var inAmbientContext = isInAmbientContext(node);
|
||||
var inAmbientContextOrInterface = node.parent.kind === SyntaxKind.InterfaceDeclaration || node.parent.kind === SyntaxKind.TypeLiteral || inAmbientContext;
|
||||
if (inAmbientContextOrInterface) {
|
||||
@@ -6938,7 +6962,7 @@ module ts {
|
||||
// declaration spaces for exported and non-exported declarations intersect
|
||||
forEach(symbol.declarations, d => {
|
||||
if (getDeclarationSpaces(d) & commonDeclarationSpace) {
|
||||
error(d.name, Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, identifierToString(d.name));
|
||||
error(d.name, Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, declarationNameToString(d.name));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -6965,7 +6989,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkFunctionDeclaration(node: FunctionDeclaration): void {
|
||||
function checkFunctionDeclaration(node: FunctionLikeDeclaration): void {
|
||||
checkSignatureDeclaration(node);
|
||||
|
||||
var symbol = getSymbolOfNode(node);
|
||||
@@ -7001,7 +7025,7 @@ module ts {
|
||||
var typeName = typeToString(anyType);
|
||||
|
||||
if (node.name) {
|
||||
error(node, Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, identifierToString(node.name), typeName);
|
||||
error(node, Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type, declarationNameToString(node.name), typeName);
|
||||
}
|
||||
else {
|
||||
error(node, Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeName);
|
||||
@@ -7016,7 +7040,7 @@ module ts {
|
||||
|
||||
function checkCollisionWithArgumentsInGeneratedCode(node: SignatureDeclaration) {
|
||||
// no rest parameters \ declaration context \ overload - no codegen impact
|
||||
if (!hasRestParameters(node) || isInAmbientContext(node) || !(<FunctionDeclaration>node).body) {
|
||||
if (!hasRestParameters(node) || isInAmbientContext(node) || !(<FunctionLikeDeclaration>node).body) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7037,7 +7061,7 @@ module ts {
|
||||
// - function has implementation (not a signature)
|
||||
// - function has rest parameters
|
||||
// - context is not ambient (otherwise no codegen impact)
|
||||
if ((<FunctionDeclaration>node.parent).body && hasRestParameters(<FunctionDeclaration>node.parent) && !isInAmbientContext(node)) {
|
||||
if ((<FunctionLikeDeclaration>node.parent).body && hasRestParameters(<FunctionLikeDeclaration>node.parent) && !isInAmbientContext(node)) {
|
||||
error(node, Diagnostics.Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter);
|
||||
}
|
||||
return;
|
||||
@@ -7095,7 +7119,7 @@ module ts {
|
||||
case SyntaxKind.Method:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.Constructor:
|
||||
if (hasRestParameters(<FunctionDeclaration>current)) {
|
||||
if (hasRestParameters(<FunctionLikeDeclaration>current)) {
|
||||
error(node, Diagnostics.Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter);
|
||||
return;
|
||||
}
|
||||
@@ -7105,8 +7129,9 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function needCollisionCheckForIdentifier(node: Node, identifier: Identifier, name: string): boolean {
|
||||
if (!(identifier && identifier.text === name)) {
|
||||
// TODO(jfreeman): Decide what to do for computed properties
|
||||
function needCollisionCheckForIdentifier(node: Node, identifier: DeclarationName, name: string): boolean {
|
||||
if (!(identifier && (<Identifier>identifier).text === name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -7123,15 +7148,16 @@ module ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (node.kind === SyntaxKind.Parameter && !(<FunctionDeclaration>node.parent).body) {
|
||||
if (node.kind === SyntaxKind.Parameter && !(<FunctionLikeDeclaration>node.parent).body) {
|
||||
// just an overload - no codegen impact
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function checkCollisionWithCapturedThisVariable(node: Node, name: Identifier): void {
|
||||
|
||||
// TODO(jfreeman): Decide what to do for computed properties
|
||||
function checkCollisionWithCapturedThisVariable(node: Node, name: DeclarationName): void {
|
||||
if (!needCollisionCheckForIdentifier(node, name, "_this")) {
|
||||
return;
|
||||
}
|
||||
@@ -7156,7 +7182,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkCollisionWithCapturedSuperVariable(node: Node, name: Identifier) {
|
||||
function checkCollisionWithCapturedSuperVariable(node: Node, name: DeclarationName) {
|
||||
if (!needCollisionCheckForIdentifier(node, name, "_super")) {
|
||||
return;
|
||||
}
|
||||
@@ -7179,7 +7205,8 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkCollisionWithRequireExportsInGeneratedCode(node: Node, name: Identifier) {
|
||||
// TODO(jfreeman): Decide what to do for computed properties
|
||||
function checkCollisionWithRequireExportsInGeneratedCode(node: Node, name: DeclarationName) {
|
||||
if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
|
||||
return;
|
||||
}
|
||||
@@ -7193,7 +7220,8 @@ module ts {
|
||||
var parent = node.kind === SyntaxKind.VariableDeclaration ? node.parent.parent : node.parent;
|
||||
if (parent.kind === SyntaxKind.SourceFile && isExternalModule(<SourceFile>parent)) {
|
||||
// If the declaration happens to be in external module, report error that require and exports are reserved keywords
|
||||
error(name, Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, name.text, name.text);
|
||||
error(name, Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module,
|
||||
declarationNameToString(name), declarationNameToString(name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7229,7 +7257,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkVariableDeclaration(node: VariableDeclaration) {
|
||||
function checkVariableDeclaration(node: VariableDeclaration | PropertyDeclaration) {
|
||||
checkSourceElement(node.type);
|
||||
checkExportsOnMergedDeclarations(node);
|
||||
|
||||
@@ -7243,7 +7271,7 @@ module ts {
|
||||
type = typeOfValueDeclaration;
|
||||
}
|
||||
else {
|
||||
type = getTypeOfVariableDeclaration(node);
|
||||
type = getTypeOfVariableOrPropertyDeclaration(node);
|
||||
}
|
||||
|
||||
|
||||
@@ -7252,7 +7280,8 @@ module ts {
|
||||
// Use default messages
|
||||
checkTypeAssignableTo(checkAndMarkExpression(node.initializer), type, node, /*headMessage*/ undefined);
|
||||
}
|
||||
checkCollisionWithConstDeclarations(node);
|
||||
//TODO(jfreeman): Check that it is not a computed property
|
||||
checkCollisionWithConstDeclarations(<VariableDeclaration>node);
|
||||
}
|
||||
|
||||
checkCollisionWithCapturedSuperVariable(node, node.name);
|
||||
@@ -7263,7 +7292,7 @@ module ts {
|
||||
// Multiple declarations for the same variable name in the same declaration space are permitted,
|
||||
// provided that each declaration associates the same type with the variable.
|
||||
if (typeOfValueDeclaration !== unknownType && type !== unknownType && !isTypeIdenticalTo(typeOfValueDeclaration, type)) {
|
||||
error(node.name, Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, identifierToString(node.name), typeToString(typeOfValueDeclaration), typeToString(type));
|
||||
error(node.name, Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, declarationNameToString(node.name), typeToString(typeOfValueDeclaration), typeToString(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7481,16 +7510,17 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkTypeNameIsReserved(name: Identifier, message: DiagnosticMessage): void {
|
||||
// TODO(jfreeman): Decide what to do for computed properties
|
||||
function checkTypeNameIsReserved(name: DeclarationName, message: DiagnosticMessage): void {
|
||||
// TS 1.0 spec (April 2014): 3.6.1
|
||||
// The predefined type keywords are reserved and cannot be used as names of user defined types.
|
||||
switch (name.text) {
|
||||
switch ((<Identifier>name).text) {
|
||||
case "any":
|
||||
case "number":
|
||||
case "boolean":
|
||||
case "string":
|
||||
case "void":
|
||||
error(name, message, name.text);
|
||||
error(name, message, (<Identifier>name).text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7504,7 +7534,7 @@ module ts {
|
||||
if (fullTypeCheck) {
|
||||
for (var j = 0; j < i; j++) {
|
||||
if (typeParameterDeclarations[j].symbol === node.symbol) {
|
||||
error(node.name, Diagnostics.Duplicate_identifier_0, identifierToString(node.name));
|
||||
error(node.name, Diagnostics.Duplicate_identifier_0, declarationNameToString(node.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7762,7 +7792,8 @@ module ts {
|
||||
var enumIsConst = isConstEnumDeclaration(node);
|
||||
|
||||
forEach(node.members, member => {
|
||||
if(isNumericName(member.name.text)) {
|
||||
// TODO(jfreeman): Check that it is not a computed name
|
||||
if(isNumericName((<Identifier>member.name).text)) {
|
||||
error(member.name, Diagnostics.An_enum_member_cannot_have_a_numeric_name);
|
||||
}
|
||||
var initializer = member.initializer;
|
||||
@@ -7967,7 +7998,7 @@ module ts {
|
||||
var declarations = symbol.declarations;
|
||||
for (var i = 0; i < declarations.length; i++) {
|
||||
var declaration = declarations[i];
|
||||
if ((declaration.kind === SyntaxKind.ClassDeclaration || (declaration.kind === SyntaxKind.FunctionDeclaration && (<FunctionDeclaration>declaration).body)) && !isInAmbientContext(declaration)) {
|
||||
if ((declaration.kind === SyntaxKind.ClassDeclaration || (declaration.kind === SyntaxKind.FunctionDeclaration && (<FunctionLikeDeclaration>declaration).body)) && !isInAmbientContext(declaration)) {
|
||||
return declaration;
|
||||
}
|
||||
}
|
||||
@@ -8028,7 +8059,7 @@ module ts {
|
||||
checkExpression(node.entityName);
|
||||
}
|
||||
else {
|
||||
error(moduleName, Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, identifierToString(moduleName));
|
||||
error(moduleName, Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, declarationNameToString(moduleName));
|
||||
}
|
||||
}
|
||||
if (target.flags & SymbolFlags.Type) {
|
||||
@@ -8114,7 +8145,7 @@ module ts {
|
||||
case SyntaxKind.ParenType:
|
||||
return checkSourceElement((<ParenTypeNode>node).type);
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
return checkFunctionDeclaration(<FunctionDeclaration>node);
|
||||
return checkFunctionDeclaration(<FunctionLikeDeclaration>node);
|
||||
case SyntaxKind.Block:
|
||||
return checkBlock(<Block>node);
|
||||
case SyntaxKind.FunctionBlock:
|
||||
@@ -8181,7 +8212,7 @@ module ts {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
forEach((<FunctionDeclaration>node).parameters, checkFunctionExpressionBodies);
|
||||
forEach((<FunctionLikeDeclaration>node).parameters, checkFunctionExpressionBodies);
|
||||
checkFunctionExpressionBody(<FunctionExpression>node);
|
||||
break;
|
||||
case SyntaxKind.Method:
|
||||
@@ -8189,7 +8220,7 @@ module ts {
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
forEach((<FunctionDeclaration>node).parameters, checkFunctionExpressionBodies);
|
||||
forEach((<FunctionLikeDeclaration>node).parameters, checkFunctionExpressionBodies);
|
||||
break;
|
||||
case SyntaxKind.WithStatement:
|
||||
checkFunctionExpressionBodies((<WithStatement>node).expression);
|
||||
@@ -8471,7 +8502,7 @@ module ts {
|
||||
case SyntaxKind.Method:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return node === (<FunctionDeclaration>parent).type;
|
||||
return node === (<FunctionLikeDeclaration>parent).type;
|
||||
case SyntaxKind.CallSignature:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.IndexSignature:
|
||||
@@ -8727,7 +8758,7 @@ module ts {
|
||||
return true;
|
||||
}
|
||||
|
||||
function getLocalNameOfContainer(container: Declaration): string {
|
||||
function getLocalNameOfContainer(container: ModuleDeclaration | EnumDeclaration): string {
|
||||
var links = getNodeLinks(container);
|
||||
if (!links.localModuleName) {
|
||||
var prefix = "";
|
||||
@@ -8744,7 +8775,7 @@ module ts {
|
||||
var node = location;
|
||||
while (node) {
|
||||
if ((node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.EnumDeclaration) && getSymbolOfNode(node) === symbol) {
|
||||
return getLocalNameOfContainer(node);
|
||||
return getLocalNameOfContainer(<ModuleDeclaration | EnumDeclaration>node);
|
||||
}
|
||||
node = node.parent;
|
||||
}
|
||||
@@ -8779,7 +8810,6 @@ module ts {
|
||||
// parent is not source file or it is not reference to internal module
|
||||
return false;
|
||||
}
|
||||
var symbol = getSymbolOfNode(node);
|
||||
return isImportResolvedToValue(getSymbolOfNode(node));
|
||||
}
|
||||
|
||||
@@ -8815,7 +8845,7 @@ module ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
function isImplementationOfOverload(node: FunctionDeclaration) {
|
||||
function isImplementationOfOverload(node: FunctionLikeDeclaration) {
|
||||
if (node.body) {
|
||||
var symbol = getSymbolOfNode(node);
|
||||
var signaturesOfSymbol = getSignaturesOfSymbol(symbol);
|
||||
|
||||
+30
-21
@@ -86,8 +86,9 @@ module ts {
|
||||
var getAccessor: AccessorDeclaration;
|
||||
var setAccessor: AccessorDeclaration;
|
||||
forEach(node.members, (member: Declaration) => {
|
||||
// TODO(jfreeman): Handle computed names for accessor matching
|
||||
if ((member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) &&
|
||||
member.name.text === accessor.name.text &&
|
||||
(<Identifier>member.name).text === (<Identifier>accessor.name).text &&
|
||||
(member.flags & NodeFlags.Static) === (accessor.flags & NodeFlags.Static)) {
|
||||
if (!firstAccessor) {
|
||||
firstAccessor = <AccessorDeclaration>member;
|
||||
@@ -577,7 +578,8 @@ module ts {
|
||||
node.kind === SyntaxKind.EnumDeclaration) {
|
||||
// Declaration and has associated name use it
|
||||
if ((<Declaration>node).name) {
|
||||
scopeName = (<Declaration>node).name.text;
|
||||
// TODO(jfreeman): Ask shkamat about what this name should be for source maps
|
||||
scopeName = (<Identifier>(<Declaration>node).name).text;
|
||||
}
|
||||
recordScopeNameStart(scopeName);
|
||||
}
|
||||
@@ -907,15 +909,15 @@ module ts {
|
||||
|
||||
// This function specifically handles numeric/string literals for enum and accessor 'identifiers'.
|
||||
// In a sense, it does not actually emit identifiers as much as it declares a name for a specific property.
|
||||
function emitQuotedIdentifier(node: Identifier) {
|
||||
function emitExpressionForPropertyName(node: DeclarationName) {
|
||||
if (node.kind === SyntaxKind.StringLiteral) {
|
||||
emitLiteral(node);
|
||||
emitLiteral(<LiteralExpression>node);
|
||||
}
|
||||
else {
|
||||
write("\"");
|
||||
|
||||
if (node.kind === SyntaxKind.NumericLiteral) {
|
||||
write(node.text);
|
||||
write((<LiteralExpression>node).text);
|
||||
}
|
||||
else {
|
||||
write(getSourceTextOfLocalNode(node));
|
||||
@@ -1034,7 +1036,7 @@ module ts {
|
||||
function tryEmitConstantValue(node: PropertyAccess | IndexedAccess): boolean {
|
||||
var constantValue = resolver.getConstantValue(node);
|
||||
if (constantValue !== undefined) {
|
||||
var propertyName = node.kind === SyntaxKind.PropertyAccess ? identifierToString((<PropertyAccess>node).right) : getTextOfNode((<IndexedAccess>node).index);
|
||||
var propertyName = node.kind === SyntaxKind.PropertyAccess ? declarationNameToString((<PropertyAccess>node).right) : getTextOfNode((<IndexedAccess>node).index);
|
||||
write(constantValue.toString() + " /* " + propertyName + " */");
|
||||
return true;
|
||||
}
|
||||
@@ -1464,7 +1466,7 @@ module ts {
|
||||
emitTrailingComments(node);
|
||||
}
|
||||
|
||||
function emitDefaultValueAssignments(node: FunctionDeclaration) {
|
||||
function emitDefaultValueAssignments(node: FunctionLikeDeclaration) {
|
||||
forEach(node.parameters, param => {
|
||||
if (param.initializer) {
|
||||
writeLine();
|
||||
@@ -1484,7 +1486,7 @@ module ts {
|
||||
});
|
||||
}
|
||||
|
||||
function emitRestParameter(node: FunctionDeclaration) {
|
||||
function emitRestParameter(node: FunctionLikeDeclaration) {
|
||||
if (hasRestParameters(node)) {
|
||||
var restIndex = node.parameters.length - 1;
|
||||
var restParam = node.parameters[restIndex];
|
||||
@@ -1530,7 +1532,7 @@ module ts {
|
||||
emitTrailingComments(node);
|
||||
}
|
||||
|
||||
function emitFunctionDeclaration(node: FunctionDeclaration) {
|
||||
function emitFunctionDeclaration(node: FunctionLikeDeclaration) {
|
||||
if (!node.body) {
|
||||
return emitPinnedOrTripleSlashComments(node);
|
||||
}
|
||||
@@ -1558,7 +1560,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitSignatureParameters(node: FunctionDeclaration) {
|
||||
function emitSignatureParameters(node: FunctionLikeDeclaration) {
|
||||
increaseIndent();
|
||||
write("(");
|
||||
if (node) {
|
||||
@@ -1568,7 +1570,7 @@ module ts {
|
||||
decreaseIndent();
|
||||
}
|
||||
|
||||
function emitSignatureAndBody(node: FunctionDeclaration) {
|
||||
function emitSignatureAndBody(node: FunctionLikeDeclaration) {
|
||||
emitSignatureParameters(node);
|
||||
write(" {");
|
||||
scopeEmitStart(node);
|
||||
@@ -1665,7 +1667,8 @@ module ts {
|
||||
});
|
||||
}
|
||||
|
||||
function emitMemberAccess(memberName: Identifier) {
|
||||
// TODO(jfreeman): Account for computed property name
|
||||
function emitMemberAccess(memberName: DeclarationName) {
|
||||
if (memberName.kind === SyntaxKind.StringLiteral || memberName.kind === SyntaxKind.NumericLiteral) {
|
||||
write("[");
|
||||
emitNode(memberName);
|
||||
@@ -1738,7 +1741,7 @@ module ts {
|
||||
write(".prototype");
|
||||
}
|
||||
write(", ");
|
||||
emitQuotedIdentifier((<AccessorDeclaration>member).name);
|
||||
emitExpressionForPropertyName((<AccessorDeclaration>member).name);
|
||||
emitEnd((<AccessorDeclaration>member).name);
|
||||
write(", {");
|
||||
increaseIndent();
|
||||
@@ -1951,7 +1954,7 @@ module ts {
|
||||
write("[");
|
||||
write(resolver.getLocalNameOfContainer(node));
|
||||
write("[");
|
||||
emitQuotedIdentifier(member.name);
|
||||
emitExpressionForPropertyName(member.name);
|
||||
write("] = ");
|
||||
if (member.initializer && !isConstEnum) {
|
||||
emit(member.initializer);
|
||||
@@ -1960,7 +1963,7 @@ module ts {
|
||||
write(resolver.getEnumMemberValue(member).toString());
|
||||
}
|
||||
write("] = ");
|
||||
emitQuotedIdentifier(member.name);
|
||||
emitExpressionForPropertyName(member.name);
|
||||
emitEnd(member);
|
||||
write(";");
|
||||
emitTrailingComments(member);
|
||||
@@ -2072,7 +2075,10 @@ module ts {
|
||||
function getExternalImportDeclarations(node: SourceFile): ImportDeclaration[] {
|
||||
var result: ImportDeclaration[] = [];
|
||||
forEach(node.statements, stat => {
|
||||
if (stat.kind === SyntaxKind.ImportDeclaration && (<ImportDeclaration>stat).externalModuleName && resolver.isReferencedImportDeclaration(stat)) {
|
||||
if (stat.kind === SyntaxKind.ImportDeclaration
|
||||
&& (<ImportDeclaration>stat).externalModuleName
|
||||
&& resolver.isReferencedImportDeclaration(<ImportDeclaration>stat)) {
|
||||
|
||||
result.push(<ImportDeclaration>stat);
|
||||
}
|
||||
});
|
||||
@@ -2261,7 +2267,7 @@ module ts {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return emitFunctionDeclaration(<FunctionDeclaration>node);
|
||||
return emitFunctionDeclaration(<FunctionLikeDeclaration>node);
|
||||
case SyntaxKind.PrefixOperator:
|
||||
case SyntaxKind.PostfixOperator:
|
||||
return emitUnaryExpression(<UnaryExpression>node);
|
||||
@@ -2504,7 +2510,7 @@ module ts {
|
||||
var getSymbolVisibilityDiagnosticMessage: (symbolAccesibilityResult: SymbolAccessiblityResult) => {
|
||||
errorNode: Node;
|
||||
diagnosticMessage: DiagnosticMessage;
|
||||
typeName?: Identifier
|
||||
typeName?: DeclarationName
|
||||
}
|
||||
|
||||
function createTextWriterWithSymbolWriter(): EmitTextWriterWithSymbolWriter {
|
||||
@@ -2966,11 +2972,12 @@ module ts {
|
||||
function emitPropertyDeclaration(node: PropertyDeclaration) {
|
||||
emitJsDocComments(node);
|
||||
emitDeclarationFlags(node);
|
||||
emitVariableDeclaration(node);
|
||||
emitVariableDeclaration(<VariableDeclaration>node);
|
||||
write(";");
|
||||
writeLine();
|
||||
}
|
||||
|
||||
// TODO(jfreeman): Factor out common part of property definition, but treat name differently
|
||||
function emitVariableDeclaration(node: VariableDeclaration) {
|
||||
// If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted
|
||||
// so there is no check needed to see if declaration is visible
|
||||
@@ -2998,6 +3005,7 @@ module ts {
|
||||
}
|
||||
// This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit
|
||||
else if (node.kind === SyntaxKind.Property) {
|
||||
// TODO(jfreeman): Deal with computed properties in error reporting.
|
||||
if (node.flags & NodeFlags.Static) {
|
||||
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
|
||||
symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ?
|
||||
@@ -3081,6 +3089,7 @@ module ts {
|
||||
return {
|
||||
diagnosticMessage: diagnosticMessage,
|
||||
errorNode: <Node>node.parameters[0],
|
||||
// TODO(jfreeman): Investigate why we are passing node.name instead of node.parameters[0].name
|
||||
typeName: node.name
|
||||
};
|
||||
}
|
||||
@@ -3108,7 +3117,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
function emitFunctionDeclaration(node: FunctionDeclaration) {
|
||||
function emitFunctionDeclaration(node: FunctionLikeDeclaration) {
|
||||
// If we are emitting Method/Constructor it isn't moduleElement and hence already determined to be emitting
|
||||
// so no need to verify if the declaration is visible
|
||||
if ((node.kind !== SyntaxKind.FunctionDeclaration || resolver.isDeclarationVisible(node)) &&
|
||||
@@ -3327,7 +3336,7 @@ module ts {
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.Method:
|
||||
return emitFunctionDeclaration(<FunctionDeclaration>node);
|
||||
return emitFunctionDeclaration(<FunctionLikeDeclaration>node);
|
||||
case SyntaxKind.ConstructSignature:
|
||||
return emitConstructSignatureDeclaration(<SignatureDeclaration>node);
|
||||
case SyntaxKind.CallSignature:
|
||||
|
||||
+81
-45
@@ -62,9 +62,10 @@ module ts {
|
||||
return identifier.length >= 3 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ && identifier.charCodeAt(2) === CharacterCodes._ ? identifier.substr(1) : identifier;
|
||||
}
|
||||
|
||||
// TODO(jfreeman): Implement declarationNameToString for computed properties
|
||||
// Return display name of an identifier
|
||||
export function identifierToString(identifier: Identifier) {
|
||||
return identifier.kind === SyntaxKind.Missing ? "(Missing)" : getTextOfNode(identifier);
|
||||
export function declarationNameToString(name: DeclarationName) {
|
||||
return name.kind === SyntaxKind.Missing ? "(Missing)" : getTextOfNode(name);
|
||||
}
|
||||
|
||||
export function createDiagnosticForNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): Diagnostic {
|
||||
@@ -213,11 +214,11 @@ module ts {
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return child((<FunctionDeclaration>node).name) ||
|
||||
children((<FunctionDeclaration>node).typeParameters) ||
|
||||
children((<FunctionDeclaration>node).parameters) ||
|
||||
child((<FunctionDeclaration>node).type) ||
|
||||
child((<FunctionDeclaration>node).body);
|
||||
return child((<FunctionLikeDeclaration>node).name) ||
|
||||
children((<FunctionLikeDeclaration>node).typeParameters) ||
|
||||
children((<FunctionLikeDeclaration>node).parameters) ||
|
||||
child((<FunctionLikeDeclaration>node).type) ||
|
||||
child((<FunctionLikeDeclaration>node).body);
|
||||
case SyntaxKind.TypeReference:
|
||||
return child((<TypeReferenceNode>node).typeName) ||
|
||||
children((<TypeReferenceNode>node).typeArguments);
|
||||
@@ -490,6 +491,7 @@ module ts {
|
||||
case SyntaxKind.BinaryExpression:
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
case SyntaxKind.TemplateExpression:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
case SyntaxKind.OmittedExpression:
|
||||
return true;
|
||||
case SyntaxKind.QualifiedName:
|
||||
@@ -502,7 +504,6 @@ module ts {
|
||||
// fall through
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
var parent = node.parent;
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
@@ -531,6 +532,8 @@ module ts {
|
||||
(<ForInStatement>parent).expression === node;
|
||||
case SyntaxKind.TypeAssertion:
|
||||
return node === (<TypeAssertion>parent).operand;
|
||||
case SyntaxKind.TemplateSpan:
|
||||
return node === (<TemplateSpan>parent).expression;
|
||||
default:
|
||||
if (isExpression(parent)) {
|
||||
return true;
|
||||
@@ -744,6 +747,47 @@ module ts {
|
||||
nodeIsNestedInLabel(label: Identifier, requireIterationStatement: boolean, stopAtFunctionBoundary: boolean): ControlBlockContext;
|
||||
}
|
||||
|
||||
interface ReferencePathMatchResult {
|
||||
fileReference?: FileReference
|
||||
diagnostic?: DiagnosticMessage
|
||||
isNoDefaultLib?: boolean
|
||||
}
|
||||
|
||||
export function getFileReferenceFromReferencePath(comment: string, commentRange: CommentRange): ReferencePathMatchResult {
|
||||
var simpleReferenceRegEx = /^\/\/\/\s*<reference\s+/gim;
|
||||
var isNoDefaultLibRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/gim;
|
||||
if (simpleReferenceRegEx.exec(comment)) {
|
||||
if (isNoDefaultLibRegEx.exec(comment)) {
|
||||
return {
|
||||
isNoDefaultLib: true
|
||||
}
|
||||
}
|
||||
else {
|
||||
var matchResult = fullTripleSlashReferencePathRegEx.exec(comment);
|
||||
if (matchResult) {
|
||||
var start = commentRange.pos;
|
||||
var end = commentRange.end;
|
||||
var fileRef = {
|
||||
pos: start,
|
||||
end: end,
|
||||
filename: matchResult[3]
|
||||
};
|
||||
return {
|
||||
fileReference: fileRef,
|
||||
isNoDefaultLib: false
|
||||
};
|
||||
}
|
||||
else {
|
||||
return {
|
||||
diagnostic: Diagnostics.Invalid_reference_directive_syntax,
|
||||
isNoDefaultLib: false
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function isKeyword(token: SyntaxKind): boolean {
|
||||
return SyntaxKind.FirstKeyword <= token && token <= SyntaxKind.LastKeyword;
|
||||
}
|
||||
@@ -924,7 +968,7 @@ module ts {
|
||||
}
|
||||
|
||||
function reportInvalidUseInStrictMode(node: Identifier): void {
|
||||
// identifierToString cannot be used here since it uses a backreference to 'parent' that is not yet set
|
||||
// declarationNameToString cannot be used here since it uses a backreference to 'parent' that is not yet set
|
||||
var name = sourceText.substring(skipTrivia(sourceText, node.pos), node.end);
|
||||
grammarErrorOnNode(node, Diagnostics.Invalid_use_of_0_in_strict_mode, name);
|
||||
}
|
||||
@@ -1631,7 +1675,7 @@ module ts {
|
||||
// Identifier in a PropertySetParameterList of a PropertyAssignment that is contained in strict code
|
||||
// or if its FunctionBody is strict code(11.1.5).
|
||||
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
|
||||
// strict mode FunctionDeclaration or FunctionExpression(13.1)
|
||||
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
|
||||
if (isInStrictMode && isEvalOrArgumentsIdentifier(parameter.name)) {
|
||||
reportInvalidUseInStrictMode(parameter.name);
|
||||
return;
|
||||
@@ -2712,9 +2756,13 @@ module ts {
|
||||
var SetAccesor = 4;
|
||||
var GetOrSetAccessor = GetAccessor | SetAccesor;
|
||||
forEach(node.properties, (p: Declaration) => {
|
||||
// TODO(jfreeman): continue if we have a computed property
|
||||
if (p.kind === SyntaxKind.OmittedExpression) {
|
||||
return;
|
||||
}
|
||||
|
||||
var name = <Identifier>p.name;
|
||||
|
||||
// ECMA-262 11.1.5 Object Initialiser
|
||||
// If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
|
||||
// a.This production is contained in strict code and IsDataDescriptor(previous) is true and
|
||||
@@ -2737,26 +2785,26 @@ module ts {
|
||||
Debug.fail("Unexpected syntax kind:" + p.kind);
|
||||
}
|
||||
|
||||
if (!hasProperty(seen, p.name.text)) {
|
||||
seen[p.name.text] = currentKind;
|
||||
if (!hasProperty(seen, name.text)) {
|
||||
seen[name.text] = currentKind;
|
||||
}
|
||||
else {
|
||||
var existingKind = seen[p.name.text];
|
||||
var existingKind = seen[name.text];
|
||||
if (currentKind === Property && existingKind === Property) {
|
||||
if (isInStrictMode) {
|
||||
grammarErrorOnNode(p.name, Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode);
|
||||
grammarErrorOnNode(name, Diagnostics.An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode);
|
||||
}
|
||||
}
|
||||
else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) {
|
||||
if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) {
|
||||
seen[p.name.text] = currentKind | existingKind;
|
||||
seen[name.text] = currentKind | existingKind;
|
||||
}
|
||||
else {
|
||||
grammarErrorOnNode(p.name, Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
|
||||
grammarErrorOnNode(name, Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
grammarErrorOnNode(p.name, Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
|
||||
grammarErrorOnNode(name, Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -2771,7 +2819,7 @@ module ts {
|
||||
var body = parseBody(/* ignoreMissingOpenBrace */ false);
|
||||
if (name && isInStrictMode && isEvalOrArgumentsIdentifier(name)) {
|
||||
// It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the
|
||||
// Identifier of a FunctionDeclaration or FunctionExpression or as a formal parameter name(13.1)
|
||||
// Identifier of a FunctionLikeDeclaration or FunctionExpression or as a formal parameter name(13.1)
|
||||
reportInvalidUseInStrictMode(name);
|
||||
}
|
||||
return makeFunctionExpression(SyntaxKind.FunctionExpression, pos, name, sig, body);
|
||||
@@ -3437,8 +3485,8 @@ module ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
function parseFunctionDeclaration(pos?: number, flags?: NodeFlags): FunctionDeclaration {
|
||||
var node = <FunctionDeclaration>createNode(SyntaxKind.FunctionDeclaration, pos);
|
||||
function parseFunctionDeclaration(pos?: number, flags?: NodeFlags): FunctionLikeDeclaration {
|
||||
var node = <FunctionLikeDeclaration>createNode(SyntaxKind.FunctionDeclaration, pos);
|
||||
if (flags) node.flags = flags;
|
||||
parseExpected(SyntaxKind.FunctionKeyword);
|
||||
node.name = parseIdentifier();
|
||||
@@ -3447,10 +3495,10 @@ module ts {
|
||||
node.parameters = sig.parameters;
|
||||
node.type = sig.type;
|
||||
node.body = parseAndCheckFunctionBody(/*isConstructor*/ false);
|
||||
if (isInStrictMode && isEvalOrArgumentsIdentifier(node.name)) {
|
||||
if (isInStrictMode && isEvalOrArgumentsIdentifier(node.name) && node.name.kind === SyntaxKind.Identifier) {
|
||||
// It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the
|
||||
// Identifier of a FunctionDeclaration or FunctionExpression or as a formal parameter name(13.1)
|
||||
reportInvalidUseInStrictMode(node.name);
|
||||
// Identifier of a FunctionLikeDeclaration or FunctionExpression or as a formal parameter name(13.1)
|
||||
reportInvalidUseInStrictMode(<Identifier>node.name);
|
||||
}
|
||||
return finishNode(node);
|
||||
}
|
||||
@@ -3567,7 +3615,7 @@ module ts {
|
||||
// A common error is to try to declare an accessor in an ambient class.
|
||||
if (inAmbientContext && canParseSemicolon()) {
|
||||
parseSemicolon();
|
||||
node.body = createMissingNode();
|
||||
node.body = <Block>createMissingNode();
|
||||
}
|
||||
else {
|
||||
node.body = parseBody(/* ignoreMissingOpenBrace */ false);
|
||||
@@ -4163,28 +4211,16 @@ module ts {
|
||||
for (var i = 0; i < commentRanges.length; i++) {
|
||||
var range = commentRanges[i];
|
||||
var comment = sourceText.substring(range.pos, range.end);
|
||||
var simpleReferenceRegEx = /^\/\/\/\s*<reference\s+/gim;
|
||||
if (simpleReferenceRegEx.exec(comment)) {
|
||||
var isNoDefaultLibRegEx = /^(\/\/\/\s*<reference\s+no-default-lib=)('|")(.+?)\2\s*\/>/gim;
|
||||
if (isNoDefaultLibRegEx.exec(comment)) {
|
||||
file.hasNoDefaultLib = true;
|
||||
var referencePathMatchResult = getFileReferenceFromReferencePath(comment, range);
|
||||
if (referencePathMatchResult) {
|
||||
var fileReference = referencePathMatchResult.fileReference;
|
||||
file.hasNoDefaultLib = referencePathMatchResult.isNoDefaultLib;
|
||||
var diagnostic = referencePathMatchResult.diagnostic;
|
||||
if (fileReference) {
|
||||
referencedFiles.push(fileReference);
|
||||
}
|
||||
else {
|
||||
var matchResult = fullTripleSlashReferencePathRegEx.exec(comment);
|
||||
var start = range.pos;
|
||||
var end = range.end;
|
||||
var length = end - start;
|
||||
|
||||
if (!matchResult) {
|
||||
errorAtPos(start, length, Diagnostics.Invalid_reference_directive_syntax);
|
||||
}
|
||||
else {
|
||||
referencedFiles.push({
|
||||
pos: start,
|
||||
end: end,
|
||||
filename: matchResult[3]
|
||||
});
|
||||
}
|
||||
if (diagnostic) {
|
||||
errorAtPos(range.pos, range.end - range.pos, diagnostic);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
+52
-13
@@ -1,5 +1,4 @@
|
||||
/// <reference path="core.ts"/>
|
||||
/// <reference path="scanner.ts"/>
|
||||
|
||||
module ts {
|
||||
|
||||
@@ -306,34 +305,66 @@ module ts {
|
||||
type?: TypeNode;
|
||||
}
|
||||
|
||||
export type DeclarationName = Identifier | LiteralExpression | ComputedPropertyName;
|
||||
|
||||
export interface Declaration extends Node {
|
||||
name?: Identifier;
|
||||
name?: DeclarationName;
|
||||
}
|
||||
|
||||
export interface ComputedPropertyName extends Node {
|
||||
expression: Expression;
|
||||
}
|
||||
|
||||
export interface TypeParameterDeclaration extends Declaration {
|
||||
name: Identifier;
|
||||
constraint?: TypeNode;
|
||||
}
|
||||
|
||||
export interface SignatureDeclaration extends Declaration, ParsedSignature { }
|
||||
|
||||
export interface VariableDeclaration extends Declaration {
|
||||
name: Identifier;
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
|
||||
export interface PropertyDeclaration extends VariableDeclaration { }
|
||||
export interface PropertyDeclaration extends Declaration {
|
||||
type?: TypeNode;
|
||||
initializer?: Expression;
|
||||
}
|
||||
|
||||
export interface ParameterDeclaration extends VariableDeclaration { }
|
||||
|
||||
export interface FunctionDeclaration extends Declaration, ParsedSignature {
|
||||
/**
|
||||
* Several node kinds share function-like features such as a signature,
|
||||
* a name, and a body. These nodes should extend FunctionLikeDeclaration.
|
||||
* Examples:
|
||||
* FunctionDeclaration
|
||||
* MethodDeclaration
|
||||
* ConstructorDeclaration
|
||||
* AccessorDeclaration
|
||||
* FunctionExpression
|
||||
*/
|
||||
export interface FunctionLikeDeclaration extends Declaration, ParsedSignature {
|
||||
body?: Block | Expression;
|
||||
}
|
||||
|
||||
export interface MethodDeclaration extends FunctionDeclaration { }
|
||||
export interface FunctionDeclaration extends FunctionLikeDeclaration {
|
||||
name: Identifier;
|
||||
body?: Block;
|
||||
}
|
||||
|
||||
export interface ConstructorDeclaration extends FunctionDeclaration { }
|
||||
export interface MethodDeclaration extends FunctionLikeDeclaration {
|
||||
body?: Block;
|
||||
}
|
||||
|
||||
export interface AccessorDeclaration extends FunctionDeclaration { }
|
||||
export interface ConstructorDeclaration extends FunctionLikeDeclaration {
|
||||
body?: Block;
|
||||
}
|
||||
|
||||
export interface AccessorDeclaration extends FunctionLikeDeclaration {
|
||||
body?: Block;
|
||||
}
|
||||
|
||||
export interface TypeNode extends Node { }
|
||||
|
||||
@@ -391,7 +422,8 @@ module ts {
|
||||
whenFalse: Expression;
|
||||
}
|
||||
|
||||
export interface FunctionExpression extends Expression, FunctionDeclaration {
|
||||
export interface FunctionExpression extends Expression, FunctionLikeDeclaration {
|
||||
name?: Identifier;
|
||||
body: Block | Expression; // Required, whereas the member inherited from FunctionDeclaration is optional
|
||||
}
|
||||
|
||||
@@ -542,6 +574,7 @@ module ts {
|
||||
}
|
||||
|
||||
export interface ClassDeclaration extends Declaration {
|
||||
name: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
baseType?: TypeReferenceNode;
|
||||
implementedTypes?: NodeArray<TypeReferenceNode>;
|
||||
@@ -549,28 +582,34 @@ module ts {
|
||||
}
|
||||
|
||||
export interface InterfaceDeclaration extends Declaration {
|
||||
name: Identifier;
|
||||
typeParameters?: NodeArray<TypeParameterDeclaration>;
|
||||
baseTypes?: NodeArray<TypeReferenceNode>;
|
||||
members: NodeArray<Node>;
|
||||
}
|
||||
|
||||
export interface TypeAliasDeclaration extends Declaration {
|
||||
name: Identifier;
|
||||
type: TypeNode;
|
||||
}
|
||||
|
||||
export interface EnumMember extends Declaration {
|
||||
name: Identifier | LiteralExpression;
|
||||
initializer?: Expression;
|
||||
}
|
||||
|
||||
export interface EnumDeclaration extends Declaration {
|
||||
name: Identifier;
|
||||
members: NodeArray<EnumMember>;
|
||||
}
|
||||
|
||||
export interface ModuleDeclaration extends Declaration {
|
||||
name: Identifier | LiteralExpression;
|
||||
body: Block | ModuleDeclaration;
|
||||
}
|
||||
|
||||
export interface ImportDeclaration extends Declaration {
|
||||
name: Identifier;
|
||||
entityName?: EntityName;
|
||||
externalModuleName?: LiteralExpression;
|
||||
}
|
||||
@@ -667,7 +706,7 @@ module ts {
|
||||
checkProgram(): void;
|
||||
emitFiles(targetSourceFile?: SourceFile): EmitResult;
|
||||
getParentOfSymbol(symbol: Symbol): Symbol;
|
||||
getTypeOfSymbol(symbol: Symbol): Type;
|
||||
getNarrowedTypeOfSymbol(symbol: Symbol, node: Node): Type;
|
||||
getDeclaredTypeOfSymbol(symbol: Symbol): Type;
|
||||
getPropertiesOfType(type: Type): Symbol[];
|
||||
getPropertyOfType(type: Type, propertyName: string): Symbol;
|
||||
@@ -686,7 +725,7 @@ module ts {
|
||||
getContextualType(node: Node): Type;
|
||||
getResolvedSignature(node: CallExpression, candidatesOutArray?: Signature[]): Signature;
|
||||
getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature;
|
||||
isImplementationOfOverload(node: FunctionDeclaration): boolean;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
isUndefinedSymbol(symbol: Symbol): boolean;
|
||||
isArgumentsSymbol(symbol: Symbol): boolean;
|
||||
hasEarlyErrors(sourceFile?: SourceFile): boolean;
|
||||
@@ -764,7 +803,7 @@ module ts {
|
||||
|
||||
export interface EmitResolver {
|
||||
getProgram(): Program;
|
||||
getLocalNameOfContainer(container: Declaration): string;
|
||||
getLocalNameOfContainer(container: ModuleDeclaration | EnumDeclaration): string;
|
||||
getExpressionNamePrefix(node: Identifier): string;
|
||||
getExportAssignmentName(node: SourceFile): string;
|
||||
isReferencedImportDeclaration(node: ImportDeclaration): boolean;
|
||||
@@ -773,7 +812,7 @@ module ts {
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
hasSemanticErrors(): boolean;
|
||||
isDeclarationVisible(node: Declaration): boolean;
|
||||
isImplementationOfOverload(node: FunctionDeclaration): boolean;
|
||||
isImplementationOfOverload(node: FunctionLikeDeclaration): boolean;
|
||||
writeTypeAtLocation(location: Node, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void;
|
||||
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
|
||||
@@ -1308,4 +1347,4 @@ module ts {
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
getNewLine(): string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,12 +285,10 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
typeLines.push('=== ' + file.unitName + ' ===\r\n');
|
||||
for (var i = 0; i < codeLines.length; i++) {
|
||||
var currentCodeLine = codeLines[i];
|
||||
var lastLine = typeLines[typeLines.length];
|
||||
typeLines.push(currentCodeLine + '\r\n');
|
||||
if (typeMap[file.unitName]) {
|
||||
var typeInfo = typeMap[file.unitName][i];
|
||||
if (typeInfo) {
|
||||
var leadingSpaces = '';
|
||||
typeInfo.forEach(ty => {
|
||||
typeLines.push('>' + ty + '\r\n');
|
||||
});
|
||||
|
||||
+77
-59
@@ -136,10 +136,11 @@ module FourSlash {
|
||||
outDir: 'outDir',
|
||||
sourceMap: 'sourceMap',
|
||||
sourceRoot: 'sourceRoot',
|
||||
resolveReference: 'ResolveReference', // This flag is used to specify entry file for resolve file references. The flag is only allow once per test file
|
||||
};
|
||||
|
||||
// List of allowed metadata names
|
||||
var fileMetadataNames = [testOptMetadataNames.filename, testOptMetadataNames.emitThisFile];
|
||||
var fileMetadataNames = [testOptMetadataNames.filename, testOptMetadataNames.emitThisFile, testOptMetadataNames.resolveReference];
|
||||
var globalMetadataNames = [testOptMetadataNames.baselineFile, testOptMetadataNames.declaration,
|
||||
testOptMetadataNames.mapRoot, testOptMetadataNames.module, testOptMetadataNames.out,
|
||||
testOptMetadataNames.outDir, testOptMetadataNames.sourceMap, testOptMetadataNames.sourceRoot]
|
||||
@@ -236,6 +237,25 @@ module FourSlash {
|
||||
throw new Error("Operation should be cancelled");
|
||||
}
|
||||
|
||||
// This function creates IScriptSnapshot object for testing getPreProcessedFileInfo
|
||||
// Return object may lack some functionalities for other purposes.
|
||||
function createScriptSnapShot(sourceText: string): TypeScript.IScriptSnapshot {
|
||||
return {
|
||||
getText: (start: number, end: number) => {
|
||||
return sourceText.substr(start, end - start);
|
||||
},
|
||||
getLength: () => {
|
||||
return sourceText.length;
|
||||
},
|
||||
getLineStartPositions: () => {
|
||||
return <number[]>[];
|
||||
},
|
||||
getChangeRange: (oldSnapshot: TypeScript.IScriptSnapshot) => {
|
||||
return <TypeScript.TextChangeRange>undefined;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export class TestState {
|
||||
// Language service instance
|
||||
public languageServiceShimHost: Harness.LanguageService.TypeScriptLS;
|
||||
@@ -264,6 +284,16 @@ module FourSlash {
|
||||
private scenarioActions: string[] = [];
|
||||
private taoInvalidReason: string = null;
|
||||
|
||||
private inputFiles: ts.Map<string> = {}; // Map between inputFile's filename and its content for easily looking up when resolving references
|
||||
|
||||
// Add input file which has matched file name with the given reference-file path.
|
||||
// This is necessary when resolveReference flag is specified
|
||||
private addMatchedInputFile(referenceFilePath: string) {
|
||||
var inputFile = this.inputFiles[referenceFilePath];
|
||||
if (inputFile && !Harness.isLibraryFile(referenceFilePath)) {
|
||||
this.languageServiceShimHost.addScript(referenceFilePath, inputFile);
|
||||
}
|
||||
}
|
||||
|
||||
constructor(public testData: FourSlashData) {
|
||||
// Initialize the language service with all the scripts
|
||||
@@ -273,57 +303,57 @@ module FourSlash {
|
||||
var compilationSettings = convertGlobalOptionsToCompilationSettings(this.testData.globalOptions);
|
||||
this.languageServiceShimHost.setCompilationSettings(compilationSettings);
|
||||
|
||||
var inputFiles: { unitName: string; content: string }[] = [];
|
||||
var startResolveFileRef: FourSlashFile = undefined;
|
||||
|
||||
testData.files.forEach(file => {
|
||||
var fixedPath = file.fileName.substr(file.fileName.indexOf('tests/'));
|
||||
});
|
||||
|
||||
// NEWTODO: disable resolution for now.
|
||||
// If the last unit contains require( or /// reference then consider it the only input file
|
||||
// and the rest will be added via resolution. If not, then assume we have multiple files
|
||||
// with 0 references in any of them. We could be smarter here to allow scenarios like
|
||||
// 2 files without references and 1 file with a reference but we have 0 tests like that
|
||||
// at the moment and an exhaustive search of the test files for that content could be quite slow.
|
||||
var lastFile = testData.files[testData.files.length - 1];
|
||||
//if (/require\(/.test(lastFile.content) || /reference\spath/.test(lastFile.content)) {
|
||||
// inputFiles.push({ unitName: lastFile.fileName, content: lastFile.content });
|
||||
//} else {
|
||||
inputFiles = testData.files.map(file => {
|
||||
return { unitName: file.fileName, content: file.content };
|
||||
});
|
||||
//}
|
||||
|
||||
|
||||
// NEWTODO: Re-implement commented-out section
|
||||
//harnessCompiler.addInputFiles(inputFiles);
|
||||
//try {
|
||||
// var resolvedFiles = harnessCompiler.resolve();
|
||||
|
||||
// resolvedFiles.forEach(file => {
|
||||
// if (!Harness.isLibraryFile(file.path)) {
|
||||
// var fixedPath = file.path.substr(file.path.indexOf('tests/'));
|
||||
// var content = harnessCompiler.getContentForFile(fixedPath);
|
||||
// this.languageServiceShimHost.addScript(fixedPath, content);
|
||||
// }
|
||||
// });
|
||||
|
||||
// this.languageServiceShimHost.addScript('lib.d.ts', Harness.Compiler.libTextMinimal);
|
||||
//}
|
||||
//finally {
|
||||
// // harness no longer needs the results of the above work, make sure the next test operations are in a clean state
|
||||
// harnessCompiler.reset();
|
||||
//}
|
||||
|
||||
/// NEWTODO: For now do not resolve, just use the input files
|
||||
inputFiles.forEach(file => {
|
||||
if (!Harness.isLibraryFile(file.unitName)) {
|
||||
this.languageServiceShimHost.addScript(file.unitName, file.content);
|
||||
ts.forEach(testData.files, file => {
|
||||
// Create map between fileName and its content for easily looking up when resolveReference flag is specified
|
||||
this.inputFiles[file.fileName] = file.content;
|
||||
if (!startResolveFileRef && file.fileOptions[testOptMetadataNames.resolveReference]) {
|
||||
startResolveFileRef = file;
|
||||
} else if (startResolveFileRef) {
|
||||
// If entry point for resolving file references is already specified, report duplication error
|
||||
throw new Error("There exists a Fourslash file which has resolveReference flag specified; remove duplicated resolveReference flag");
|
||||
}
|
||||
});
|
||||
|
||||
this.languageServiceShimHost.addDefaultLibrary();
|
||||
if (startResolveFileRef) {
|
||||
// Add the entry-point file itself into the languageServiceShimHost
|
||||
this.languageServiceShimHost.addScript(startResolveFileRef.fileName, startResolveFileRef.content);
|
||||
|
||||
var jsonResolvedResult = JSON.parse(this.languageServiceShimHost.getCoreService().getPreProcessedFileInfo(startResolveFileRef.fileName,
|
||||
createScriptSnapShot(startResolveFileRef.content)));
|
||||
var resolvedResult = jsonResolvedResult.result;
|
||||
var referencedFiles: ts.IFileReference[] = resolvedResult.referencedFiles;
|
||||
var importedFiles: ts.IFileReference[] = resolvedResult.importedFiles;
|
||||
|
||||
// Add triple reference files into language-service host
|
||||
ts.forEach(referencedFiles, referenceFile => {
|
||||
// Fourslash insert tests/cases/fourslash into inputFile.unitName so we will properly append the same base directory to refFile path
|
||||
var referenceFilePath = "tests/cases/fourslash/" + referenceFile.path;
|
||||
this.addMatchedInputFile(referenceFilePath);
|
||||
});
|
||||
|
||||
// Add import files into language-service host
|
||||
ts.forEach(importedFiles, importedFile => {
|
||||
// Fourslash insert tests/cases/fourslash into inputFile.unitName and import statement doesn't require ".ts"
|
||||
// so convert them before making appropriate comparison
|
||||
var importedFilePath = "tests/cases/fourslash/" + importedFile.path + ".ts";
|
||||
this.addMatchedInputFile(importedFilePath);
|
||||
});
|
||||
|
||||
// Check if no-default-lib flag is false and if so add default library
|
||||
if (!resolvedResult.isLibFile) {
|
||||
this.languageServiceShimHost.addDefaultLibrary();
|
||||
}
|
||||
} else {
|
||||
// resolveReference file-option is not specified then do not resolve any files and include all inputFiles
|
||||
ts.forEachKey(this.inputFiles, fileName => {
|
||||
if (!Harness.isLibraryFile(fileName)) {
|
||||
this.languageServiceShimHost.addScript(fileName, this.inputFiles[fileName]);
|
||||
}
|
||||
});
|
||||
this.languageServiceShimHost.addDefaultLibrary();
|
||||
}
|
||||
|
||||
// Sneak into the language service and get its compiler so we can examine the syntax trees
|
||||
this.languageService = this.languageServiceShimHost.getLanguageService().languageService;
|
||||
@@ -2044,10 +2074,6 @@ module FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private getEOF(): number {
|
||||
return this.languageServiceShimHost.getScriptSnapshot(this.activeFile.fileName).getLength();
|
||||
}
|
||||
|
||||
// Get the text of the entire line the caret is currently at
|
||||
private getCurrentLineContent() {
|
||||
// The current caret position (in line/col terms)
|
||||
@@ -2163,14 +2189,6 @@ module FourSlash {
|
||||
return result;
|
||||
}
|
||||
|
||||
private getCurrentLineNumberZeroBased() {
|
||||
return this.getCurrentLineNumberOneBased() - 1;
|
||||
}
|
||||
|
||||
private getCurrentLineNumberOneBased() {
|
||||
return this.languageServiceShimHost.positionToZeroBasedLineCol(this.activeFile.fileName, this.currentCaretPosition).line + 1;
|
||||
}
|
||||
|
||||
private getLineColStringAtPosition(position: number) {
|
||||
var pos = this.languageServiceShimHost.positionToZeroBasedLineCol(this.activeFile.fileName, position);
|
||||
return 'line ' + (pos.line + 1) + ', col ' + pos.character;
|
||||
|
||||
@@ -1092,7 +1092,6 @@ module Harness {
|
||||
/** @param fileResults an array of strings for the fileName and an ITextWriter with its code */
|
||||
constructor(fileResults: GeneratedFile[], errors: HarnessDiagnostic[], public program: ts.Program,
|
||||
public currentDirectoryForProgram: string, private sourceMapData: ts.SourceMapData[]) {
|
||||
var lines: string[] = [];
|
||||
|
||||
fileResults.forEach(emittedFile => {
|
||||
if (isDTS(emittedFile.fileName)) {
|
||||
@@ -1246,7 +1245,6 @@ module Harness {
|
||||
|
||||
/** Support class for baseline files */
|
||||
export module Baseline {
|
||||
var firstRun = true;
|
||||
|
||||
export interface BaselineOptions {
|
||||
LineEndingSensitive?: boolean;
|
||||
@@ -1287,8 +1285,7 @@ module Harness {
|
||||
IO.createDirectory(dirName);
|
||||
fileCache[dirName] = true;
|
||||
}
|
||||
var parentDir = IO.directoryName(actualFilename); // .../tests/baselines/local
|
||||
var parentParentDir = IO.directoryName(IO.directoryName(actualFilename)) // .../tests/baselines
|
||||
|
||||
// Create folders if needed
|
||||
createDirectoryStructure(Harness.IO.directoryName(actualFilename));
|
||||
|
||||
|
||||
@@ -258,6 +258,10 @@ module Harness.LanguageService {
|
||||
return new TypeScript.Services.TypeScriptServicesFactory().createClassifierShim(this);
|
||||
}
|
||||
|
||||
public getCoreService(): ts.CoreServicesShim {
|
||||
return new TypeScript.Services.TypeScriptServicesFactory().createCoreServicesShim(this);
|
||||
}
|
||||
|
||||
/** Parse file given its source text */
|
||||
public parseSourceText(fileName: string, sourceText: TypeScript.IScriptSnapshot): TypeScript.SourceUnitSyntax {
|
||||
return TypeScript.Parser.parse(fileName, TypeScript.SimpleText.fromScriptSnapshot(sourceText), ts.ScriptTarget.Latest, TypeScript.isDTSFile(fileName)).sourceUnit();
|
||||
|
||||
@@ -74,7 +74,7 @@ module ts.BreakpointResolver {
|
||||
return textSpan(node);
|
||||
}
|
||||
|
||||
if (node.parent.kind == SyntaxKind.ArrowFunction && (<FunctionDeclaration>node.parent).body == node) {
|
||||
if (node.parent.kind == SyntaxKind.ArrowFunction && (<FunctionLikeDeclaration>node.parent).body == node) {
|
||||
// If this is body of arrow function, it is allowed to have the breakpoint
|
||||
return textSpan(node);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ module ts.BreakpointResolver {
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return spanInFunctionDeclaration(<FunctionDeclaration>node);
|
||||
return spanInFunctionDeclaration(<FunctionLikeDeclaration>node);
|
||||
|
||||
case SyntaxKind.FunctionBlock:
|
||||
return spanInFunctionBlock(<Block>node);
|
||||
@@ -194,8 +194,9 @@ module ts.BreakpointResolver {
|
||||
// span in statement
|
||||
return spanInNode((<WithStatement>node).statement);
|
||||
|
||||
// No breakpoint in interface
|
||||
// No breakpoint in interface, type alias
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
case SyntaxKind.TypeAliasDeclaration:
|
||||
return undefined;
|
||||
|
||||
// Tokens:
|
||||
@@ -246,7 +247,7 @@ module ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
// return type of function go to previous token
|
||||
if (isAnyFunction(node.parent) && (<FunctionDeclaration>node.parent).type === node) {
|
||||
if (isAnyFunction(node.parent) && (<FunctionLikeDeclaration>node.parent).type === node) {
|
||||
return spanInPreviousNode(node);
|
||||
}
|
||||
|
||||
@@ -305,7 +306,7 @@ module ts.BreakpointResolver {
|
||||
return textSpan(parameter);
|
||||
}
|
||||
else {
|
||||
var functionDeclaration = <FunctionDeclaration>parameter.parent;
|
||||
var functionDeclaration = <FunctionLikeDeclaration>parameter.parent;
|
||||
var indexOfParameter = indexOf(functionDeclaration.parameters, parameter);
|
||||
if (indexOfParameter) {
|
||||
// Not a first parameter, go to previous parameter
|
||||
@@ -318,12 +319,12 @@ module ts.BreakpointResolver {
|
||||
}
|
||||
}
|
||||
|
||||
function canFunctionHaveSpanInWholeDeclaration(functionDeclaration: FunctionDeclaration) {
|
||||
function canFunctionHaveSpanInWholeDeclaration(functionDeclaration: FunctionLikeDeclaration) {
|
||||
return !!(functionDeclaration.flags & NodeFlags.Export) ||
|
||||
(functionDeclaration.parent.kind === SyntaxKind.ClassDeclaration && functionDeclaration.kind !== SyntaxKind.Constructor);
|
||||
}
|
||||
|
||||
function spanInFunctionDeclaration(functionDeclaration: FunctionDeclaration): TypeScript.TextSpan {
|
||||
function spanInFunctionDeclaration(functionDeclaration: FunctionLikeDeclaration): TypeScript.TextSpan {
|
||||
// No breakpoints in the function signature
|
||||
if (!functionDeclaration.body) {
|
||||
return undefined;
|
||||
@@ -340,7 +341,7 @@ module ts.BreakpointResolver {
|
||||
|
||||
function spanInFunctionBlock(block: Block): TypeScript.TextSpan {
|
||||
var nodeForSpanInBlock = block.statements.length ? block.statements[0] : block.getLastToken();
|
||||
if (canFunctionHaveSpanInWholeDeclaration(<FunctionDeclaration>block.parent)) {
|
||||
if (canFunctionHaveSpanInWholeDeclaration(<FunctionLikeDeclaration>block.parent)) {
|
||||
return spanInNodeIfStartsOnSameLine(block.parent, nodeForSpanInBlock);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,208 +0,0 @@
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
module TypeScript {
|
||||
export interface ILineAndCharacter {
|
||||
line: number;
|
||||
character: number;
|
||||
}
|
||||
|
||||
// Note: This is being using by the host (VS) and is marshaled back and forth. When changing this make sure the changes
|
||||
// are reflected in the managed side as well.
|
||||
export interface IFileReference extends ILineAndCharacter {
|
||||
path: string;
|
||||
isResident: boolean;
|
||||
position: number;
|
||||
length: number;
|
||||
}
|
||||
|
||||
///
|
||||
/// Preprocessing
|
||||
///
|
||||
export interface IPreProcessedFileInfo {
|
||||
referencedFiles: IFileReference[];
|
||||
importedFiles: IFileReference[];
|
||||
diagnostics: Diagnostic[];
|
||||
isLibFile: boolean;
|
||||
}
|
||||
|
||||
interface ITripleSlashDirectiveProperties {
|
||||
noDefaultLib: boolean;
|
||||
diagnostics: Diagnostic[];
|
||||
referencedFiles: IFileReference[];
|
||||
}
|
||||
|
||||
function isNoDefaultLibMatch(comment: string): RegExpExecArray {
|
||||
var isNoDefaultLibRegex = /^(\/\/\/\s*<reference\s+no-default-lib=)('|")(.+?)\2\s*\/>/gim;
|
||||
return isNoDefaultLibRegex.exec(comment);
|
||||
}
|
||||
|
||||
export var tripleSlashReferenceRegExp = /^(\/\/\/\s*<reference\s+path=)('|")(.+?)\2\s*(static=('|")(.+?)\5\s*)*\/>/;
|
||||
|
||||
function getFileReferenceFromReferencePath(fileName: string, text: ISimpleText, position: number, comment: string, diagnostics: Diagnostic[]): IFileReference {
|
||||
// First, just see if they've written: /// <reference\s+
|
||||
// If so, then we'll consider this a reference directive and we'll report errors if it's
|
||||
// malformed. Otherwise, we'll completely ignore this.
|
||||
var lineMap = text.lineMap();
|
||||
|
||||
var simpleReferenceRegEx = /^\/\/\/\s*<reference\s+/gim;
|
||||
if (simpleReferenceRegEx.exec(comment)) {
|
||||
var isNoDefaultLib = isNoDefaultLibMatch(comment);
|
||||
|
||||
if (!isNoDefaultLib) {
|
||||
var fullReferenceRegEx = tripleSlashReferenceRegExp;
|
||||
var fullReference = fullReferenceRegEx.exec(comment);
|
||||
|
||||
if (!fullReference) {
|
||||
// It matched the start of a reference directive, but wasn't well formed. Report
|
||||
// an appropriate error to the user.
|
||||
diagnostics.push(new Diagnostic(fileName, lineMap, position, comment.length, DiagnosticCode.Invalid_reference_directive_syntax));
|
||||
}
|
||||
else {
|
||||
var path: string = normalizePath(fullReference[3]);
|
||||
var adjustedPath = normalizePath(path);
|
||||
|
||||
var isResident = fullReference.length >= 7 && fullReference[6] === "true";
|
||||
return {
|
||||
line: 0,
|
||||
character: 0,
|
||||
position: 0,
|
||||
length: 0,
|
||||
path: switchToForwardSlashes(adjustedPath),
|
||||
isResident: isResident
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var reportDiagnostic = () => { };
|
||||
|
||||
function processImports(text: ISimpleText, scanner: Scanner.IScanner, token: ISyntaxToken, importedFiles: IFileReference[]): void {
|
||||
var lineChar = { line: -1, character: -1 };
|
||||
|
||||
var lineMap = text.lineMap();
|
||||
var start = new Date().getTime();
|
||||
// Look for:
|
||||
// import foo = module("foo")
|
||||
while (token.kind !== SyntaxKind.EndOfFileToken) {
|
||||
if (token.kind === SyntaxKind.ImportKeyword) {
|
||||
var importToken = token;
|
||||
token = scanner.scan(/*allowRegularExpression:*/ false);
|
||||
|
||||
if (SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) {
|
||||
token = scanner.scan(/*allowRegularExpression:*/ false);
|
||||
|
||||
if (token.kind === SyntaxKind.EqualsToken) {
|
||||
token = scanner.scan(/*allowRegularExpression:*/ false);
|
||||
|
||||
if (token.kind === SyntaxKind.ModuleKeyword || token.kind === SyntaxKind.RequireKeyword) {
|
||||
token = scanner.scan(/*allowRegularExpression:*/ false);
|
||||
|
||||
if (token.kind === SyntaxKind.OpenParenToken) {
|
||||
token = scanner.scan(/*allowRegularExpression:*/ false);
|
||||
|
||||
lineMap.fillLineAndCharacterFromPosition(TypeScript.start(importToken, text), lineChar);
|
||||
|
||||
if (token.kind === SyntaxKind.StringLiteral) {
|
||||
var ref = {
|
||||
line: lineChar.line,
|
||||
character: lineChar.character,
|
||||
position: TypeScript.start(token, text),
|
||||
length: width(token),
|
||||
path: stripStartAndEndQuotes(switchToForwardSlashes(token.text())),
|
||||
isResident: false
|
||||
};
|
||||
importedFiles.push(ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
token = scanner.scan(/*allowRegularExpression:*/ false);
|
||||
}
|
||||
|
||||
var totalTime = new Date().getTime() - start;
|
||||
//TypeScript.fileResolutionScanImportsTime += totalTime;
|
||||
}
|
||||
|
||||
function processTripleSlashDirectives(fileName: string, text: ISimpleText, firstToken: ISyntaxToken): ITripleSlashDirectiveProperties {
|
||||
var leadingTrivia = firstToken.leadingTrivia(text);
|
||||
|
||||
var position = 0;
|
||||
var lineChar = { line: -1, character: -1 };
|
||||
var noDefaultLib = false;
|
||||
var diagnostics: Diagnostic[] = [];
|
||||
var referencedFiles: IFileReference[] = [];
|
||||
var lineMap = text.lineMap();
|
||||
|
||||
for (var i = 0, n = leadingTrivia.count(); i < n; i++) {
|
||||
var trivia = leadingTrivia.syntaxTriviaAt(i);
|
||||
|
||||
if (trivia.kind() === SyntaxKind.SingleLineCommentTrivia) {
|
||||
var triviaText = trivia.fullText();
|
||||
var referencedCode = getFileReferenceFromReferencePath(fileName, text, position, triviaText, diagnostics);
|
||||
|
||||
if (referencedCode) {
|
||||
lineMap.fillLineAndCharacterFromPosition(position, lineChar);
|
||||
referencedCode.position = position;
|
||||
referencedCode.length = trivia.fullWidth();
|
||||
referencedCode.line = lineChar.line;
|
||||
referencedCode.character = lineChar.character;
|
||||
|
||||
referencedFiles.push(referencedCode);
|
||||
}
|
||||
|
||||
// is it a lib file?
|
||||
var isNoDefaultLib = isNoDefaultLibMatch(triviaText);
|
||||
if (isNoDefaultLib) {
|
||||
noDefaultLib = isNoDefaultLib[3] === "true";
|
||||
}
|
||||
}
|
||||
|
||||
position += trivia.fullWidth();
|
||||
}
|
||||
|
||||
return { noDefaultLib: noDefaultLib, diagnostics: diagnostics, referencedFiles: referencedFiles };
|
||||
}
|
||||
|
||||
export function preProcessFile(fileName: string, sourceText: IScriptSnapshot, readImportFiles = true): IPreProcessedFileInfo {
|
||||
var text = SimpleText.fromScriptSnapshot(sourceText);
|
||||
var scanner = Scanner.createScanner(ts.ScriptTarget.Latest, text, reportDiagnostic);
|
||||
|
||||
var firstToken = scanner.scan(/*allowRegularExpression:*/ false);
|
||||
|
||||
// only search out dynamic mods
|
||||
// if you find a dynamic mod, ignore every other mod inside, until you balance rcurlies
|
||||
// var position
|
||||
|
||||
var importedFiles: IFileReference[] = [];
|
||||
if (readImportFiles) {
|
||||
processImports(text, scanner, firstToken, importedFiles);
|
||||
}
|
||||
|
||||
var properties = processTripleSlashDirectives(fileName, text, firstToken);
|
||||
|
||||
return { referencedFiles: properties.referencedFiles, importedFiles: importedFiles, isLibFile: properties.noDefaultLib, diagnostics: properties.diagnostics };
|
||||
}
|
||||
|
||||
export function getReferencedFiles(fileName: string, sourceText: IScriptSnapshot): IFileReference[] {
|
||||
return preProcessFile(fileName, sourceText, false).referencedFiles;
|
||||
}
|
||||
} // Tools
|
||||
@@ -1,6 +1,11 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export interface ILineAndCharacter {
|
||||
line: number;
|
||||
character: number;
|
||||
}
|
||||
|
||||
export class LineMap {
|
||||
public static empty = new LineMap(() => [0], 0);
|
||||
private _lineStarts: number[] = undefined;
|
||||
|
||||
@@ -73,13 +73,14 @@ module ts.NavigationBar {
|
||||
function sortNodes(nodes: Node[]): Node[] {
|
||||
return nodes.slice(0).sort((n1: Declaration, n2: Declaration) => {
|
||||
if (n1.name && n2.name) {
|
||||
return n1.name.text.localeCompare(n2.name.text);
|
||||
// TODO(jfreeman): How do we sort declarations with computed names?
|
||||
return (<Identifier>n1.name).text.localeCompare((<Identifier>n2.name).text);
|
||||
}
|
||||
else if (n1.name) {
|
||||
return 1;
|
||||
}
|
||||
else if (n2.name) {
|
||||
-1;
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
return n1.kind - n2.kind;
|
||||
@@ -106,7 +107,7 @@ module ts.NavigationBar {
|
||||
break;
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
var functionDeclaration = <FunctionDeclaration>node;
|
||||
var functionDeclaration = <FunctionLikeDeclaration>node;
|
||||
if (isTopLevelFunctionDeclaration(functionDeclaration)) {
|
||||
topLevelNodes.push(node);
|
||||
addTopLevelNodes((<Block>functionDeclaration.body).statements, topLevelNodes);
|
||||
@@ -116,11 +117,12 @@ module ts.NavigationBar {
|
||||
}
|
||||
}
|
||||
|
||||
function isTopLevelFunctionDeclaration(functionDeclaration: FunctionDeclaration) {
|
||||
function isTopLevelFunctionDeclaration(functionDeclaration: FunctionLikeDeclaration) {
|
||||
if (functionDeclaration.kind === SyntaxKind.FunctionDeclaration) {
|
||||
// A function declaration is 'top level' if it contains any function declarations
|
||||
// within it.
|
||||
if (functionDeclaration.body && functionDeclaration.body.kind === SyntaxKind.FunctionBlock) {
|
||||
// Proper function declarations can only have identifier names
|
||||
if (forEach((<Block>functionDeclaration.body).statements,
|
||||
s => s.kind === SyntaxKind.FunctionDeclaration && !isEmpty((<FunctionDeclaration>s).name.text))) {
|
||||
|
||||
@@ -230,7 +232,7 @@ module ts.NavigationBar {
|
||||
return createItem(node, getTextOfNode((<PropertyDeclaration>node).name), ts.ScriptElementKind.memberVariableElement);
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
return createItem(node, getTextOfNode((<FunctionDeclaration>node).name), ts.ScriptElementKind.functionElement);
|
||||
return createItem(node, getTextOfNode((<FunctionLikeDeclaration>node).name), ts.ScriptElementKind.functionElement);
|
||||
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
if (node.flags & NodeFlags.Const) {
|
||||
@@ -371,8 +373,10 @@ module ts.NavigationBar {
|
||||
});
|
||||
|
||||
// Add the constructor parameters in as children of the class (for property parameters).
|
||||
// Note that *all* parameters will be added to the nodes array, but parameters that
|
||||
// are not properties will be filtered out later by createChildItem.
|
||||
var nodes: Node[] = constructor
|
||||
? constructor.parameters.concat(node.members)
|
||||
? node.members.concat(constructor.parameters)
|
||||
: node.members;
|
||||
|
||||
var childItems = getItemsWorker(sortNodes(nodes), createChildItem);
|
||||
|
||||
@@ -95,6 +95,7 @@ module TypeScript {
|
||||
Expression_expected: "Expression expected.",
|
||||
Type_expected: "Type expected.",
|
||||
Template_literal_cannot_be_used_as_an_element_name: "Template literal cannot be used as an element name.",
|
||||
Computed_property_names_cannot_be_used_here: "Computed property names cannot be used here.",
|
||||
Duplicate_identifier_0: "Duplicate identifier '{0}'.",
|
||||
The_name_0_does_not_exist_in_the_current_scope: "The name '{0}' does not exist in the current scope.",
|
||||
The_name_0_does_not_refer_to_a_value: "The name '{0}' does not refer to a value.",
|
||||
|
||||
@@ -97,6 +97,7 @@ module TypeScript {
|
||||
"Expression expected.": { "code": 1109, "category": DiagnosticCategory.Error },
|
||||
"Type expected.": { "code": 1110, "category": DiagnosticCategory.Error },
|
||||
"Template literal cannot be used as an element name.": { "code": 1111, "category": DiagnosticCategory.Error },
|
||||
"Computed property names cannot be used here.": { "code": 1112, "category": DiagnosticCategory.Error },
|
||||
"Duplicate identifier '{0}'.": { "code": 2000, "category": DiagnosticCategory.Error },
|
||||
"The name '{0}' does not exist in the current scope.": { "code": 2001, "category": DiagnosticCategory.Error },
|
||||
"The name '{0}' does not refer to a value.": { "code": 2002, "category": DiagnosticCategory.Error },
|
||||
|
||||
@@ -375,6 +375,10 @@
|
||||
"category": "Error",
|
||||
"code": 1111
|
||||
},
|
||||
"Computed property names cannot be used here.": {
|
||||
"category": "Error",
|
||||
"code": 1112
|
||||
},
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2000
|
||||
|
||||
+170
-76
@@ -75,6 +75,12 @@ module ts {
|
||||
update(scriptSnapshot: TypeScript.IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TypeScript.TextChangeRange): SourceFile;
|
||||
}
|
||||
|
||||
export interface PreProcessedFileInfo {
|
||||
referencedFiles: FileReference[];
|
||||
importedFiles: FileReference[];
|
||||
isLibFile: boolean
|
||||
}
|
||||
|
||||
var scanner: Scanner = createScanner(ScriptTarget.Latest, /*skipTrivia*/ true);
|
||||
|
||||
var emptyArray: any[] = [];
|
||||
@@ -137,7 +143,7 @@ module ts {
|
||||
while (pos < end) {
|
||||
var token = scanner.scan();
|
||||
var textPos = scanner.getTextPos();
|
||||
var node = nodes.push(createNode(token, pos, textPos, NodeFlags.Synthetic, this));
|
||||
nodes.push(createNode(token, pos, textPos, NodeFlags.Synthetic, this));
|
||||
pos = textPos;
|
||||
}
|
||||
return pos;
|
||||
@@ -345,7 +351,8 @@ module ts {
|
||||
function isName(pos: number, end: number, sourceFile: SourceFile, name: string) {
|
||||
return pos + name.length < end &&
|
||||
sourceFile.text.substr(pos, name.length) === name &&
|
||||
isWhiteSpace(sourceFile.text.charCodeAt(pos + name.length));
|
||||
(isWhiteSpace(sourceFile.text.charCodeAt(pos + name.length)) ||
|
||||
isLineBreak(sourceFile.text.charCodeAt(pos + name.length)));
|
||||
}
|
||||
|
||||
function isParamTag(pos: number, end: number, sourceFile: SourceFile) {
|
||||
@@ -353,9 +360,16 @@ module ts {
|
||||
return isName(pos, end, sourceFile, paramTag);
|
||||
}
|
||||
|
||||
function pushDocCommentLineText(docComments: SymbolDisplayPart[], text: string, blankLineCount: number) {
|
||||
// Add the empty lines in between texts
|
||||
while (blankLineCount--) docComments.push(textPart(""));
|
||||
docComments.push(textPart(text));
|
||||
}
|
||||
|
||||
function getCleanedJsDocComment(pos: number, end: number, sourceFile: SourceFile) {
|
||||
var spacesToRemoveAfterAsterisk: number;
|
||||
var docComments: SymbolDisplayPart[] = [];
|
||||
var blankLineCount = 0;
|
||||
var isInParamTag = false;
|
||||
|
||||
while (pos < end) {
|
||||
@@ -404,7 +418,12 @@ module ts {
|
||||
// Continue with next line
|
||||
pos = consumeLineBreaks(pos, end, sourceFile);
|
||||
if (docCommentTextOfLine) {
|
||||
docComments.push(textPart(docCommentTextOfLine));
|
||||
pushDocCommentLineText(docComments, docCommentTextOfLine, blankLineCount);
|
||||
blankLineCount = 0;
|
||||
}
|
||||
else if (!isInParamTag && docComments.length) {
|
||||
// This is blank line when there is text already parsed
|
||||
blankLineCount++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,6 +435,8 @@ module ts {
|
||||
var paramDocComments: SymbolDisplayPart[] = [];
|
||||
while (pos < end) {
|
||||
if (isParamTag(pos, end, sourceFile)) {
|
||||
var blankLineCount = 0;
|
||||
var recordedParamTag = false;
|
||||
// Consume leading spaces
|
||||
pos = consumeWhiteSpaces(pos + paramTag.length);
|
||||
if (pos >= end) {
|
||||
@@ -477,8 +498,13 @@ module ts {
|
||||
// at line break, set this comment line text and go to next line
|
||||
if (isLineBreak(ch)) {
|
||||
if (paramHelpString) {
|
||||
paramDocComments.push(textPart(paramHelpString));
|
||||
pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount);
|
||||
paramHelpString = "";
|
||||
blankLineCount = 0;
|
||||
recordedParamTag = true;
|
||||
}
|
||||
else if (recordedParamTag) {
|
||||
blankLineCount++;
|
||||
}
|
||||
|
||||
// Get the pos after cleaning start of the line
|
||||
@@ -499,7 +525,7 @@ module ts {
|
||||
|
||||
// If there is param help text, add it top the doc comments
|
||||
if (paramHelpString) {
|
||||
paramDocComments.push(textPart(paramHelpString));
|
||||
pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount);
|
||||
}
|
||||
paramHelpStringMargin = undefined;
|
||||
}
|
||||
@@ -627,7 +653,7 @@ module ts {
|
||||
if (this.documentationComment === undefined) {
|
||||
this.documentationComment = this.declaration ? getJsDocCommentsFromDeclarations(
|
||||
[this.declaration],
|
||||
this.declaration.name ? this.declaration.name.text : "",
|
||||
/*name*/ undefined,
|
||||
/*canUseParsedParamTagComments*/ false) : [];
|
||||
}
|
||||
|
||||
@@ -635,8 +661,6 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
var incrementalParse: IncrementalParse = TypeScript.IncrementalParser.parse;
|
||||
|
||||
class SourceFileObject extends NodeObject implements SourceFile {
|
||||
public filename: string;
|
||||
public text: string;
|
||||
@@ -674,7 +698,7 @@ module ts {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.Method:
|
||||
var functionDeclaration = <FunctionDeclaration>node;
|
||||
var functionDeclaration = <FunctionLikeDeclaration>node;
|
||||
|
||||
if (functionDeclaration.name && functionDeclaration.name.kind !== SyntaxKind.Missing) {
|
||||
var lastDeclaration = namedDeclarations.length > 0 ?
|
||||
@@ -685,7 +709,7 @@ module ts {
|
||||
if (lastDeclaration && functionDeclaration.symbol === lastDeclaration.symbol) {
|
||||
// Overwrite the last declaration if it was an overload
|
||||
// and this one is an implementation.
|
||||
if (functionDeclaration.body && !(<FunctionDeclaration>lastDeclaration).body) {
|
||||
if (functionDeclaration.body && !(<FunctionLikeDeclaration>lastDeclaration).body) {
|
||||
namedDeclarations[namedDeclarations.length - 1] = functionDeclaration;
|
||||
}
|
||||
}
|
||||
@@ -737,10 +761,6 @@ module ts {
|
||||
return this.namedDeclarations;
|
||||
}
|
||||
|
||||
private isDeclareFile(): boolean {
|
||||
return TypeScript.isDTSFile(this.filename);
|
||||
}
|
||||
|
||||
public update(scriptSnapshot: TypeScript.IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TypeScript.TextChangeRange): SourceFile {
|
||||
if (textChangeRange && Debug.shouldAssert(AssertionLevel.Normal)) {
|
||||
var oldText = this.scriptSnapshot;
|
||||
@@ -1535,7 +1555,7 @@ module ts {
|
||||
var filenames = host.getScriptFileNames();
|
||||
for (var i = 0, n = filenames.length; i < n; i++) {
|
||||
var filename = filenames[i];
|
||||
this.filenameToEntry[TypeScript.switchToForwardSlashes(filename)] = {
|
||||
this.filenameToEntry[switchToForwardSlashes(filename)] = {
|
||||
filename: filename,
|
||||
version: host.getScriptVersion(filename),
|
||||
isOpen: host.getScriptIsOpen(filename)
|
||||
@@ -1550,7 +1570,7 @@ module ts {
|
||||
}
|
||||
|
||||
public getEntry(filename: string): HostFileInformation {
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
filename = switchToForwardSlashes(filename);
|
||||
return lookUp(this.filenameToEntry, filename);
|
||||
}
|
||||
|
||||
@@ -1906,6 +1926,68 @@ module ts {
|
||||
};
|
||||
}
|
||||
|
||||
export function preProcessFile(sourceText: string, readImportFiles = true): PreProcessedFileInfo {
|
||||
var referencedFiles: FileReference[] = [];
|
||||
var importedFiles: FileReference[] = [];
|
||||
var isNoDefaultLib = false;
|
||||
|
||||
function processTripleSlashDirectives(): void {
|
||||
var commentRanges = getLeadingCommentRanges(sourceText, 0);
|
||||
forEach(commentRanges, commentRange => {
|
||||
var comment = sourceText.substring(commentRange.pos, commentRange.end);
|
||||
var referencePathMatchResult = getFileReferenceFromReferencePath(comment, commentRange);
|
||||
if (referencePathMatchResult) {
|
||||
isNoDefaultLib = referencePathMatchResult.isNoDefaultLib;
|
||||
var fileReference = referencePathMatchResult.fileReference;
|
||||
if (fileReference) {
|
||||
referencedFiles.push(fileReference);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function processImport(): void {
|
||||
scanner.setText(sourceText);
|
||||
var token = scanner.scan();
|
||||
// Look for:
|
||||
// import foo = module("foo");
|
||||
while (token !== SyntaxKind.EndOfFileToken) {
|
||||
if (token === SyntaxKind.ImportKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.Identifier) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.EqualsToken) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.RequireKeyword) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.OpenParenToken) {
|
||||
token = scanner.scan();
|
||||
if (token === SyntaxKind.StringLiteral) {
|
||||
var importPath = scanner.getTokenValue();
|
||||
var pos = scanner.getTokenPos();
|
||||
importedFiles.push({
|
||||
filename: importPath,
|
||||
pos: pos,
|
||||
end: pos + importPath.length
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
token = scanner.scan();
|
||||
}
|
||||
scanner.setText(undefined);
|
||||
}
|
||||
|
||||
if (readImportFiles) {
|
||||
processImport();
|
||||
}
|
||||
processTripleSlashDirectives();
|
||||
return { referencedFiles: referencedFiles, importedFiles: importedFiles, isLibFile: isNoDefaultLib };
|
||||
}
|
||||
|
||||
/// Helpers
|
||||
export function getNodeModifiers(node: Node): string {
|
||||
var flags = node.flags;
|
||||
@@ -1989,7 +2071,7 @@ module ts {
|
||||
|
||||
function isNameOfFunctionDeclaration(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.Identifier &&
|
||||
isAnyFunction(node.parent) && (<FunctionDeclaration>node.parent).name === node;
|
||||
isAnyFunction(node.parent) && (<FunctionLikeDeclaration>node.parent).name === node;
|
||||
}
|
||||
|
||||
/** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */
|
||||
@@ -2276,7 +2358,7 @@ module ts {
|
||||
function getSyntacticDiagnostics(filename: string) {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
filename = switchToForwardSlashes(filename);
|
||||
|
||||
return program.getDiagnostics(getSourceFile(filename).getSourceFile());
|
||||
}
|
||||
@@ -2288,7 +2370,7 @@ module ts {
|
||||
function getSemanticDiagnostics(filename: string) {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = TypeScript.switchToForwardSlashes(filename)
|
||||
filename = switchToForwardSlashes(filename)
|
||||
var compilerOptions = program.getCompilerOptions();
|
||||
var checker = getFullTypeCheckChecker();
|
||||
var targetSourceFile = getSourceFile(filename);
|
||||
@@ -2346,7 +2428,7 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function createCompletionEntry(symbol: Symbol, typeChecker: TypeChecker): CompletionEntry {
|
||||
function createCompletionEntry(symbol: Symbol, typeChecker: TypeChecker, location: Node): CompletionEntry {
|
||||
// Try to get a valid display name for this symbol, if we could not find one, then ignore it.
|
||||
// We would like to only show things that can be added after a dot, so for instance numeric properties can
|
||||
// not be accessed with a dot (a.1 <- invalid)
|
||||
@@ -2361,7 +2443,7 @@ module ts {
|
||||
// We COULD also just do what 'getSymbolModifiers' does, which is to use the first declaration.
|
||||
return {
|
||||
name: displayName,
|
||||
kind: getSymbolKind(symbol, typeChecker),
|
||||
kind: getSymbolKind(symbol, typeChecker, location),
|
||||
kindModifiers: getSymbolModifiers(symbol)
|
||||
};
|
||||
}
|
||||
@@ -2369,7 +2451,7 @@ module ts {
|
||||
function getCompletionsAtPosition(filename: string, position: number, isMemberCompletion: boolean) {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
filename = switchToForwardSlashes(filename);
|
||||
|
||||
var syntacticStart = new Date().getTime();
|
||||
var sourceFile = getSourceFile(filename);
|
||||
@@ -2432,6 +2514,7 @@ module ts {
|
||||
};
|
||||
host.log("getCompletionsAtPosition: Syntactic work: " + (new Date().getTime() - syntacticStart));
|
||||
|
||||
var location = getTouchingPropertyName(sourceFile, position);
|
||||
// Populate the completion list
|
||||
var semanticStart = new Date().getTime();
|
||||
if (isRightOfDot) {
|
||||
@@ -2513,13 +2596,13 @@ module ts {
|
||||
function getCompletionEntriesFromSymbols(symbols: Symbol[], session: CompletionSession): void {
|
||||
var start = new Date().getTime();
|
||||
forEach(symbols, symbol => {
|
||||
var entry = createCompletionEntry(symbol, session.typeChecker);
|
||||
var entry = createCompletionEntry(symbol, session.typeChecker, location);
|
||||
if (entry && !lookUp(session.symbols, entry.name)) {
|
||||
session.entries.push(entry);
|
||||
session.symbols[entry.name] = symbol;
|
||||
}
|
||||
});
|
||||
host.log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - semanticStart));
|
||||
host.log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start));
|
||||
}
|
||||
|
||||
function isCompletionListBlocker(previousToken: Node): boolean {
|
||||
@@ -2527,7 +2610,7 @@ module ts {
|
||||
var result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) ||
|
||||
isIdentifierDefinitionLocation(previousToken) ||
|
||||
isRightOfIllegalDot(previousToken);
|
||||
host.log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - semanticStart));
|
||||
host.log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2649,6 +2732,7 @@ module ts {
|
||||
case SyntaxKind.VarKeyword:
|
||||
case SyntaxKind.GetKeyword:
|
||||
case SyntaxKind.SetKeyword:
|
||||
case SyntaxKind.ImportKeyword:
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2694,7 +2778,8 @@ module ts {
|
||||
return;
|
||||
}
|
||||
|
||||
existingMemberNames[m.name.text] = true;
|
||||
// TODO(jfreeman): Account for computed property name
|
||||
existingMemberNames[(<Identifier>m.name).text] = true;
|
||||
});
|
||||
|
||||
var filteredMembers: Symbol[] = [];
|
||||
@@ -2711,7 +2796,7 @@ module ts {
|
||||
function getCompletionEntryDetails(filename: string, position: number, entryName: string): CompletionEntryDetails {
|
||||
// Note: No need to call synchronizeHostData, as we have captured all the data we need
|
||||
// in the getCompletionsAtPosition earlier
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
filename = switchToForwardSlashes(filename);
|
||||
|
||||
var sourceFile = getSourceFile(filename);
|
||||
|
||||
@@ -2724,14 +2809,13 @@ module ts {
|
||||
|
||||
var symbol = lookUp(activeCompletionSession.symbols, entryName);
|
||||
if (symbol) {
|
||||
var type = session.typeChecker.getTypeOfSymbol(symbol);
|
||||
Debug.assert(type !== undefined, "Could not find type for symbol");
|
||||
var completionEntry = createCompletionEntry(symbol, session.typeChecker);
|
||||
var location = getTouchingPropertyName(sourceFile, position);
|
||||
var completionEntry = createCompletionEntry(symbol, session.typeChecker, location);
|
||||
// TODO(drosen): Right now we just permit *all* semantic meanings when calling 'getSymbolKind'
|
||||
// which is permissible given that it is backwards compatible; but really we should consider
|
||||
// passing the meaning for the node so that we don't report that a suggestion for a value is an interface.
|
||||
// We COULD also just do what 'getSymbolModifiers' does, which is to use the first declaration.
|
||||
var location = getTouchingPropertyName(sourceFile, position);
|
||||
Debug.assert(session.typeChecker.getNarrowedTypeOfSymbol(symbol, location) !== undefined, "Could not find type for symbol");
|
||||
var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getSourceFile(filename), location, session.typeChecker, location, SemanticMeaning.All);
|
||||
return {
|
||||
name: entryName,
|
||||
@@ -2776,7 +2860,7 @@ module ts {
|
||||
}
|
||||
|
||||
// TODO(drosen): use contextual SemanticMeaning.
|
||||
function getSymbolKind(symbol: Symbol, typeResolver: TypeChecker): string {
|
||||
function getSymbolKind(symbol: Symbol, typeResolver: TypeChecker, location?: Node): string {
|
||||
var flags = symbol.getFlags();
|
||||
|
||||
if (flags & SymbolFlags.Class) return ScriptElementKind.classElement;
|
||||
@@ -2785,7 +2869,7 @@ module ts {
|
||||
if (flags & SymbolFlags.Interface) return ScriptElementKind.interfaceElement;
|
||||
if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement;
|
||||
|
||||
var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver);
|
||||
var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver, location);
|
||||
if (result === ScriptElementKind.unknown) {
|
||||
if (flags & SymbolFlags.TypeParameter) return ScriptElementKind.typeParameterElement;
|
||||
if (flags & SymbolFlags.EnumMember) return ScriptElementKind.variableElement;
|
||||
@@ -2795,7 +2879,7 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol: Symbol, flags: SymbolFlags, typeResolver: TypeChecker) {
|
||||
function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol: Symbol, flags: SymbolFlags, typeResolver: TypeChecker, location: Node) {
|
||||
if (typeResolver.isUndefinedSymbol(symbol)) {
|
||||
return ScriptElementKind.variableElement;
|
||||
}
|
||||
@@ -2819,15 +2903,24 @@ module ts {
|
||||
|
||||
if (flags & SymbolFlags.Property) {
|
||||
if (flags & SymbolFlags.UnionProperty) {
|
||||
return forEach(typeInfoResolver.getRootSymbols(symbol), rootSymbol => {
|
||||
// If union property is result of union of non method (property/accessors/variables), it is labeled as property
|
||||
var unionPropertyKind = forEach(typeInfoResolver.getRootSymbols(symbol), rootSymbol => {
|
||||
var rootSymbolFlags = rootSymbol.getFlags();
|
||||
if (rootSymbolFlags & SymbolFlags.Property) {
|
||||
if (rootSymbolFlags & (SymbolFlags.PropertyOrAccessor | SymbolFlags.Variable)) {
|
||||
return ScriptElementKind.memberVariableElement;
|
||||
}
|
||||
if (rootSymbolFlags & SymbolFlags.GetAccessor) return ScriptElementKind.memberVariableElement;
|
||||
if (rootSymbolFlags & SymbolFlags.SetAccessor) return ScriptElementKind.memberVariableElement;
|
||||
Debug.assert((rootSymbolFlags & SymbolFlags.Method) !== undefined);
|
||||
}) || ScriptElementKind.memberFunctionElement;
|
||||
Debug.assert(!!(rootSymbolFlags & SymbolFlags.Method));
|
||||
});
|
||||
if (!unionPropertyKind) {
|
||||
// If this was union of all methods,
|
||||
//make sure it has call signatures before we can label it as method
|
||||
var typeOfUnionProperty = typeInfoResolver.getNarrowedTypeOfSymbol(symbol, location);
|
||||
if (typeOfUnionProperty.getCallSignatures().length) {
|
||||
return ScriptElementKind.memberFunctionElement;
|
||||
}
|
||||
return ScriptElementKind.memberVariableElement;
|
||||
}
|
||||
return unionPropertyKind;
|
||||
}
|
||||
return ScriptElementKind.memberVariableElement;
|
||||
}
|
||||
@@ -2885,7 +2978,7 @@ module ts {
|
||||
var displayParts: SymbolDisplayPart[] = [];
|
||||
var documentation: SymbolDisplayPart[];
|
||||
var symbolFlags = symbol.flags;
|
||||
var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, typeResolver);
|
||||
var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, typeResolver, location);
|
||||
var hasAddedSymbolInfo: boolean;
|
||||
// Class at constructor site need to be shown as constructor apart from property,method, vars
|
||||
if (symbolKind !== ScriptElementKind.unknown || symbolFlags & SymbolFlags.Class || symbolFlags & SymbolFlags.Import) {
|
||||
@@ -2894,7 +2987,7 @@ module ts {
|
||||
symbolKind = ScriptElementKind.memberVariableElement;
|
||||
}
|
||||
|
||||
var type = typeResolver.getTypeOfSymbol(symbol);
|
||||
var type = typeResolver.getNarrowedTypeOfSymbol(symbol, location);
|
||||
if (type) {
|
||||
if (location.parent && location.parent.kind === SyntaxKind.PropertyAccess) {
|
||||
var right = (<PropertyAccess>location.parent).right;
|
||||
@@ -2981,7 +3074,7 @@ module ts {
|
||||
(location.kind === SyntaxKind.ConstructorKeyword && location.parent.kind === SyntaxKind.Constructor)) { // At constructor keyword of constructor declaration
|
||||
// get the signature from the declaration and write it
|
||||
var signature: Signature;
|
||||
var functionDeclaration = <FunctionDeclaration>location.parent;
|
||||
var functionDeclaration = <FunctionLikeDeclaration>location.parent;
|
||||
var allSignatures = functionDeclaration.kind === SyntaxKind.Constructor ? type.getConstructSignatures() : type.getCallSignatures();
|
||||
if (!typeResolver.isImplementationOfOverload(functionDeclaration)) {
|
||||
signature = typeResolver.getSignatureFromDeclaration(functionDeclaration);
|
||||
@@ -3087,13 +3180,13 @@ module ts {
|
||||
displayParts.push(keywordPart(SyntaxKind.ImportKeyword));
|
||||
displayParts.push(spacePart());
|
||||
addFullSymbolName(symbol);
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(punctuationPart(SyntaxKind.EqualsToken));
|
||||
displayParts.push(spacePart());
|
||||
ts.forEach(symbol.declarations, declaration => {
|
||||
if (declaration.kind === SyntaxKind.ImportDeclaration) {
|
||||
var importDeclaration = <ImportDeclaration>declaration;
|
||||
if (importDeclaration.externalModuleName) {
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(punctuationPart(SyntaxKind.EqualsToken));
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(keywordPart(SyntaxKind.RequireKeyword));
|
||||
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
|
||||
displayParts.push(displayPart(getTextOfNode(importDeclaration.externalModuleName), SymbolDisplayPartKind.stringLiteral));
|
||||
@@ -3101,7 +3194,12 @@ module ts {
|
||||
}
|
||||
else {
|
||||
var internalAliasSymbol = typeResolver.getSymbolInfo(importDeclaration.entityName);
|
||||
addFullSymbolName(internalAliasSymbol, enclosingDeclaration);
|
||||
if (internalAliasSymbol) {
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(punctuationPart(SyntaxKind.EqualsToken));
|
||||
displayParts.push(spacePart());
|
||||
addFullSymbolName(internalAliasSymbol, enclosingDeclaration);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -3140,7 +3238,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
symbolKind = getSymbolKind(symbol, typeResolver);
|
||||
symbolKind = getSymbolKind(symbol, typeResolver, location);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3198,7 +3296,7 @@ module ts {
|
||||
function getQuickInfoAtPosition(fileName: string, position: number): QuickInfo {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = TypeScript.switchToForwardSlashes(fileName);
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
var sourceFile = getSourceFile(fileName);
|
||||
var node = getTouchingPropertyName(sourceFile, position);
|
||||
if (!node) {
|
||||
@@ -3261,7 +3359,7 @@ module ts {
|
||||
if ((selectConstructors && d.kind === SyntaxKind.Constructor) ||
|
||||
(!selectConstructors && (d.kind === SyntaxKind.FunctionDeclaration || d.kind === SyntaxKind.Method))) {
|
||||
declarations.push(d);
|
||||
if ((<FunctionDeclaration>d).body) definition = d;
|
||||
if ((<FunctionLikeDeclaration>d).body) definition = d;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -3300,7 +3398,7 @@ module ts {
|
||||
|
||||
synchronizeHostData();
|
||||
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
filename = switchToForwardSlashes(filename);
|
||||
var sourceFile = getSourceFile(filename);
|
||||
|
||||
var node = getTouchingPropertyName(sourceFile, position);
|
||||
@@ -3364,7 +3462,7 @@ module ts {
|
||||
function getOccurrencesAtPosition(filename: string, position: number): ReferenceEntry[] {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
filename = switchToForwardSlashes(filename);
|
||||
var sourceFile = getSourceFile(filename);
|
||||
|
||||
var node = getTouchingWord(sourceFile, position);
|
||||
@@ -3508,7 +3606,7 @@ module ts {
|
||||
}
|
||||
|
||||
function getReturnOccurrences(returnStatement: ReturnStatement): ReferenceEntry[] {
|
||||
var func = <FunctionDeclaration>getContainingFunction(returnStatement);
|
||||
var func = <FunctionLikeDeclaration>getContainingFunction(returnStatement);
|
||||
|
||||
// If we didn't find a containing function with a block body, bail out.
|
||||
if (!(func && hasKind(func.body, SyntaxKind.FunctionBlock))) {
|
||||
@@ -3667,9 +3765,6 @@ module ts {
|
||||
|
||||
pushKeywordIf(keywords, switchStatement.getFirstToken(), SyntaxKind.SwitchKeyword);
|
||||
|
||||
// Types of break statements we can grab on to.
|
||||
var breakSearchType = BreakContinueSearchType.All;
|
||||
|
||||
// Go through each clause in the switch statement, collecting the 'case'/'default' keywords.
|
||||
forEach(switchStatement.clauses, clause => {
|
||||
pushKeywordIf(keywords, clause.getFirstToken(), SyntaxKind.CaseKeyword, SyntaxKind.DefaultKeyword);
|
||||
@@ -3817,7 +3912,7 @@ module ts {
|
||||
function findReferences(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReferenceEntry[] {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = TypeScript.switchToForwardSlashes(fileName);
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
var sourceFile = getSourceFile(fileName);
|
||||
|
||||
var node = getTouchingPropertyName(sourceFile, position);
|
||||
@@ -3907,7 +4002,7 @@ module ts {
|
||||
|
||||
function getNormalizedSymbolName(symbolName: string, declarations: Declaration[]): string {
|
||||
// Special case for function expressions, whose names are solely local to their bodies.
|
||||
var functionExpression = forEach(declarations, d => d.kind === SyntaxKind.FunctionExpression ? d : undefined);
|
||||
var functionExpression = forEach(declarations, d => d.kind === SyntaxKind.FunctionExpression ? <FunctionExpression>d : undefined);
|
||||
|
||||
if (functionExpression && functionExpression.name) {
|
||||
var name = functionExpression.name.text;
|
||||
@@ -4466,7 +4561,8 @@ module ts {
|
||||
var declarations = sourceFile.getNamedDeclarations();
|
||||
for (var i = 0, n = declarations.length; i < n; i++) {
|
||||
var declaration = declarations[i];
|
||||
var name = declaration.name.text;
|
||||
// TODO(jfreeman): Skip this declaration if it has a computed name
|
||||
var name = (<Identifier>declaration.name).text;
|
||||
var matchKind = getMatchKind(searchTerms, name);
|
||||
if (matchKind !== MatchKind.none) {
|
||||
var container = <Declaration>getContainerNode(declaration);
|
||||
@@ -4477,7 +4573,8 @@ module ts {
|
||||
matchKind: MatchKind[matchKind],
|
||||
fileName: filename,
|
||||
textSpan: TypeScript.TextSpan.fromBounds(declaration.getStart(), declaration.getEnd()),
|
||||
containerName: container.name ? container.name.text : "",
|
||||
// TODO(jfreeman): What should be the containerName when the container has a computed name?
|
||||
containerName: container.name ? (<Identifier>container.name).text : "",
|
||||
containerKind: container.name ? getNodeKind(container) : ""
|
||||
});
|
||||
}
|
||||
@@ -4536,12 +4633,11 @@ module ts {
|
||||
|
||||
function getEmitOutput(filename: string): EmitOutput {
|
||||
synchronizeHostData();
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
filename = switchToForwardSlashes(filename);
|
||||
var compilerOptions = program.getCompilerOptions();
|
||||
var targetSourceFile = program.getSourceFile(filename); // Current selected file to be output
|
||||
// If --out flag is not specified, shouldEmitToOwnFile is true. Otherwise shouldEmitToOwnFile is false.
|
||||
var shouldEmitToOwnFile = ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions);
|
||||
var emitDeclaration = compilerOptions.declaration;
|
||||
var emitOutput: EmitOutput = {
|
||||
outputFiles: [],
|
||||
emitOutputStatus: undefined,
|
||||
@@ -4558,7 +4654,6 @@ module ts {
|
||||
// Initialize writer for CompilerHost.writeFile
|
||||
writer = getEmitOutputWriter;
|
||||
|
||||
var syntacticDiagnostics: Diagnostic[] = [];
|
||||
var containSyntacticErrors = false;
|
||||
|
||||
if (shouldEmitToOwnFile) {
|
||||
@@ -4712,7 +4807,7 @@ module ts {
|
||||
function getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = TypeScript.switchToForwardSlashes(fileName);
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
var sourceFile = getSourceFile(fileName);
|
||||
|
||||
return SignatureHelp.getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken);
|
||||
@@ -4782,12 +4877,12 @@ module ts {
|
||||
|
||||
/// Syntactic features
|
||||
function getSyntaxTree(filename: string): TypeScript.SyntaxTree {
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
filename = switchToForwardSlashes(filename);
|
||||
return syntaxTreeCache.getCurrentFileSyntaxTree(filename);
|
||||
}
|
||||
|
||||
function getCurrentSourceFile(filename: string): SourceFile {
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
filename = switchToForwardSlashes(filename);
|
||||
var currentSourceFile = syntaxTreeCache.getCurrentSourceFile(filename);
|
||||
return currentSourceFile;
|
||||
}
|
||||
@@ -4854,14 +4949,14 @@ module ts {
|
||||
}
|
||||
|
||||
function getNavigationBarItems(filename: string): NavigationBarItem[] {
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
filename = switchToForwardSlashes(filename);
|
||||
|
||||
return NavigationBar.getNavigationBarItems(getCurrentSourceFile(filename));
|
||||
}
|
||||
|
||||
function getSemanticClassifications(fileName: string, span: TypeScript.TextSpan): ClassifiedSpan[] {
|
||||
synchronizeHostData();
|
||||
fileName = TypeScript.switchToForwardSlashes(fileName);
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
|
||||
var sourceFile = getSourceFile(fileName);
|
||||
|
||||
@@ -4932,7 +5027,7 @@ module ts {
|
||||
|
||||
function getSyntacticClassifications(fileName: string, span: TypeScript.TextSpan): ClassifiedSpan[] {
|
||||
// doesn't use compiler - no need to synchronize with host
|
||||
fileName = TypeScript.switchToForwardSlashes(fileName);
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
var sourceFile = getCurrentSourceFile(fileName);
|
||||
|
||||
var result: ClassifiedSpan[] = [];
|
||||
@@ -5062,7 +5157,7 @@ module ts {
|
||||
|
||||
function getOutliningSpans(filename: string): OutliningSpan[] {
|
||||
// doesn't use compiler - no need to synchronize with host
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
filename = switchToForwardSlashes(filename);
|
||||
var sourceFile = getCurrentSourceFile(filename);
|
||||
return OutliningElementsCollector.collectElements(sourceFile);
|
||||
}
|
||||
@@ -5121,7 +5216,7 @@ module ts {
|
||||
}
|
||||
|
||||
function getIndentationAtPosition(filename: string, position: number, editorOptions: EditorOptions) {
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
filename = switchToForwardSlashes(filename);
|
||||
|
||||
var start = new Date().getTime();
|
||||
var sourceFile = getCurrentSourceFile(filename);
|
||||
@@ -5136,14 +5231,14 @@ module ts {
|
||||
}
|
||||
|
||||
function getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[] {
|
||||
fileName = TypeScript.switchToForwardSlashes(fileName);
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
var options = copyFormatCodeOptions(options);
|
||||
var sourceFile = getCurrentSourceFile(fileName);
|
||||
return formatting.formatSelection(start, end, sourceFile, getRuleProvider(options), options);
|
||||
}
|
||||
|
||||
function getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[] {
|
||||
fileName = TypeScript.switchToForwardSlashes(fileName);
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
|
||||
var sourceFile = getCurrentSourceFile(fileName);
|
||||
var options = copyFormatCodeOptions(options)
|
||||
@@ -5151,7 +5246,7 @@ module ts {
|
||||
}
|
||||
|
||||
function getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[] {
|
||||
fileName = TypeScript.switchToForwardSlashes(fileName);
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
|
||||
var sourceFile = getCurrentSourceFile(fileName);
|
||||
var options = copyFormatCodeOptions(options);
|
||||
@@ -5338,7 +5433,7 @@ module ts {
|
||||
function getRenameInfo(fileName: string, position: number): RenameInfo {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = TypeScript.switchToForwardSlashes(fileName);
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
var sourceFile = getSourceFile(fileName);
|
||||
|
||||
var node = getTouchingWord(sourceFile, position);
|
||||
@@ -5477,7 +5572,6 @@ module ts {
|
||||
|
||||
function getClassificationsForLine(text: string, lexState: EndOfLineState): ClassificationResult {
|
||||
var offset = 0;
|
||||
var lastTokenOrCommentEnd = 0;
|
||||
var token = SyntaxKind.Unknown;
|
||||
var lastNonTriviaToken = SyntaxKind.Unknown;
|
||||
|
||||
|
||||
+36
-16
@@ -16,7 +16,6 @@
|
||||
/// <reference path='services.ts' />
|
||||
|
||||
/// <reference path='compiler\pathUtils.ts' />
|
||||
/// <reference path='compiler\precompile.ts' />
|
||||
|
||||
var debugObjectHost = (<any>this);
|
||||
|
||||
@@ -55,6 +54,17 @@ module ts {
|
||||
getDefaultLibFilename(): string;
|
||||
}
|
||||
|
||||
///
|
||||
/// Pre-processing
|
||||
///
|
||||
// Note: This is being using by the host (VS) and is marshaled back and forth.
|
||||
// When changing this make sure the changes are reflected in the managed side as well
|
||||
export interface IFileReference {
|
||||
path: string;
|
||||
position: number;
|
||||
length: number;
|
||||
}
|
||||
|
||||
/** Public interface of a language service instance shim. */
|
||||
export interface ShimFactory {
|
||||
registerShim(shim: Shim): void;
|
||||
@@ -507,17 +517,6 @@ module ts {
|
||||
};
|
||||
}
|
||||
|
||||
private realizeDiagnosticWithFileName(diagnostic: Diagnostic): { fileName: string; message: string; start: number; length: number; category: string; } {
|
||||
return {
|
||||
fileName: diagnostic.file.filename,
|
||||
message: diagnostic.messageText,
|
||||
start: diagnostic.start,
|
||||
length: diagnostic.length,
|
||||
/// TODO: no need for the tolowerCase call
|
||||
category: DiagnosticCategory[diagnostic.category].toLowerCase()
|
||||
};
|
||||
}
|
||||
|
||||
public getSyntacticClassifications(fileName: string, start: number, length: number): string {
|
||||
return this.forwardJSONCall(
|
||||
"getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")",
|
||||
@@ -559,7 +558,7 @@ module ts {
|
||||
"getCompilerOptionsDiagnostics()",
|
||||
() => {
|
||||
var errors = this.languageService.getCompilerOptionsDiagnostics();
|
||||
return errors.map(d => this.realizeDiagnosticWithFileName(d))
|
||||
return errors.map(LanguageServiceShimObject.realizeDiagnostic)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -846,12 +845,33 @@ module ts {
|
||||
return forwardJSONCall(this.logger, actionDescription, action);
|
||||
}
|
||||
|
||||
public getPreProcessedFileInfo(fileName: string, sourceText: TypeScript.IScriptSnapshot): string {
|
||||
public getPreProcessedFileInfo(fileName: string, sourceTextSnapshot: TypeScript.IScriptSnapshot): string {
|
||||
return this.forwardJSONCall(
|
||||
"getPreProcessedFileInfo('" + fileName + "')",
|
||||
() => {
|
||||
var result = TypeScript.preProcessFile(fileName, sourceText);
|
||||
return result;
|
||||
var result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()));
|
||||
var convertResult = {
|
||||
referencedFiles: <IFileReference[]>[],
|
||||
importedFiles: <IFileReference[]>[],
|
||||
isLibFile: result.isLibFile
|
||||
};
|
||||
|
||||
forEach(result.referencedFiles, refFile => {
|
||||
convertResult.referencedFiles.push({
|
||||
path: switchToForwardSlashes(normalizePath(refFile.filename)),
|
||||
position: refFile.pos,
|
||||
length: refFile.end - refFile.pos
|
||||
});
|
||||
});
|
||||
|
||||
forEach(result.importedFiles, importedFile => {
|
||||
convertResult.importedFiles.push({
|
||||
path: switchToForwardSlashes(importedFile.filename),
|
||||
position: importedFile.pos,
|
||||
length: importedFile.end - importedFile.pos
|
||||
});
|
||||
});
|
||||
return convertResult;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -394,7 +394,7 @@ module ts.formatting {
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.Method:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
return !(<FunctionDeclaration>n).body || isCompletedNode((<FunctionDeclaration>n).body, sourceFile);
|
||||
return !(<FunctionLikeDeclaration>n).body || isCompletedNode((<FunctionLikeDeclaration>n).body, sourceFile);
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return (<ModuleDeclaration>n).body && isCompletedNode((<ModuleDeclaration>n).body, sourceFile);
|
||||
case SyntaxKind.IfStatement:
|
||||
|
||||
@@ -620,8 +620,9 @@ var TypeScript;
|
||||
SyntaxKind[SyntaxKind["Parameter"] = 208] = "Parameter";
|
||||
SyntaxKind[SyntaxKind["EnumElement"] = 209] = "EnumElement";
|
||||
SyntaxKind[SyntaxKind["TypeAnnotation"] = 210] = "TypeAnnotation";
|
||||
SyntaxKind[SyntaxKind["ExternalModuleReference"] = 211] = "ExternalModuleReference";
|
||||
SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 212] = "ModuleNameModuleReference";
|
||||
SyntaxKind[SyntaxKind["ComputedPropertyName"] = 211] = "ComputedPropertyName";
|
||||
SyntaxKind[SyntaxKind["ExternalModuleReference"] = 212] = "ExternalModuleReference";
|
||||
SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 213] = "ModuleNameModuleReference";
|
||||
SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword";
|
||||
SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword";
|
||||
SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword";
|
||||
@@ -1040,7 +1041,7 @@ var definitions = [
|
||||
name: 'VariableDeclaratorSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
children: [
|
||||
{ name: 'propertyName', isToken: true },
|
||||
{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
{ name: 'typeAnnotation', type: 'TypeAnnotationSyntax', isOptional: true, isTypeScriptSpecific: true },
|
||||
{ name: 'equalsValueClause', type: 'EqualsValueClauseSyntax', isOptional: true }
|
||||
]
|
||||
@@ -1376,7 +1377,7 @@ var definitions = [
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['ITypeMemberSyntax'],
|
||||
children: [
|
||||
{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
{ name: 'questionToken', isToken: true, isOptional: true, itTypeScriptSpecific: true },
|
||||
{ name: 'callSignature', type: 'CallSignatureSyntax' }
|
||||
]
|
||||
@@ -1398,7 +1399,7 @@ var definitions = [
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['ITypeMemberSyntax'],
|
||||
children: [
|
||||
{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
{ name: 'questionToken', isToken: true, isOptional: true },
|
||||
{ name: 'typeAnnotation', type: 'TypeAnnotationSyntax', isOptional: true }
|
||||
],
|
||||
@@ -1500,7 +1501,7 @@ var definitions = [
|
||||
interfaces: ['IMemberDeclarationSyntax'],
|
||||
children: [
|
||||
{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
{ name: 'block', type: 'BlockSyntax', isOptional: true },
|
||||
{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
@@ -1514,7 +1515,7 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken', isTypeScriptSpecific: true },
|
||||
{ name: 'getKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
{ name: 'block', type: 'BlockSyntax' }
|
||||
]
|
||||
@@ -1526,7 +1527,7 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken', isTypeScriptSpecific: true },
|
||||
{ name: 'setKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
{ name: 'block', type: 'BlockSyntax' }
|
||||
],
|
||||
@@ -1713,7 +1714,7 @@ var definitions = [
|
||||
name: 'EnumElementSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
children: [
|
||||
{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
{ name: 'equalsValueClause', type: 'EqualsValueClauseSyntax', isOptional: true }
|
||||
]
|
||||
},
|
||||
@@ -1739,12 +1740,22 @@ var definitions = [
|
||||
{ name: 'closeBraceToken', isToken: true, excludeFromAST: true }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'ComputedPropertyNameSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['IPropertyNameSyntax'],
|
||||
children: [
|
||||
{ name: 'openBracketToken', isToken: true },
|
||||
{ name: 'expression', type: 'IExpressionSyntax' },
|
||||
{ name: 'closeBracketToken', isToken: true }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'SimplePropertyAssignmentSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['IPropertyAssignmentSyntax'],
|
||||
children: [
|
||||
{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
{ name: 'colonToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'expression', type: 'IExpressionSyntax' }
|
||||
]
|
||||
@@ -1754,7 +1765,7 @@ var definitions = [
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['IPropertyAssignmentSyntax'],
|
||||
children: [
|
||||
{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
{ name: 'block', type: 'BlockSyntax' }
|
||||
]
|
||||
|
||||
File diff suppressed because one or more lines are too long
+238
-157
@@ -1005,7 +1005,7 @@ module TypeScript.Parser {
|
||||
return true;
|
||||
}
|
||||
|
||||
return isPropertyName(currentToken(), inErrorRecovery);
|
||||
return isPropertyName(/*peekToken:*/ 0, inErrorRecovery);
|
||||
}
|
||||
|
||||
function tryParseEnumElementEqualsValueClause(): EqualsValueClauseSyntax {
|
||||
@@ -1019,11 +1019,11 @@ module TypeScript.Parser {
|
||||
return <EnumElementSyntax>node;
|
||||
}
|
||||
|
||||
if (!isPropertyName(currentToken(), inErrorRecovery)) {
|
||||
if (!isPropertyName(/*peekToken:*/ 0, inErrorRecovery)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return new EnumElementSyntax(parseNodeData, eatPropertyName(), tryParseEnumElementEqualsValueClause());
|
||||
return new EnumElementSyntax(parseNodeData, parsePropertyName(), tryParseEnumElementEqualsValueClause());
|
||||
}
|
||||
|
||||
function isModifierKind(kind: SyntaxKind): boolean {
|
||||
@@ -1131,7 +1131,7 @@ module TypeScript.Parser {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isPropertyName(peekToken(modifierCount + 1), inErrorRecovery);
|
||||
return isPropertyName(/*peekIndex:*/ modifierCount + 1, inErrorRecovery);
|
||||
}
|
||||
|
||||
function parseAccessor(checkForStrictMode: boolean): IAccessorSyntax {
|
||||
@@ -1152,14 +1152,14 @@ module TypeScript.Parser {
|
||||
|
||||
function parseGetMemberAccessorDeclaration(modifiers: ISyntaxToken[], getKeyword: ISyntaxToken, checkForStrictMode: boolean): GetAccessorSyntax {
|
||||
return new GetAccessorSyntax(parseNodeData,
|
||||
modifiers, consumeToken(getKeyword), eatPropertyName(),
|
||||
modifiers, consumeToken(getKeyword), parsePropertyName(),
|
||||
parseCallSignature(/*requireCompleteTypeParameterList:*/ false),
|
||||
parseBlock(/*parseStatementsEvenWithNoOpenBrace:*/ false, checkForStrictMode));
|
||||
}
|
||||
|
||||
function parseSetMemberAccessorDeclaration(modifiers: ISyntaxToken[], setKeyword: ISyntaxToken, checkForStrictMode: boolean): SetAccessorSyntax {
|
||||
return new SetAccessorSyntax(parseNodeData,
|
||||
modifiers, consumeToken(setKeyword), eatPropertyName(),
|
||||
modifiers, consumeToken(setKeyword), parsePropertyName(),
|
||||
parseCallSignature(/*requireCompleteTypeParameterList:*/ false),
|
||||
parseBlock(/*parseStatementsEvenWithNoOpenBrace:*/ false, checkForStrictMode));
|
||||
}
|
||||
@@ -1173,10 +1173,48 @@ module TypeScript.Parser {
|
||||
// checks for a subset of the conditions of the previous two calls.
|
||||
var _modifierCount = modifierCount();
|
||||
return isConstructorDeclaration(_modifierCount) ||
|
||||
isMemberFunctionDeclaration(_modifierCount, inErrorRecovery) ||
|
||||
isAccessor(_modifierCount, inErrorRecovery) ||
|
||||
isMemberVariableDeclaration(_modifierCount, inErrorRecovery) ||
|
||||
isIndexMemberDeclaration(_modifierCount);
|
||||
isIndexMemberDeclaration(_modifierCount) ||
|
||||
isMemberVariableOrFunctionDeclaration(_modifierCount, inErrorRecovery);
|
||||
}
|
||||
|
||||
function isMemberVariableOrFunctionDeclaration(peekIndex: number, inErrorRecovery: boolean) {
|
||||
// Check if its the start of a property or method. Both must start with a property name.
|
||||
if (!isPropertyName(peekIndex, inErrorRecovery)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SyntaxFacts.isAnyKeyword(peekToken(peekIndex).kind)) {
|
||||
// It wasn't a keyword. So this is definitely a member variable or function.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Keywords *can* technically start properties and methods. However, they often
|
||||
// are actually intended to start a real ts/js construct. Only accept a keyword
|
||||
// if it is definitely a property or method.
|
||||
// keywords are also property names. Only accept a keyword as a property
|
||||
// name if is of the form:
|
||||
// public;
|
||||
// public=
|
||||
// public:
|
||||
// public }
|
||||
// public(
|
||||
// public<
|
||||
// public <eof>
|
||||
// public <newline>
|
||||
var nextToken = peekToken(peekIndex + 1);
|
||||
switch (nextToken.kind) {
|
||||
case SyntaxKind.SemicolonToken:
|
||||
case SyntaxKind.EqualsToken:
|
||||
case SyntaxKind.ColonToken:
|
||||
case SyntaxKind.CloseBraceToken:
|
||||
case SyntaxKind.OpenParenToken:
|
||||
case SyntaxKind.LessThanToken:
|
||||
case SyntaxKind.EndOfFileToken:
|
||||
return true;
|
||||
default:
|
||||
return previousTokenHasTrailingNewLine(nextToken);
|
||||
}
|
||||
}
|
||||
|
||||
function tryParseClassElement(inErrorRecovery: boolean): IClassElementSyntax {
|
||||
@@ -1186,21 +1224,28 @@ module TypeScript.Parser {
|
||||
return <IClassElementSyntax>node;
|
||||
}
|
||||
|
||||
// Have to check for indexers before anything else. That way if we see "[foo:" we
|
||||
// parse it out as an indexer and not a member function or variable.
|
||||
var _modifierCount = modifierCount();
|
||||
if (isConstructorDeclaration(_modifierCount)) {
|
||||
return parseConstructorDeclaration();
|
||||
}
|
||||
else if (isMemberFunctionDeclaration(_modifierCount, inErrorRecovery)) {
|
||||
return parseMemberFunctionDeclaration();
|
||||
else if (isIndexMemberDeclaration(_modifierCount)) {
|
||||
return parseIndexMemberDeclaration();
|
||||
}
|
||||
else if (isAccessor(_modifierCount, inErrorRecovery)) {
|
||||
return parseAccessor(/*checkForStrictMode:*/ false);
|
||||
}
|
||||
else if (isMemberVariableDeclaration(_modifierCount, inErrorRecovery)) {
|
||||
return parseMemberVariableDeclaration();
|
||||
}
|
||||
else if (isIndexMemberDeclaration(_modifierCount)) {
|
||||
return parseIndexMemberDeclaration();
|
||||
else if (isMemberVariableOrFunctionDeclaration(/*peekIndex:*/ _modifierCount, inErrorRecovery)) {
|
||||
var modifiers = parseModifiers();
|
||||
var propertyName = parsePropertyName();
|
||||
|
||||
if (isCallSignature(/*peekIndex:*/ 0)) {
|
||||
return parseMemberFunctionDeclaration(modifiers, propertyName);
|
||||
}
|
||||
else {
|
||||
return parseMemberVariableDeclaration(modifiers, propertyName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
@@ -1233,13 +1278,7 @@ module TypeScript.Parser {
|
||||
return new ConstructorDeclarationSyntax(parseNodeData, modifiers, constructorKeyword, callSignature, block, semicolonToken);
|
||||
}
|
||||
|
||||
function isMemberFunctionDeclaration(modifierCount: number, inErrorRecovery: boolean): boolean {
|
||||
return isPropertyName(peekToken(modifierCount), inErrorRecovery) && isCallSignature(modifierCount + 1);
|
||||
}
|
||||
|
||||
function parseMemberFunctionDeclaration(): MemberFunctionDeclarationSyntax {
|
||||
var modifiers = parseModifiers();
|
||||
var propertyName = eatPropertyName();
|
||||
function parseMemberFunctionDeclaration(modifiers: ISyntaxToken[], propertyName: IPropertyNameSyntax): MemberFunctionDeclarationSyntax {
|
||||
var callSignature = parseCallSignature(/*requireCompleteTypeParameterList:*/ false);
|
||||
|
||||
// If we got an errant => then we want to parse what's coming up without requiring an
|
||||
@@ -1259,42 +1298,13 @@ module TypeScript.Parser {
|
||||
return new MemberFunctionDeclarationSyntax(parseNodeData, modifiers, propertyName, callSignature, block, semicolon);
|
||||
}
|
||||
|
||||
function isDefinitelyMemberVariablePropertyName(index: number): boolean {
|
||||
// keywords are also property names. Only accept a keyword as a property
|
||||
// name if is of the form:
|
||||
// public;
|
||||
// public=
|
||||
// public:
|
||||
// public }
|
||||
// public <eof>
|
||||
// public <newline>
|
||||
if (SyntaxFacts.isAnyKeyword(peekToken(index).kind)) {
|
||||
var nextToken = peekToken(index + 1);
|
||||
switch (nextToken.kind) {
|
||||
case SyntaxKind.SemicolonToken:
|
||||
case SyntaxKind.EqualsToken:
|
||||
case SyntaxKind.ColonToken:
|
||||
case SyntaxKind.CloseBraceToken:
|
||||
case SyntaxKind.EndOfFileToken:
|
||||
return true;
|
||||
default:
|
||||
return previousTokenHasTrailingNewLine(nextToken);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// If was a property name and not a keyword, then we're good to go.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function isMemberVariableDeclaration(modifierCount: number, inErrorRecover: boolean): boolean {
|
||||
return isPropertyName(peekToken(modifierCount), inErrorRecover) && isDefinitelyMemberVariablePropertyName(modifierCount);
|
||||
}
|
||||
|
||||
function parseMemberVariableDeclaration(): MemberVariableDeclarationSyntax {
|
||||
function parseMemberVariableDeclaration(modifiers: ISyntaxToken[], propertyName: IPropertyNameSyntax): MemberVariableDeclarationSyntax {
|
||||
return new MemberVariableDeclarationSyntax(parseNodeData,
|
||||
parseModifiers(),
|
||||
tryParseVariableDeclarator(/*allowIn:*/ true, /*allowPropertyName:*/ true), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false));
|
||||
modifiers,
|
||||
new VariableDeclaratorSyntax(parseNodeData, propertyName,
|
||||
parseOptionalTypeAnnotation(/*allowStringLiteral:*/ false),
|
||||
isEqualsValueClause(/*inParameter*/ false) ? parseEqualsValueClause(/*allowIn:*/ true) : undefined),
|
||||
eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false));
|
||||
}
|
||||
|
||||
function isIndexMemberDeclaration(modifierCount: number): boolean {
|
||||
@@ -1429,8 +1439,36 @@ module TypeScript.Parser {
|
||||
return isCallSignature(/*tokenIndex:*/ 0) ||
|
||||
isConstructSignature() ||
|
||||
isIndexSignature(/*tokenIndex:*/ 0) ||
|
||||
isMethodSignature(inErrorRecovery) ||
|
||||
isPropertySignature(inErrorRecovery);
|
||||
isMethodOrPropertySignature(inErrorRecovery);
|
||||
}
|
||||
|
||||
function isMethodOrPropertySignature(inErrorRecovery: boolean): boolean {
|
||||
var _currentToken = currentToken();
|
||||
|
||||
// Keywords can start properties. However, they're often intended to start something
|
||||
// else. If we see a modifier before something that can be a property, then don't
|
||||
// try parse it out as a property. For example, if we have:
|
||||
//
|
||||
// public foo
|
||||
//
|
||||
// Then don't parse 'public' as a property name. Note: if you have:
|
||||
//
|
||||
// public
|
||||
// foo
|
||||
//
|
||||
// Then we *should* parse it as a property name, as ASI takes effect here.
|
||||
if (isModifier(_currentToken, /*index:*/ 0)) {
|
||||
var token1 = peekToken(1);
|
||||
if (!existsNewLineBetweenTokens(_currentToken, token1, source.text) &&
|
||||
isPropertyNameToken(token1, inErrorRecovery)) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Note: property names also start function signatures. So it's important that we call this
|
||||
// after we calll isFunctionSignature.
|
||||
return isPropertyName(/*peekIndex:*/ 0, inErrorRecovery);
|
||||
}
|
||||
|
||||
function tryParseTypeMember(inErrorRecovery: boolean): ITypeMemberSyntax {
|
||||
@@ -1449,13 +1487,16 @@ module TypeScript.Parser {
|
||||
else if (isIndexSignature(/*tokenIndex:*/ 0)) {
|
||||
return parseIndexSignature();
|
||||
}
|
||||
else if (isMethodSignature(inErrorRecovery)) {
|
||||
// Note: it is important that isFunctionSignature is called before isPropertySignature.
|
||||
// isPropertySignature checks for a subset of isFunctionSignature.
|
||||
return parseMethodSignature();
|
||||
}
|
||||
else if (isPropertySignature(inErrorRecovery)) {
|
||||
return parsePropertySignature();
|
||||
else if (isMethodOrPropertySignature(inErrorRecovery)) {
|
||||
var propertyName = parsePropertyName();
|
||||
var questionToken = tryEatToken(SyntaxKind.QuestionToken);
|
||||
|
||||
if (isCallSignature(/*peekIndex:*/ 0)) {
|
||||
return parseMethodSignature(propertyName, questionToken);
|
||||
}
|
||||
else {
|
||||
return parsePropertySignature(propertyName, questionToken);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
@@ -1477,14 +1518,14 @@ module TypeScript.Parser {
|
||||
openBracketToken, parameters, eatToken(SyntaxKind.CloseBracketToken), parseOptionalTypeAnnotation(/*allowStringLiteral:*/ false));
|
||||
}
|
||||
|
||||
function parseMethodSignature(): MethodSignatureSyntax {
|
||||
function parseMethodSignature(propertyName: IPropertyNameSyntax, questionToken: ISyntaxToken): MethodSignatureSyntax {
|
||||
return new MethodSignatureSyntax(parseNodeData,
|
||||
eatPropertyName(), tryEatToken(SyntaxKind.QuestionToken), parseCallSignature(/*requireCompleteTypeParameterList:*/ false));
|
||||
propertyName, questionToken, parseCallSignature(/*requireCompleteTypeParameterList:*/ false));
|
||||
}
|
||||
|
||||
function parsePropertySignature(): PropertySignatureSyntax {
|
||||
function parsePropertySignature(propertyName: IPropertyNameSyntax, questionToken: ISyntaxToken): PropertySignatureSyntax {
|
||||
return new PropertySignatureSyntax(parseNodeData,
|
||||
eatPropertyName(), tryEatToken(SyntaxKind.QuestionToken), parseOptionalTypeAnnotation(/*allowStringLiteral:*/ false));
|
||||
propertyName, questionToken, parseOptionalTypeAnnotation(/*allowStringLiteral:*/ false));
|
||||
}
|
||||
|
||||
function isCallSignature(peekIndex: number): boolean {
|
||||
@@ -1501,54 +1542,36 @@ module TypeScript.Parser {
|
||||
}
|
||||
|
||||
function isIndexSignature(peekIndex: number): boolean {
|
||||
return peekToken(peekIndex).kind === SyntaxKind.OpenBracketToken;
|
||||
}
|
||||
|
||||
function isMethodSignature(inErrorRecovery: boolean): boolean {
|
||||
if (isPropertyName(currentToken(), inErrorRecovery)) {
|
||||
// id(
|
||||
if (isCallSignature(1)) {
|
||||
// In order to be considered an index signature, we need to see at least:
|
||||
//
|
||||
// [a:
|
||||
// [...
|
||||
// [a,
|
||||
// [public a
|
||||
// []
|
||||
//
|
||||
// Otherwise, we will think that this is the start of a computed property name
|
||||
// for a function or variable.
|
||||
if (peekToken(peekIndex).kind === SyntaxKind.OpenBracketToken) {
|
||||
var token1 = peekToken(peekIndex + 1);
|
||||
if (token1.kind === SyntaxKind.DotDotDotToken || token1.kind === SyntaxKind.CloseBracketToken) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// id?(
|
||||
if (peekToken(1).kind === SyntaxKind.QuestionToken &&
|
||||
isCallSignature(2)) {
|
||||
return true;
|
||||
if (isIdentifier(token1)) {
|
||||
var token2 = peekToken(peekIndex + 2);
|
||||
if (token2.kind === SyntaxKind.ColonToken || token2.kind === SyntaxKind.CommaToken) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (token1.kind === SyntaxKind.PublicKeyword || token1.kind === SyntaxKind.PrivateKeyword) {
|
||||
var token2 = peekToken(peekIndex + 2);
|
||||
return isIdentifier(token2);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isPropertySignature(inErrorRecovery: boolean): boolean {
|
||||
var _currentToken = currentToken();
|
||||
|
||||
// Keywords can start properties. However, they're often intended to start something
|
||||
// else. If we see a modifier before something that can be a property, then don't
|
||||
// try parse it out as a property. For example, if we have:
|
||||
//
|
||||
// public foo
|
||||
//
|
||||
// Then don't parse 'public' as a property name. Note: if you have:
|
||||
//
|
||||
// public
|
||||
// foo
|
||||
//
|
||||
// Then we *should* parse it as a property name, as ASI takes effect here.
|
||||
if (isModifier(_currentToken, /*index:*/ 0)) {
|
||||
if (!existsNewLineBetweenTokens(_currentToken, peekToken(1), source.text) &&
|
||||
isPropertyName(peekToken(1), inErrorRecovery)) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Note: property names also start function signatures. So it's important that we call this
|
||||
// after we calll isFunctionSignature.
|
||||
return isPropertyName(_currentToken, inErrorRecovery);
|
||||
}
|
||||
|
||||
function isHeritageClause(): boolean {
|
||||
var tokenKind = currentToken().kind;
|
||||
return tokenKind === SyntaxKind.ExtendsKeyword || tokenKind === SyntaxKind.ImplementsKeyword;
|
||||
@@ -1986,7 +2009,17 @@ module TypeScript.Parser {
|
||||
|
||||
consumeToken(switchKeyword);
|
||||
var openParenToken = eatToken(SyntaxKind.OpenParenToken);
|
||||
var expression = parseExpression(/*allowIn:*/ true);
|
||||
var expression: IExpressionSyntax;
|
||||
|
||||
// if we have "switch {"
|
||||
// then don't try to consume the { as the start of an expression.
|
||||
if (openParenToken.fullWidth() === 0 && currentToken().kind === SyntaxKind.OpenBraceToken) {
|
||||
expression = eatIdentifierToken();
|
||||
}
|
||||
else {
|
||||
expression = parseExpression(/*allowIn:*/ true);
|
||||
}
|
||||
|
||||
var closeParenToken = eatToken(SyntaxKind.CloseParenToken);
|
||||
var openBraceToken = eatToken(SyntaxKind.OpenBraceToken);
|
||||
|
||||
@@ -2258,7 +2291,7 @@ module TypeScript.Parser {
|
||||
return variableDeclarator.equalsValueClause === undefined;
|
||||
}
|
||||
|
||||
function tryParseVariableDeclarator(allowIn: boolean, allowPropertyName: boolean): VariableDeclaratorSyntax {
|
||||
function tryParseVariableDeclarator(allowIn: boolean): VariableDeclaratorSyntax {
|
||||
// TODO(cyrusn): What if the 'allowIn' context has changed between when we last parsed
|
||||
// and now? We could end up with an incorrect tree. For example, say we had in the old
|
||||
// tree "var i = a in b". Then, in the new tree the declarator portion moved into:
|
||||
@@ -2271,19 +2304,15 @@ module TypeScript.Parser {
|
||||
return <VariableDeclaratorSyntax>node;
|
||||
}
|
||||
|
||||
if (allowPropertyName) {
|
||||
// Debug.assert(isPropertyName(currentToken(), /*inErrorRecovery:*/ false));
|
||||
}
|
||||
|
||||
if (!allowPropertyName && !isIdentifier(currentToken())) {
|
||||
if (!isIdentifier(currentToken())) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var propertyName = allowPropertyName ? eatPropertyName() : eatIdentifierToken();
|
||||
var propertyName = eatIdentifierToken();
|
||||
var equalsValueClause: EqualsValueClauseSyntax = undefined;
|
||||
var typeAnnotation: TypeAnnotationSyntax = undefined;
|
||||
|
||||
if (propertyName.fullWidth() > 0) {
|
||||
if (fullWidth(propertyName) > 0) {
|
||||
typeAnnotation = parseOptionalTypeAnnotation(/*allowStringLiteral:*/ false);
|
||||
|
||||
if (isEqualsValueClause(/*inParameter*/ false)) {
|
||||
@@ -3309,51 +3338,73 @@ module TypeScript.Parser {
|
||||
if (isAccessor(modifierCount(), inErrorRecovery)) {
|
||||
return parseAccessor(/*checkForStrictMode:*/ true);
|
||||
}
|
||||
else if (isFunctionPropertyAssignment(inErrorRecovery)) {
|
||||
return parseFunctionPropertyAssignment();
|
||||
|
||||
// Note: we don't want to call parsePropertyName here yet as it will convert a keyword
|
||||
// to an identifier name. We don't want to do that yet as a keyword is not legal as a
|
||||
// shorthand property assignment.
|
||||
|
||||
var _currentToken = currentToken();
|
||||
if (isIdentifier(_currentToken)) {
|
||||
var token1 = peekToken(1);
|
||||
if (token1.kind !== SyntaxKind.ColonToken &&
|
||||
token1.kind !== SyntaxKind.OpenParenToken &&
|
||||
token1.kind !== SyntaxKind.LessThanToken) {
|
||||
|
||||
// If we don't have one of:
|
||||
//
|
||||
// id:
|
||||
// id(
|
||||
// id<
|
||||
//
|
||||
// then this is a shorthand property assignment. Just return the identifier
|
||||
// token as is.
|
||||
return consumeToken(_currentToken);
|
||||
}
|
||||
}
|
||||
else if (isSimplePropertyAssignment(inErrorRecovery)) {
|
||||
return parseSimplePropertyAssignment();
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
|
||||
// All the rest of the property assignments start with property names. They are:
|
||||
// id: e
|
||||
// [e1]: e2
|
||||
// id() { }
|
||||
// [e]() { }
|
||||
if (isPropertyName(/*peekIndex:*/ 0, inErrorRecovery)) {
|
||||
var propertyName = parsePropertyName();
|
||||
|
||||
if (isCallSignature(/*peekIndex:*/ 0)) {
|
||||
return parseFunctionPropertyAssignment(propertyName);
|
||||
}
|
||||
else {
|
||||
// If we didn't have an identifier, then we must have gotten a keyword or a
|
||||
// literal. Neither of these are allowed in a shorthand property, so this must
|
||||
// be a simple property assignment.
|
||||
//
|
||||
// Also, if we have an identifier and it is followed by a colon then this is
|
||||
// definitely a simple property assignment.
|
||||
return new SimplePropertyAssignmentSyntax(parseNodeData,
|
||||
propertyName, eatToken(SyntaxKind.ColonToken), tryParseAssignmentExpressionOrHigher(/*force:*/ true, /*allowIn:*/ true));
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function isPropertyAssignment(inErrorRecovery: boolean): boolean {
|
||||
return isAccessor(modifierCount(), inErrorRecovery) ||
|
||||
isFunctionPropertyAssignment(inErrorRecovery) ||
|
||||
isSimplePropertyAssignment(inErrorRecovery);
|
||||
isPropertyName(/*peekIndex:*/ 0, inErrorRecovery);
|
||||
}
|
||||
|
||||
function eatPropertyName(): ISyntaxToken {
|
||||
var _currentToken = currentToken();
|
||||
return SyntaxFacts.isIdentifierNameOrAnyKeyword(_currentToken)
|
||||
? eatIdentifierNameToken()
|
||||
: consumeToken(_currentToken);
|
||||
function isPropertyName(peekIndex: number, inErrorRecovery: boolean): boolean {
|
||||
var token = peekToken(peekIndex);
|
||||
if (token.kind === SyntaxKind.OpenBracketToken) {
|
||||
// A '[' only starts a property name as long as we're sure it doesn't start an
|
||||
// index signature.
|
||||
return !isIndexSignature(peekIndex);
|
||||
}
|
||||
|
||||
return isPropertyNameToken(token, inErrorRecovery);
|
||||
}
|
||||
|
||||
function isFunctionPropertyAssignment(inErrorRecovery: boolean): boolean {
|
||||
return isPropertyName(currentToken(), inErrorRecovery) &&
|
||||
isCallSignature(/*peekIndex:*/ 1);
|
||||
}
|
||||
|
||||
function parseFunctionPropertyAssignment(): FunctionPropertyAssignmentSyntax {
|
||||
return new FunctionPropertyAssignmentSyntax(parseNodeData,
|
||||
eatPropertyName(), parseCallSignature(/*requireCompleteTypeParameterList:*/ false),
|
||||
parseBlock(/*parseBlockEvenWithNoOpenBrace:*/ false, /*checkForStrictMode:*/ true));
|
||||
}
|
||||
|
||||
function isSimplePropertyAssignment(inErrorRecovery: boolean): boolean {
|
||||
return isPropertyName(currentToken(), inErrorRecovery);
|
||||
}
|
||||
|
||||
function parseSimplePropertyAssignment(): SimplePropertyAssignmentSyntax {
|
||||
return new SimplePropertyAssignmentSyntax(parseNodeData,
|
||||
eatPropertyName(), eatToken(SyntaxKind.ColonToken), tryParseAssignmentExpressionOrHigher(/*force:*/ true, /*allowIn:*/ true));
|
||||
}
|
||||
|
||||
function isPropertyName(token: ISyntaxToken, inErrorRecovery: boolean): boolean {
|
||||
function isPropertyNameToken(token: ISyntaxToken, inErrorRecovery: boolean): boolean {
|
||||
// NOTE: we do *not* want to check "isIdentifier" here. Any IdentifierName is
|
||||
// allowed here, even reserved words like keywords.
|
||||
if (SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) {
|
||||
@@ -3372,12 +3423,42 @@ module TypeScript.Parser {
|
||||
}
|
||||
}
|
||||
|
||||
return isLiteralPropertyName(token);
|
||||
}
|
||||
|
||||
function isLiteralPropertyName(token: ISyntaxToken): boolean {
|
||||
// We allow a template literal while parser for error tolerance. We'll report errors
|
||||
// on this later in the grammar checker walker.
|
||||
var kind = token.kind;
|
||||
return kind === SyntaxKind.StringLiteral || kind === SyntaxKind.NumericLiteral || kind === SyntaxKind.NoSubstitutionTemplateToken;
|
||||
}
|
||||
|
||||
function parsePropertyName(): IPropertyNameSyntax {
|
||||
var _currentToken = currentToken();
|
||||
if (_currentToken.kind === SyntaxKind.OpenBracketToken) {
|
||||
return parseComputedPropertyName(_currentToken);
|
||||
}
|
||||
else if (SyntaxFacts.isIdentifierNameOrAnyKeyword(_currentToken)) {
|
||||
// If it was a keyword, convert it to an identifier name.
|
||||
return eatIdentifierNameToken();
|
||||
}
|
||||
else {
|
||||
// Must have been a literal.
|
||||
return consumeToken(_currentToken);
|
||||
}
|
||||
}
|
||||
|
||||
function parseComputedPropertyName(openBracketToken: ISyntaxToken): ComputedPropertyNameSyntax {
|
||||
return new ComputedPropertyNameSyntax(parseNodeData,
|
||||
consumeToken(openBracketToken), tryParseAssignmentExpressionOrHigher(/*force:*/ true, /*allowIn:*/ true), eatToken(SyntaxKind.CloseBracketToken));
|
||||
}
|
||||
|
||||
function parseFunctionPropertyAssignment(propertyName: IPropertyNameSyntax): FunctionPropertyAssignmentSyntax {
|
||||
return new FunctionPropertyAssignmentSyntax(parseNodeData,
|
||||
propertyName, parseCallSignature(/*requireCompleteTypeParameterList:*/ false),
|
||||
parseBlock(/*parseBlockEvenWithNoOpenBrace:*/ false, /*checkForStrictMode:*/ true));
|
||||
}
|
||||
|
||||
function parseArrayLiteralExpression(openBracketToken: ISyntaxToken): ArrayLiteralExpressionSyntax {
|
||||
// Debug.assert(currentToken().kind === SyntaxKind.OpenBracketToken);
|
||||
consumeToken(openBracketToken);
|
||||
@@ -4339,8 +4420,8 @@ module TypeScript.Parser {
|
||||
case ListParsingState.ObjectType_TypeMembers: return tryParseTypeMember(inErrorRecovery);
|
||||
case ListParsingState.ClassOrInterfaceDeclaration_HeritageClauses: return tryParseHeritageClause();
|
||||
case ListParsingState.HeritageClause_TypeNameList: return tryParseHeritageClauseTypeName();
|
||||
case ListParsingState.VariableDeclaration_VariableDeclarators_AllowIn: return tryParseVariableDeclarator(/*allowIn:*/ true, /*allowIdentifierName:*/ false);
|
||||
case ListParsingState.VariableDeclaration_VariableDeclarators_DisallowIn: return tryParseVariableDeclarator(/*allowIn:*/ false, /*allowIdentifierName:*/ false);
|
||||
case ListParsingState.VariableDeclaration_VariableDeclarators_AllowIn: return tryParseVariableDeclarator(/*allowIn:*/ true);
|
||||
case ListParsingState.VariableDeclaration_VariableDeclarators_DisallowIn: return tryParseVariableDeclarator(/*allowIn:*/ false);
|
||||
case ListParsingState.ArgumentList_AssignmentExpressions: return tryParseArgumentListExpression();
|
||||
case ListParsingState.ObjectLiteralExpression_PropertyAssignments: return tryParsePropertyAssignment(inErrorRecovery);
|
||||
case ListParsingState.ArrayLiteralExpression_AssignmentExpressions: return tryParseAssignmentOrOmittedExpression();
|
||||
|
||||
@@ -353,7 +353,7 @@ module TypeScript.PrettyPrinter {
|
||||
}
|
||||
|
||||
public visitVariableDeclarator(node: VariableDeclaratorSyntax): void {
|
||||
this.appendToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
this.appendNode(node.equalsValueClause);
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ module TypeScript.PrettyPrinter {
|
||||
}
|
||||
|
||||
public visitMethodSignature(node: MethodSignatureSyntax): void {
|
||||
this.appendToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
this.appendToken(node.questionToken);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
}
|
||||
@@ -592,7 +592,7 @@ module TypeScript.PrettyPrinter {
|
||||
}
|
||||
|
||||
public visitPropertySignature(node: PropertySignatureSyntax): void {
|
||||
this.appendToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
this.appendToken(node.questionToken);
|
||||
this.appendNode(node.typeAnnotation);
|
||||
}
|
||||
@@ -684,7 +684,7 @@ module TypeScript.PrettyPrinter {
|
||||
public visitMemberFunctionDeclaration(node: MemberFunctionDeclarationSyntax): void {
|
||||
this.appendSpaceList(node.modifiers);
|
||||
this.ensureSpace();
|
||||
this.appendToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
this.appendBlockOrSemicolon(node.block, node.semicolonToken);
|
||||
}
|
||||
@@ -694,7 +694,7 @@ module TypeScript.PrettyPrinter {
|
||||
this.ensureSpace();
|
||||
this.appendToken(node.getKeyword);
|
||||
this.ensureSpace();
|
||||
this.appendToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
this.ensureSpace();
|
||||
visitNodeOrToken(this, node.block);
|
||||
@@ -705,7 +705,7 @@ module TypeScript.PrettyPrinter {
|
||||
this.ensureSpace();
|
||||
this.appendToken(node.setKeyword);
|
||||
this.ensureSpace();
|
||||
this.appendToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
visitNodeOrToken(this, node.callSignature)
|
||||
this.ensureSpace();
|
||||
visitNodeOrToken(this, node.block);
|
||||
@@ -895,7 +895,7 @@ module TypeScript.PrettyPrinter {
|
||||
}
|
||||
|
||||
public visitEnumElement(node: EnumElementSyntax): void {
|
||||
this.appendToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
this.ensureSpace();
|
||||
this.appendNode(node.equalsValueClause);
|
||||
}
|
||||
@@ -926,15 +926,21 @@ module TypeScript.PrettyPrinter {
|
||||
this.appendToken(node.closeBraceToken);
|
||||
}
|
||||
|
||||
public visitComputedPropertyName(node: ComputedPropertyNameSyntax): void {
|
||||
this.appendToken(node.openBracketToken);
|
||||
visitNodeOrToken(this, node.expression);
|
||||
this.appendToken(node.closeBracketToken);
|
||||
}
|
||||
|
||||
public visitSimplePropertyAssignment(node: SimplePropertyAssignmentSyntax): void {
|
||||
this.appendToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
this.appendToken(node.colonToken);
|
||||
this.ensureSpace();
|
||||
visitNodeOrToken(this, node.expression);
|
||||
}
|
||||
|
||||
public visitFunctionPropertyAssignment(node: FunctionPropertyAssignmentSyntax): void {
|
||||
this.appendToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
this.ensureSpace();
|
||||
visitNodeOrToken(this, node.block);
|
||||
|
||||
@@ -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 _nameBrand: 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 _propertyAssignmentBrand: any; public _propertyNameBrand: 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 _nameBrand: 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 _propertyAssignmentBrand: any; public _propertyNameBrand: any;
|
||||
public parent: ISyntaxElement;
|
||||
public childCount: number;
|
||||
|
||||
|
||||
@@ -450,7 +450,7 @@ module TypeScript {
|
||||
_memberDeclarationBrand: any;
|
||||
}
|
||||
|
||||
export interface IPropertyAssignmentSyntax extends ISyntaxNode {
|
||||
export interface IPropertyAssignmentSyntax extends ISyntaxNodeOrToken {
|
||||
_propertyAssignmentBrand: any;
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ module TypeScript {
|
||||
_accessorBrand: any;
|
||||
|
||||
modifiers: ISyntaxToken[];
|
||||
propertyName: ISyntaxToken;
|
||||
propertyName: IPropertyNameSyntax;
|
||||
callSignature: CallSignatureSyntax;
|
||||
block: BlockSyntax;
|
||||
}
|
||||
@@ -504,4 +504,8 @@ module TypeScript {
|
||||
export interface INameSyntax extends ITypeSyntax {
|
||||
_nameBrand: any;
|
||||
}
|
||||
|
||||
export interface IPropertyNameSyntax extends ISyntaxNodeOrToken {
|
||||
_propertyNameBrand: any;
|
||||
}
|
||||
}
|
||||
@@ -187,7 +187,7 @@ var definitions:ITypeDefinition[] = [
|
||||
name: 'VariableDeclaratorSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
children: [
|
||||
<any>{ name: 'propertyName', isToken: true },
|
||||
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
<any>{ name: 'typeAnnotation', type: 'TypeAnnotationSyntax', isOptional: true, isTypeScriptSpecific: true },
|
||||
<any>{ name: 'equalsValueClause', type: 'EqualsValueClauseSyntax', isOptional: true }
|
||||
]
|
||||
@@ -525,7 +525,7 @@ var definitions:ITypeDefinition[] = [
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['ITypeMemberSyntax'],
|
||||
children: [
|
||||
<any>{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
<any>{ name: 'questionToken', isToken: true, isOptional: true, itTypeScriptSpecific: true },
|
||||
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' }
|
||||
]
|
||||
@@ -547,7 +547,7 @@ var definitions:ITypeDefinition[] = [
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['ITypeMemberSyntax'],
|
||||
children: [
|
||||
<any>{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
<any>{ name: 'questionToken', isToken: true, isOptional: true },
|
||||
<any>{ name: 'typeAnnotation', type: 'TypeAnnotationSyntax', isOptional: true }
|
||||
],
|
||||
@@ -650,7 +650,7 @@ var definitions:ITypeDefinition[] = [
|
||||
interfaces: ['IMemberDeclarationSyntax'],
|
||||
children: [
|
||||
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
<any>{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
<any>{ name: 'block', type: 'BlockSyntax', isOptional: true },
|
||||
<any>{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
@@ -664,7 +664,7 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken', isTypeScriptSpecific: true },
|
||||
<any>{ name: 'getKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
<any>{ name: 'block', type: 'BlockSyntax' }
|
||||
]
|
||||
@@ -676,7 +676,7 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken', isTypeScriptSpecific: true },
|
||||
<any>{ name: 'setKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
<any>{ name: 'block', type: 'BlockSyntax' }
|
||||
],
|
||||
@@ -863,7 +863,7 @@ var definitions:ITypeDefinition[] = [
|
||||
name: 'EnumElementSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
children: [
|
||||
<any>{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
<any>{ name: 'equalsValueClause', type: 'EqualsValueClauseSyntax', isOptional: true }
|
||||
]
|
||||
},
|
||||
@@ -889,12 +889,22 @@ var definitions:ITypeDefinition[] = [
|
||||
<any>{ name: 'closeBraceToken', isToken: true, excludeFromAST: true }
|
||||
]
|
||||
},
|
||||
<any>{
|
||||
name: 'ComputedPropertyNameSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['IPropertyNameSyntax'],
|
||||
children: [
|
||||
<any>{ name: 'openBracketToken', isToken: true },
|
||||
<any>{ name: 'expression', type: 'IExpressionSyntax' },
|
||||
<any>{ name: 'closeBracketToken', isToken: true }
|
||||
]
|
||||
},
|
||||
<any>{
|
||||
name: 'SimplePropertyAssignmentSyntax',
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['IPropertyAssignmentSyntax'],
|
||||
children: [
|
||||
<any>{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
<any>{ name: 'colonToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'expression', type: 'IExpressionSyntax' }
|
||||
]
|
||||
@@ -904,7 +914,7 @@ var definitions:ITypeDefinition[] = [
|
||||
baseType: 'ISyntaxNode',
|
||||
interfaces: ['IPropertyAssignmentSyntax'],
|
||||
children: [
|
||||
<any>{ name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] },
|
||||
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
<any>{ name: 'block', type: 'BlockSyntax' }
|
||||
]
|
||||
|
||||
@@ -152,12 +152,12 @@ module TypeScript {
|
||||
|
||||
export interface MemberFunctionDeclarationSyntax extends ISyntaxNode, IMemberDeclarationSyntax {
|
||||
modifiers: ISyntaxToken[];
|
||||
propertyName: ISyntaxToken;
|
||||
propertyName: IPropertyNameSyntax;
|
||||
callSignature: CallSignatureSyntax;
|
||||
block: BlockSyntax;
|
||||
semicolonToken: ISyntaxToken;
|
||||
}
|
||||
export interface MemberFunctionDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken): MemberFunctionDeclarationSyntax }
|
||||
export interface MemberFunctionDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken): MemberFunctionDeclarationSyntax }
|
||||
|
||||
export interface MemberVariableDeclarationSyntax extends ISyntaxNode, IMemberDeclarationSyntax {
|
||||
modifiers: ISyntaxToken[];
|
||||
@@ -185,27 +185,27 @@ module TypeScript {
|
||||
export interface GetAccessorSyntax extends ISyntaxNode, IAccessorSyntax {
|
||||
modifiers: ISyntaxToken[];
|
||||
getKeyword: ISyntaxToken;
|
||||
propertyName: ISyntaxToken;
|
||||
propertyName: IPropertyNameSyntax;
|
||||
callSignature: CallSignatureSyntax;
|
||||
block: BlockSyntax;
|
||||
}
|
||||
export interface GetAccessorConstructor { new (data: number, modifiers: ISyntaxToken[], getKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax): GetAccessorSyntax }
|
||||
export interface GetAccessorConstructor { new (data: number, modifiers: ISyntaxToken[], getKeyword: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax): GetAccessorSyntax }
|
||||
|
||||
export interface SetAccessorSyntax extends ISyntaxNode, IAccessorSyntax {
|
||||
modifiers: ISyntaxToken[];
|
||||
setKeyword: ISyntaxToken;
|
||||
propertyName: ISyntaxToken;
|
||||
propertyName: IPropertyNameSyntax;
|
||||
callSignature: CallSignatureSyntax;
|
||||
block: BlockSyntax;
|
||||
}
|
||||
export interface SetAccessorConstructor { new (data: number, modifiers: ISyntaxToken[], setKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax): SetAccessorSyntax }
|
||||
export interface SetAccessorConstructor { new (data: number, modifiers: ISyntaxToken[], setKeyword: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax): SetAccessorSyntax }
|
||||
|
||||
export interface PropertySignatureSyntax extends ISyntaxNode, ITypeMemberSyntax {
|
||||
propertyName: ISyntaxToken;
|
||||
propertyName: IPropertyNameSyntax;
|
||||
questionToken: ISyntaxToken;
|
||||
typeAnnotation: TypeAnnotationSyntax;
|
||||
}
|
||||
export interface PropertySignatureConstructor { new (data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax): PropertySignatureSyntax }
|
||||
export interface PropertySignatureConstructor { new (data: number, propertyName: IPropertyNameSyntax, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax): PropertySignatureSyntax }
|
||||
|
||||
export interface CallSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax {
|
||||
typeParameterList: TypeParameterListSyntax;
|
||||
@@ -229,11 +229,11 @@ module TypeScript {
|
||||
export interface IndexSignatureConstructor { new (data: number, openBracketToken: ISyntaxToken, parameters: ISeparatedSyntaxList<ParameterSyntax>, closeBracketToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax): IndexSignatureSyntax }
|
||||
|
||||
export interface MethodSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax {
|
||||
propertyName: ISyntaxToken;
|
||||
propertyName: IPropertyNameSyntax;
|
||||
questionToken: ISyntaxToken;
|
||||
callSignature: CallSignatureSyntax;
|
||||
}
|
||||
export interface MethodSignatureConstructor { new (data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, callSignature: CallSignatureSyntax): MethodSignatureSyntax }
|
||||
export interface MethodSignatureConstructor { new (data: number, propertyName: IPropertyNameSyntax, questionToken: ISyntaxToken, callSignature: CallSignatureSyntax): MethodSignatureSyntax }
|
||||
|
||||
export interface BlockSyntax extends ISyntaxNode, IStatementSyntax {
|
||||
openBraceToken: ISyntaxToken;
|
||||
@@ -535,11 +535,11 @@ module TypeScript {
|
||||
export interface VariableDeclarationConstructor { new (data: number, varKeyword: ISyntaxToken, variableDeclarators: ISeparatedSyntaxList<VariableDeclaratorSyntax>): VariableDeclarationSyntax }
|
||||
|
||||
export interface VariableDeclaratorSyntax extends ISyntaxNode {
|
||||
propertyName: ISyntaxToken;
|
||||
propertyName: IPropertyNameSyntax;
|
||||
typeAnnotation: TypeAnnotationSyntax;
|
||||
equalsValueClause: EqualsValueClauseSyntax;
|
||||
}
|
||||
export interface VariableDeclaratorConstructor { new (data: number, propertyName: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax): VariableDeclaratorSyntax }
|
||||
export interface VariableDeclaratorConstructor { new (data: number, propertyName: IPropertyNameSyntax, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax): VariableDeclaratorSyntax }
|
||||
|
||||
export interface ArgumentListSyntax extends ISyntaxNode {
|
||||
typeArgumentList: TypeArgumentListSyntax;
|
||||
@@ -638,18 +638,18 @@ module TypeScript {
|
||||
export interface ConstraintConstructor { new (data: number, extendsKeyword: ISyntaxToken, typeOrExpression: ISyntaxNodeOrToken): ConstraintSyntax }
|
||||
|
||||
export interface SimplePropertyAssignmentSyntax extends ISyntaxNode, IPropertyAssignmentSyntax {
|
||||
propertyName: ISyntaxToken;
|
||||
propertyName: IPropertyNameSyntax;
|
||||
colonToken: ISyntaxToken;
|
||||
expression: IExpressionSyntax;
|
||||
}
|
||||
export interface SimplePropertyAssignmentConstructor { new (data: number, propertyName: ISyntaxToken, colonToken: ISyntaxToken, expression: IExpressionSyntax): SimplePropertyAssignmentSyntax }
|
||||
export interface SimplePropertyAssignmentConstructor { new (data: number, propertyName: IPropertyNameSyntax, colonToken: ISyntaxToken, expression: IExpressionSyntax): SimplePropertyAssignmentSyntax }
|
||||
|
||||
export interface FunctionPropertyAssignmentSyntax extends ISyntaxNode, IPropertyAssignmentSyntax {
|
||||
propertyName: ISyntaxToken;
|
||||
propertyName: IPropertyNameSyntax;
|
||||
callSignature: CallSignatureSyntax;
|
||||
block: BlockSyntax;
|
||||
}
|
||||
export interface FunctionPropertyAssignmentConstructor { new (data: number, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax): FunctionPropertyAssignmentSyntax }
|
||||
export interface FunctionPropertyAssignmentConstructor { new (data: number, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax): FunctionPropertyAssignmentSyntax }
|
||||
|
||||
export interface ParameterSyntax extends ISyntaxNode {
|
||||
dotDotDotToken: ISyntaxToken;
|
||||
@@ -662,10 +662,10 @@ module TypeScript {
|
||||
export interface ParameterConstructor { new (data: number, dotDotDotToken: ISyntaxToken, modifiers: ISyntaxToken[], identifier: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax): ParameterSyntax }
|
||||
|
||||
export interface EnumElementSyntax extends ISyntaxNode {
|
||||
propertyName: ISyntaxToken;
|
||||
propertyName: IPropertyNameSyntax;
|
||||
equalsValueClause: EqualsValueClauseSyntax;
|
||||
}
|
||||
export interface EnumElementConstructor { new (data: number, propertyName: ISyntaxToken, equalsValueClause: EqualsValueClauseSyntax): EnumElementSyntax }
|
||||
export interface EnumElementConstructor { new (data: number, propertyName: IPropertyNameSyntax, equalsValueClause: EqualsValueClauseSyntax): EnumElementSyntax }
|
||||
|
||||
export interface TypeAnnotationSyntax extends ISyntaxNode {
|
||||
colonToken: ISyntaxToken;
|
||||
@@ -673,6 +673,13 @@ module TypeScript {
|
||||
}
|
||||
export interface TypeAnnotationConstructor { new (data: number, colonToken: ISyntaxToken, type: ITypeSyntax): TypeAnnotationSyntax }
|
||||
|
||||
export interface ComputedPropertyNameSyntax extends ISyntaxNode, IPropertyNameSyntax {
|
||||
openBracketToken: ISyntaxToken;
|
||||
expression: IExpressionSyntax;
|
||||
closeBracketToken: ISyntaxToken;
|
||||
}
|
||||
export interface ComputedPropertyNameConstructor { new (data: number, openBracketToken: ISyntaxToken, expression: IExpressionSyntax, closeBracketToken: ISyntaxToken): ComputedPropertyNameSyntax }
|
||||
|
||||
export interface ExternalModuleReferenceSyntax extends ISyntaxNode, IModuleReferenceSyntax {
|
||||
requireKeyword: ISyntaxToken;
|
||||
openParenToken: ISyntaxToken;
|
||||
|
||||
@@ -261,14 +261,13 @@ module TypeScript {
|
||||
|
||||
// Property Assignment
|
||||
SimplePropertyAssignment,
|
||||
// GetAccessorPropertyAssignment,
|
||||
// SetAccessorPropertyAssignment,
|
||||
FunctionPropertyAssignment,
|
||||
|
||||
// Misc.
|
||||
Parameter,
|
||||
EnumElement,
|
||||
TypeAnnotation,
|
||||
ComputedPropertyName,
|
||||
ExternalModuleReference,
|
||||
ModuleNameModuleReference,
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export var SourceUnitSyntax: SourceUnitConstructor = <any>function (data: number, moduleElements: IModuleElementSyntax[], endOfFileToken: ISyntaxToken) {
|
||||
export var SourceUnitSyntax: SourceUnitConstructor = <any>function(data: number, moduleElements: IModuleElementSyntax[], endOfFileToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.moduleElements = moduleElements,
|
||||
this.endOfFileToken = endOfFileToken,
|
||||
@@ -17,7 +17,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var QualifiedNameSyntax: QualifiedNameConstructor = <any>function (data: number, left: INameSyntax, dotToken: ISyntaxToken, right: ISyntaxToken) {
|
||||
export var QualifiedNameSyntax: QualifiedNameConstructor = <any>function(data: number, left: INameSyntax, dotToken: ISyntaxToken, right: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.left = left,
|
||||
this.dotToken = dotToken,
|
||||
@@ -36,7 +36,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ObjectTypeSyntax: ObjectTypeConstructor = <any>function (data: number, openBraceToken: ISyntaxToken, typeMembers: ISeparatedSyntaxList<ITypeMemberSyntax>, closeBraceToken: ISyntaxToken) {
|
||||
export var ObjectTypeSyntax: ObjectTypeConstructor = <any>function(data: number, openBraceToken: ISyntaxToken, typeMembers: ISeparatedSyntaxList<ITypeMemberSyntax>, closeBraceToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.openBraceToken = openBraceToken,
|
||||
this.typeMembers = typeMembers,
|
||||
@@ -55,7 +55,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var FunctionTypeSyntax: FunctionTypeConstructor = <any>function (data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax) {
|
||||
export var FunctionTypeSyntax: FunctionTypeConstructor = <any>function(data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.typeParameterList = typeParameterList,
|
||||
this.parameterList = parameterList,
|
||||
@@ -77,7 +77,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ArrayTypeSyntax: ArrayTypeConstructor = <any>function (data: number, type: ITypeSyntax, openBracketToken: ISyntaxToken, closeBracketToken: ISyntaxToken) {
|
||||
export var ArrayTypeSyntax: ArrayTypeConstructor = <any>function(data: number, type: ITypeSyntax, openBracketToken: ISyntaxToken, closeBracketToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.type = type,
|
||||
this.openBracketToken = openBracketToken,
|
||||
@@ -96,7 +96,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ConstructorTypeSyntax: ConstructorTypeConstructor = <any>function (data: number, newKeyword: ISyntaxToken, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax) {
|
||||
export var ConstructorTypeSyntax: ConstructorTypeConstructor = <any>function(data: number, newKeyword: ISyntaxToken, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.newKeyword = newKeyword,
|
||||
this.typeParameterList = typeParameterList,
|
||||
@@ -121,7 +121,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var GenericTypeSyntax: GenericTypeConstructor = <any>function (data: number, name: INameSyntax, typeArgumentList: TypeArgumentListSyntax) {
|
||||
export var GenericTypeSyntax: GenericTypeConstructor = <any>function(data: number, name: INameSyntax, typeArgumentList: TypeArgumentListSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.name = name,
|
||||
this.typeArgumentList = typeArgumentList,
|
||||
@@ -137,7 +137,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var TypeQuerySyntax: TypeQueryConstructor = <any>function (data: number, typeOfKeyword: ISyntaxToken, name: INameSyntax) {
|
||||
export var TypeQuerySyntax: TypeQueryConstructor = <any>function(data: number, typeOfKeyword: ISyntaxToken, name: INameSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.typeOfKeyword = typeOfKeyword,
|
||||
this.name = name,
|
||||
@@ -153,7 +153,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var TupleTypeSyntax: TupleTypeConstructor = <any>function (data: number, openBracketToken: ISyntaxToken, types: ISeparatedSyntaxList<ITypeSyntax>, closeBracketToken: ISyntaxToken) {
|
||||
export var TupleTypeSyntax: TupleTypeConstructor = <any>function(data: number, openBracketToken: ISyntaxToken, types: ISeparatedSyntaxList<ITypeSyntax>, closeBracketToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.openBracketToken = openBracketToken,
|
||||
this.types = types,
|
||||
@@ -172,7 +172,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var UnionTypeSyntax: UnionTypeConstructor = <any>function (data: number, left: ITypeSyntax, barToken: ISyntaxToken, right: ITypeSyntax) {
|
||||
export var UnionTypeSyntax: UnionTypeConstructor = <any>function(data: number, left: ITypeSyntax, barToken: ISyntaxToken, right: ITypeSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.left = left,
|
||||
this.barToken = barToken,
|
||||
@@ -191,7 +191,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ParenthesizedTypeSyntax: ParenthesizedTypeConstructor = <any>function (data: number, openParenToken: ISyntaxToken, type: ITypeSyntax, closeParenToken: ISyntaxToken) {
|
||||
export var ParenthesizedTypeSyntax: ParenthesizedTypeConstructor = <any>function(data: number, openParenToken: ISyntaxToken, type: ITypeSyntax, closeParenToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.openParenToken = openParenToken,
|
||||
this.type = type,
|
||||
@@ -210,7 +210,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var InterfaceDeclarationSyntax: InterfaceDeclarationConstructor = <any>function (data: number, modifiers: ISyntaxToken[], interfaceKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], body: ObjectTypeSyntax) {
|
||||
export var InterfaceDeclarationSyntax: InterfaceDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], interfaceKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], body: ObjectTypeSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.interfaceKeyword = interfaceKeyword,
|
||||
@@ -238,7 +238,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var FunctionDeclarationSyntax: FunctionDeclarationConstructor = <any>function (data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) {
|
||||
export var FunctionDeclarationSyntax: FunctionDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.functionKeyword = functionKeyword,
|
||||
@@ -266,7 +266,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ModuleDeclarationSyntax: ModuleDeclarationConstructor = <any>function (data: number, modifiers: ISyntaxToken[], moduleKeyword: ISyntaxToken, name: INameSyntax, stringLiteral: ISyntaxToken, openBraceToken: ISyntaxToken, moduleElements: IModuleElementSyntax[], closeBraceToken: ISyntaxToken) {
|
||||
export var ModuleDeclarationSyntax: ModuleDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], moduleKeyword: ISyntaxToken, name: INameSyntax, stringLiteral: ISyntaxToken, openBraceToken: ISyntaxToken, moduleElements: IModuleElementSyntax[], closeBraceToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.moduleKeyword = moduleKeyword,
|
||||
@@ -297,7 +297,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ClassDeclarationSyntax: ClassDeclarationConstructor = <any>function (data: number, modifiers: ISyntaxToken[], classKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], openBraceToken: ISyntaxToken, classElements: IClassElementSyntax[], closeBraceToken: ISyntaxToken) {
|
||||
export var ClassDeclarationSyntax: ClassDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], classKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], openBraceToken: ISyntaxToken, classElements: IClassElementSyntax[], closeBraceToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.classKeyword = classKeyword,
|
||||
@@ -331,7 +331,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var EnumDeclarationSyntax: EnumDeclarationConstructor = <any>function (data: number, modifiers: ISyntaxToken[], enumKeyword: ISyntaxToken, identifier: ISyntaxToken, openBraceToken: ISyntaxToken, enumElements: ISeparatedSyntaxList<EnumElementSyntax>, closeBraceToken: ISyntaxToken) {
|
||||
export var EnumDeclarationSyntax: EnumDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], enumKeyword: ISyntaxToken, identifier: ISyntaxToken, openBraceToken: ISyntaxToken, enumElements: ISeparatedSyntaxList<EnumElementSyntax>, closeBraceToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.enumKeyword = enumKeyword,
|
||||
@@ -359,7 +359,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ImportDeclarationSyntax: ImportDeclarationConstructor = <any>function (data: number, modifiers: ISyntaxToken[], importKeyword: ISyntaxToken, identifier: ISyntaxToken, equalsToken: ISyntaxToken, moduleReference: IModuleReferenceSyntax, semicolonToken: ISyntaxToken) {
|
||||
export var ImportDeclarationSyntax: ImportDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], importKeyword: ISyntaxToken, identifier: ISyntaxToken, equalsToken: ISyntaxToken, moduleReference: IModuleReferenceSyntax, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.importKeyword = importKeyword,
|
||||
@@ -387,7 +387,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ExportAssignmentSyntax: ExportAssignmentConstructor = <any>function (data: number, exportKeyword: ISyntaxToken, equalsToken: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) {
|
||||
export var ExportAssignmentSyntax: ExportAssignmentConstructor = <any>function(data: number, exportKeyword: ISyntaxToken, equalsToken: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.exportKeyword = exportKeyword,
|
||||
this.equalsToken = equalsToken,
|
||||
@@ -409,7 +409,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var MemberFunctionDeclarationSyntax: MemberFunctionDeclarationConstructor = <any>function (data: number, modifiers: ISyntaxToken[], propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) {
|
||||
export var MemberFunctionDeclarationSyntax: MemberFunctionDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.propertyName = propertyName,
|
||||
@@ -434,7 +434,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var MemberVariableDeclarationSyntax: MemberVariableDeclarationConstructor = <any>function (data: number, modifiers: ISyntaxToken[], variableDeclarator: VariableDeclaratorSyntax, semicolonToken: ISyntaxToken) {
|
||||
export var MemberVariableDeclarationSyntax: MemberVariableDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], variableDeclarator: VariableDeclaratorSyntax, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.variableDeclarator = variableDeclarator,
|
||||
@@ -453,7 +453,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ConstructorDeclarationSyntax: ConstructorDeclarationConstructor = <any>function (data: number, modifiers: ISyntaxToken[], constructorKeyword: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) {
|
||||
export var ConstructorDeclarationSyntax: ConstructorDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], constructorKeyword: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.constructorKeyword = constructorKeyword,
|
||||
@@ -478,7 +478,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var IndexMemberDeclarationSyntax: IndexMemberDeclarationConstructor = <any>function (data: number, modifiers: ISyntaxToken[], indexSignature: IndexSignatureSyntax, semicolonToken: ISyntaxToken) {
|
||||
export var IndexMemberDeclarationSyntax: IndexMemberDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], indexSignature: IndexSignatureSyntax, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.indexSignature = indexSignature,
|
||||
@@ -497,7 +497,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var GetAccessorSyntax: GetAccessorConstructor = <any>function (data: number, modifiers: ISyntaxToken[], getKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) {
|
||||
export var GetAccessorSyntax: GetAccessorConstructor = <any>function(data: number, modifiers: ISyntaxToken[], getKeyword: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.getKeyword = getKeyword,
|
||||
@@ -522,7 +522,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var SetAccessorSyntax: SetAccessorConstructor = <any>function (data: number, modifiers: ISyntaxToken[], setKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) {
|
||||
export var SetAccessorSyntax: SetAccessorConstructor = <any>function(data: number, modifiers: ISyntaxToken[], setKeyword: ISyntaxToken, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.setKeyword = setKeyword,
|
||||
@@ -547,7 +547,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var PropertySignatureSyntax: PropertySignatureConstructor = <any>function (data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax) {
|
||||
export var PropertySignatureSyntax: PropertySignatureConstructor = <any>function(data: number, propertyName: IPropertyNameSyntax, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.propertyName = propertyName,
|
||||
this.questionToken = questionToken,
|
||||
@@ -566,7 +566,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var CallSignatureSyntax: CallSignatureConstructor = <any>function (data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, typeAnnotation: TypeAnnotationSyntax) {
|
||||
export var CallSignatureSyntax: CallSignatureConstructor = <any>function(data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, typeAnnotation: TypeAnnotationSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.typeParameterList = typeParameterList,
|
||||
this.parameterList = parameterList,
|
||||
@@ -585,7 +585,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ConstructSignatureSyntax: ConstructSignatureConstructor = <any>function (data: number, newKeyword: ISyntaxToken, callSignature: CallSignatureSyntax) {
|
||||
export var ConstructSignatureSyntax: ConstructSignatureConstructor = <any>function(data: number, newKeyword: ISyntaxToken, callSignature: CallSignatureSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.newKeyword = newKeyword,
|
||||
this.callSignature = callSignature,
|
||||
@@ -601,7 +601,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var IndexSignatureSyntax: IndexSignatureConstructor = <any>function (data: number, openBracketToken: ISyntaxToken, parameters: ISeparatedSyntaxList<ParameterSyntax>, closeBracketToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax) {
|
||||
export var IndexSignatureSyntax: IndexSignatureConstructor = <any>function(data: number, openBracketToken: ISyntaxToken, parameters: ISeparatedSyntaxList<ParameterSyntax>, closeBracketToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.openBracketToken = openBracketToken,
|
||||
this.parameters = parameters,
|
||||
@@ -623,7 +623,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var MethodSignatureSyntax: MethodSignatureConstructor = <any>function (data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, callSignature: CallSignatureSyntax) {
|
||||
export var MethodSignatureSyntax: MethodSignatureConstructor = <any>function(data: number, propertyName: IPropertyNameSyntax, questionToken: ISyntaxToken, callSignature: CallSignatureSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.propertyName = propertyName,
|
||||
this.questionToken = questionToken,
|
||||
@@ -642,7 +642,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var BlockSyntax: BlockConstructor = <any>function (data: number, openBraceToken: ISyntaxToken, statements: IStatementSyntax[], closeBraceToken: ISyntaxToken) {
|
||||
export var BlockSyntax: BlockConstructor = <any>function(data: number, openBraceToken: ISyntaxToken, statements: IStatementSyntax[], closeBraceToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.openBraceToken = openBraceToken,
|
||||
this.statements = statements,
|
||||
@@ -661,7 +661,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var IfStatementSyntax: IfStatementConstructor = <any>function (data: number, ifKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax, elseClause: ElseClauseSyntax) {
|
||||
export var IfStatementSyntax: IfStatementConstructor = <any>function(data: number, ifKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax, elseClause: ElseClauseSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.ifKeyword = ifKeyword,
|
||||
this.openParenToken = openParenToken,
|
||||
@@ -689,7 +689,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var VariableStatementSyntax: VariableStatementConstructor = <any>function (data: number, modifiers: ISyntaxToken[], variableDeclaration: VariableDeclarationSyntax, semicolonToken: ISyntaxToken) {
|
||||
export var VariableStatementSyntax: VariableStatementConstructor = <any>function(data: number, modifiers: ISyntaxToken[], variableDeclaration: VariableDeclarationSyntax, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.variableDeclaration = variableDeclaration,
|
||||
@@ -708,7 +708,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ExpressionStatementSyntax: ExpressionStatementConstructor = <any>function (data: number, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) {
|
||||
export var ExpressionStatementSyntax: ExpressionStatementConstructor = <any>function(data: number, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.expression = expression,
|
||||
this.semicolonToken = semicolonToken,
|
||||
@@ -724,7 +724,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ReturnStatementSyntax: ReturnStatementConstructor = <any>function (data: number, returnKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) {
|
||||
export var ReturnStatementSyntax: ReturnStatementConstructor = <any>function(data: number, returnKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.returnKeyword = returnKeyword,
|
||||
this.expression = expression,
|
||||
@@ -743,7 +743,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var SwitchStatementSyntax: SwitchStatementConstructor = <any>function (data: number, switchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, openBraceToken: ISyntaxToken, switchClauses: ISwitchClauseSyntax[], closeBraceToken: ISyntaxToken) {
|
||||
export var SwitchStatementSyntax: SwitchStatementConstructor = <any>function(data: number, switchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, openBraceToken: ISyntaxToken, switchClauses: ISwitchClauseSyntax[], closeBraceToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.switchKeyword = switchKeyword,
|
||||
this.openParenToken = openParenToken,
|
||||
@@ -774,7 +774,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var BreakStatementSyntax: BreakStatementConstructor = <any>function (data: number, breakKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) {
|
||||
export var BreakStatementSyntax: BreakStatementConstructor = <any>function(data: number, breakKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.breakKeyword = breakKeyword,
|
||||
this.identifier = identifier,
|
||||
@@ -793,7 +793,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ContinueStatementSyntax: ContinueStatementConstructor = <any>function (data: number, continueKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) {
|
||||
export var ContinueStatementSyntax: ContinueStatementConstructor = <any>function(data: number, continueKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.continueKeyword = continueKeyword,
|
||||
this.identifier = identifier,
|
||||
@@ -812,7 +812,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ForStatementSyntax: ForStatementConstructor = <any>function (data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, initializer: IExpressionSyntax, firstSemicolonToken: ISyntaxToken, condition: IExpressionSyntax, secondSemicolonToken: ISyntaxToken, incrementor: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
|
||||
export var ForStatementSyntax: ForStatementConstructor = <any>function(data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, initializer: IExpressionSyntax, firstSemicolonToken: ISyntaxToken, condition: IExpressionSyntax, secondSemicolonToken: ISyntaxToken, incrementor: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.forKeyword = forKeyword,
|
||||
this.openParenToken = openParenToken,
|
||||
@@ -852,7 +852,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ForInStatementSyntax: ForInStatementConstructor = <any>function (data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, left: IExpressionSyntax, inKeyword: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
|
||||
export var ForInStatementSyntax: ForInStatementConstructor = <any>function(data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, left: IExpressionSyntax, inKeyword: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.forKeyword = forKeyword,
|
||||
this.openParenToken = openParenToken,
|
||||
@@ -886,7 +886,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var EmptyStatementSyntax: EmptyStatementConstructor = <any>function (data: number, semicolonToken: ISyntaxToken) {
|
||||
export var EmptyStatementSyntax: EmptyStatementConstructor = <any>function(data: number, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.semicolonToken = semicolonToken,
|
||||
semicolonToken.parent = this;
|
||||
@@ -899,7 +899,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ThrowStatementSyntax: ThrowStatementConstructor = <any>function (data: number, throwKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) {
|
||||
export var ThrowStatementSyntax: ThrowStatementConstructor = <any>function(data: number, throwKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.throwKeyword = throwKeyword,
|
||||
this.expression = expression,
|
||||
@@ -918,7 +918,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var WhileStatementSyntax: WhileStatementConstructor = <any>function (data: number, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
|
||||
export var WhileStatementSyntax: WhileStatementConstructor = <any>function(data: number, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.whileKeyword = whileKeyword,
|
||||
this.openParenToken = openParenToken,
|
||||
@@ -943,7 +943,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var TryStatementSyntax: TryStatementConstructor = <any>function (data: number, tryKeyword: ISyntaxToken, block: BlockSyntax, catchClause: CatchClauseSyntax, finallyClause: FinallyClauseSyntax) {
|
||||
export var TryStatementSyntax: TryStatementConstructor = <any>function(data: number, tryKeyword: ISyntaxToken, block: BlockSyntax, catchClause: CatchClauseSyntax, finallyClause: FinallyClauseSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.tryKeyword = tryKeyword,
|
||||
this.block = block,
|
||||
@@ -965,7 +965,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var LabeledStatementSyntax: LabeledStatementConstructor = <any>function (data: number, identifier: ISyntaxToken, colonToken: ISyntaxToken, statement: IStatementSyntax) {
|
||||
export var LabeledStatementSyntax: LabeledStatementConstructor = <any>function(data: number, identifier: ISyntaxToken, colonToken: ISyntaxToken, statement: IStatementSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.identifier = identifier,
|
||||
this.colonToken = colonToken,
|
||||
@@ -984,7 +984,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var DoStatementSyntax: DoStatementConstructor = <any>function (data: number, doKeyword: ISyntaxToken, statement: IStatementSyntax, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, semicolonToken: ISyntaxToken) {
|
||||
export var DoStatementSyntax: DoStatementConstructor = <any>function(data: number, doKeyword: ISyntaxToken, statement: IStatementSyntax, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.doKeyword = doKeyword,
|
||||
this.statement = statement,
|
||||
@@ -1015,7 +1015,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var DebuggerStatementSyntax: DebuggerStatementConstructor = <any>function (data: number, debuggerKeyword: ISyntaxToken, semicolonToken: ISyntaxToken) {
|
||||
export var DebuggerStatementSyntax: DebuggerStatementConstructor = <any>function(data: number, debuggerKeyword: ISyntaxToken, semicolonToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.debuggerKeyword = debuggerKeyword,
|
||||
this.semicolonToken = semicolonToken,
|
||||
@@ -1031,7 +1031,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var WithStatementSyntax: WithStatementConstructor = <any>function (data: number, withKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
|
||||
export var WithStatementSyntax: WithStatementConstructor = <any>function(data: number, withKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.withKeyword = withKeyword,
|
||||
this.openParenToken = openParenToken,
|
||||
@@ -1056,7 +1056,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var PrefixUnaryExpressionSyntax: PrefixUnaryExpressionConstructor = <any>function (data: number, operatorToken: ISyntaxToken, operand: IUnaryExpressionSyntax) {
|
||||
export var PrefixUnaryExpressionSyntax: PrefixUnaryExpressionConstructor = <any>function(data: number, operatorToken: ISyntaxToken, operand: IUnaryExpressionSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.operatorToken = operatorToken,
|
||||
this.operand = operand,
|
||||
@@ -1072,7 +1072,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var DeleteExpressionSyntax: DeleteExpressionConstructor = <any>function (data: number, deleteKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) {
|
||||
export var DeleteExpressionSyntax: DeleteExpressionConstructor = <any>function(data: number, deleteKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.deleteKeyword = deleteKeyword,
|
||||
this.expression = expression,
|
||||
@@ -1088,7 +1088,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var TypeOfExpressionSyntax: TypeOfExpressionConstructor = <any>function (data: number, typeOfKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) {
|
||||
export var TypeOfExpressionSyntax: TypeOfExpressionConstructor = <any>function(data: number, typeOfKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.typeOfKeyword = typeOfKeyword,
|
||||
this.expression = expression,
|
||||
@@ -1104,7 +1104,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var VoidExpressionSyntax: VoidExpressionConstructor = <any>function (data: number, voidKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) {
|
||||
export var VoidExpressionSyntax: VoidExpressionConstructor = <any>function(data: number, voidKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.voidKeyword = voidKeyword,
|
||||
this.expression = expression,
|
||||
@@ -1120,7 +1120,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ConditionalExpressionSyntax: ConditionalExpressionConstructor = <any>function (data: number, condition: IExpressionSyntax, questionToken: ISyntaxToken, whenTrue: IExpressionSyntax, colonToken: ISyntaxToken, whenFalse: IExpressionSyntax) {
|
||||
export var ConditionalExpressionSyntax: ConditionalExpressionConstructor = <any>function(data: number, condition: IExpressionSyntax, questionToken: ISyntaxToken, whenTrue: IExpressionSyntax, colonToken: ISyntaxToken, whenFalse: IExpressionSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.condition = condition,
|
||||
this.questionToken = questionToken,
|
||||
@@ -1145,7 +1145,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var BinaryExpressionSyntax: BinaryExpressionConstructor = <any>function (data: number, left: IExpressionSyntax, operatorToken: ISyntaxToken, right: IExpressionSyntax) {
|
||||
export var BinaryExpressionSyntax: BinaryExpressionConstructor = <any>function(data: number, left: IExpressionSyntax, operatorToken: ISyntaxToken, right: IExpressionSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.left = left,
|
||||
this.operatorToken = operatorToken,
|
||||
@@ -1164,7 +1164,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var PostfixUnaryExpressionSyntax: PostfixUnaryExpressionConstructor = <any>function (data: number, operand: ILeftHandSideExpressionSyntax, operatorToken: ISyntaxToken) {
|
||||
export var PostfixUnaryExpressionSyntax: PostfixUnaryExpressionConstructor = <any>function(data: number, operand: ILeftHandSideExpressionSyntax, operatorToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.operand = operand,
|
||||
this.operatorToken = operatorToken,
|
||||
@@ -1180,7 +1180,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var MemberAccessExpressionSyntax: MemberAccessExpressionConstructor = <any>function (data: number, expression: ILeftHandSideExpressionSyntax, dotToken: ISyntaxToken, name: ISyntaxToken) {
|
||||
export var MemberAccessExpressionSyntax: MemberAccessExpressionConstructor = <any>function(data: number, expression: ILeftHandSideExpressionSyntax, dotToken: ISyntaxToken, name: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.expression = expression,
|
||||
this.dotToken = dotToken,
|
||||
@@ -1199,7 +1199,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var InvocationExpressionSyntax: InvocationExpressionConstructor = <any>function (data: number, expression: ILeftHandSideExpressionSyntax, argumentList: ArgumentListSyntax) {
|
||||
export var InvocationExpressionSyntax: InvocationExpressionConstructor = <any>function(data: number, expression: ILeftHandSideExpressionSyntax, argumentList: ArgumentListSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.expression = expression,
|
||||
this.argumentList = argumentList,
|
||||
@@ -1215,7 +1215,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ArrayLiteralExpressionSyntax: ArrayLiteralExpressionConstructor = <any>function (data: number, openBracketToken: ISyntaxToken, expressions: ISeparatedSyntaxList<IExpressionSyntax>, closeBracketToken: ISyntaxToken) {
|
||||
export var ArrayLiteralExpressionSyntax: ArrayLiteralExpressionConstructor = <any>function(data: number, openBracketToken: ISyntaxToken, expressions: ISeparatedSyntaxList<IExpressionSyntax>, closeBracketToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.openBracketToken = openBracketToken,
|
||||
this.expressions = expressions,
|
||||
@@ -1234,7 +1234,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ObjectLiteralExpressionSyntax: ObjectLiteralExpressionConstructor = <any>function (data: number, openBraceToken: ISyntaxToken, propertyAssignments: ISeparatedSyntaxList<IPropertyAssignmentSyntax>, closeBraceToken: ISyntaxToken) {
|
||||
export var ObjectLiteralExpressionSyntax: ObjectLiteralExpressionConstructor = <any>function(data: number, openBraceToken: ISyntaxToken, propertyAssignments: ISeparatedSyntaxList<IPropertyAssignmentSyntax>, closeBraceToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.openBraceToken = openBraceToken,
|
||||
this.propertyAssignments = propertyAssignments,
|
||||
@@ -1253,7 +1253,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ObjectCreationExpressionSyntax: ObjectCreationExpressionConstructor = <any>function (data: number, newKeyword: ISyntaxToken, expression: IMemberExpressionSyntax, argumentList: ArgumentListSyntax) {
|
||||
export var ObjectCreationExpressionSyntax: ObjectCreationExpressionConstructor = <any>function(data: number, newKeyword: ISyntaxToken, expression: IMemberExpressionSyntax, argumentList: ArgumentListSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.newKeyword = newKeyword,
|
||||
this.expression = expression,
|
||||
@@ -1272,7 +1272,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ParenthesizedExpressionSyntax: ParenthesizedExpressionConstructor = <any>function (data: number, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken) {
|
||||
export var ParenthesizedExpressionSyntax: ParenthesizedExpressionConstructor = <any>function(data: number, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.openParenToken = openParenToken,
|
||||
this.expression = expression,
|
||||
@@ -1291,7 +1291,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ParenthesizedArrowFunctionExpressionSyntax: ParenthesizedArrowFunctionExpressionConstructor = <any>function (data: number, callSignature: CallSignatureSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax) {
|
||||
export var ParenthesizedArrowFunctionExpressionSyntax: ParenthesizedArrowFunctionExpressionConstructor = <any>function(data: number, callSignature: CallSignatureSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.callSignature = callSignature,
|
||||
this.equalsGreaterThanToken = equalsGreaterThanToken,
|
||||
@@ -1313,7 +1313,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var SimpleArrowFunctionExpressionSyntax: SimpleArrowFunctionExpressionConstructor = <any>function (data: number, parameter: ParameterSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax) {
|
||||
export var SimpleArrowFunctionExpressionSyntax: SimpleArrowFunctionExpressionConstructor = <any>function(data: number, parameter: ParameterSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.parameter = parameter,
|
||||
this.equalsGreaterThanToken = equalsGreaterThanToken,
|
||||
@@ -1335,7 +1335,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var CastExpressionSyntax: CastExpressionConstructor = <any>function (data: number, lessThanToken: ISyntaxToken, type: ITypeSyntax, greaterThanToken: ISyntaxToken, expression: IUnaryExpressionSyntax) {
|
||||
export var CastExpressionSyntax: CastExpressionConstructor = <any>function(data: number, lessThanToken: ISyntaxToken, type: ITypeSyntax, greaterThanToken: ISyntaxToken, expression: IUnaryExpressionSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.lessThanToken = lessThanToken,
|
||||
this.type = type,
|
||||
@@ -1357,7 +1357,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ElementAccessExpressionSyntax: ElementAccessExpressionConstructor = <any>function (data: number, expression: ILeftHandSideExpressionSyntax, openBracketToken: ISyntaxToken, argumentExpression: IExpressionSyntax, closeBracketToken: ISyntaxToken) {
|
||||
export var ElementAccessExpressionSyntax: ElementAccessExpressionConstructor = <any>function(data: number, expression: ILeftHandSideExpressionSyntax, openBracketToken: ISyntaxToken, argumentExpression: IExpressionSyntax, closeBracketToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.expression = expression,
|
||||
this.openBracketToken = openBracketToken,
|
||||
@@ -1379,7 +1379,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var FunctionExpressionSyntax: FunctionExpressionConstructor = <any>function (data: number, functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) {
|
||||
export var FunctionExpressionSyntax: FunctionExpressionConstructor = <any>function(data: number, functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.functionKeyword = functionKeyword,
|
||||
this.identifier = identifier,
|
||||
@@ -1401,7 +1401,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var OmittedExpressionSyntax: OmittedExpressionConstructor = <any>function (data: number) {
|
||||
export var OmittedExpressionSyntax: OmittedExpressionConstructor = <any>function(data: number) {
|
||||
if (data) { this.__data = data; }
|
||||
};
|
||||
OmittedExpressionSyntax.prototype.kind = SyntaxKind.OmittedExpression;
|
||||
@@ -1410,7 +1410,7 @@ module TypeScript {
|
||||
throw Errors.invalidOperation();
|
||||
}
|
||||
|
||||
export var TemplateExpressionSyntax: TemplateExpressionConstructor = <any>function (data: number, templateStartToken: ISyntaxToken, templateClauses: TemplateClauseSyntax[]) {
|
||||
export var TemplateExpressionSyntax: TemplateExpressionConstructor = <any>function(data: number, templateStartToken: ISyntaxToken, templateClauses: TemplateClauseSyntax[]) {
|
||||
if (data) { this.__data = data; }
|
||||
this.templateStartToken = templateStartToken,
|
||||
this.templateClauses = templateClauses,
|
||||
@@ -1426,7 +1426,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var TemplateAccessExpressionSyntax: TemplateAccessExpressionConstructor = <any>function (data: number, expression: ILeftHandSideExpressionSyntax, templateExpression: IPrimaryExpressionSyntax) {
|
||||
export var TemplateAccessExpressionSyntax: TemplateAccessExpressionConstructor = <any>function(data: number, expression: ILeftHandSideExpressionSyntax, templateExpression: IPrimaryExpressionSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.expression = expression,
|
||||
this.templateExpression = templateExpression,
|
||||
@@ -1442,7 +1442,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var VariableDeclarationSyntax: VariableDeclarationConstructor = <any>function (data: number, varKeyword: ISyntaxToken, variableDeclarators: ISeparatedSyntaxList<VariableDeclaratorSyntax>) {
|
||||
export var VariableDeclarationSyntax: VariableDeclarationConstructor = <any>function(data: number, varKeyword: ISyntaxToken, variableDeclarators: ISeparatedSyntaxList<VariableDeclaratorSyntax>) {
|
||||
if (data) { this.__data = data; }
|
||||
this.varKeyword = varKeyword,
|
||||
this.variableDeclarators = variableDeclarators,
|
||||
@@ -1458,7 +1458,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var VariableDeclaratorSyntax: VariableDeclaratorConstructor = <any>function (data: number, propertyName: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax) {
|
||||
export var VariableDeclaratorSyntax: VariableDeclaratorConstructor = <any>function(data: number, propertyName: IPropertyNameSyntax, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.propertyName = propertyName,
|
||||
this.typeAnnotation = typeAnnotation,
|
||||
@@ -1477,7 +1477,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ArgumentListSyntax: ArgumentListConstructor = <any>function (data: number, typeArgumentList: TypeArgumentListSyntax, openParenToken: ISyntaxToken, _arguments: ISeparatedSyntaxList<IExpressionSyntax>, closeParenToken: ISyntaxToken) {
|
||||
export var ArgumentListSyntax: ArgumentListConstructor = <any>function(data: number, typeArgumentList: TypeArgumentListSyntax, openParenToken: ISyntaxToken, _arguments: ISeparatedSyntaxList<IExpressionSyntax>, closeParenToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.typeArgumentList = typeArgumentList,
|
||||
this.openParenToken = openParenToken,
|
||||
@@ -1499,7 +1499,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ParameterListSyntax: ParameterListConstructor = <any>function (data: number, openParenToken: ISyntaxToken, parameters: ISeparatedSyntaxList<ParameterSyntax>, closeParenToken: ISyntaxToken) {
|
||||
export var ParameterListSyntax: ParameterListConstructor = <any>function(data: number, openParenToken: ISyntaxToken, parameters: ISeparatedSyntaxList<ParameterSyntax>, closeParenToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.openParenToken = openParenToken,
|
||||
this.parameters = parameters,
|
||||
@@ -1518,7 +1518,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var TypeArgumentListSyntax: TypeArgumentListConstructor = <any>function (data: number, lessThanToken: ISyntaxToken, typeArguments: ISeparatedSyntaxList<ITypeSyntax>, greaterThanToken: ISyntaxToken) {
|
||||
export var TypeArgumentListSyntax: TypeArgumentListConstructor = <any>function(data: number, lessThanToken: ISyntaxToken, typeArguments: ISeparatedSyntaxList<ITypeSyntax>, greaterThanToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.lessThanToken = lessThanToken,
|
||||
this.typeArguments = typeArguments,
|
||||
@@ -1537,7 +1537,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var TypeParameterListSyntax: TypeParameterListConstructor = <any>function (data: number, lessThanToken: ISyntaxToken, typeParameters: ISeparatedSyntaxList<TypeParameterSyntax>, greaterThanToken: ISyntaxToken) {
|
||||
export var TypeParameterListSyntax: TypeParameterListConstructor = <any>function(data: number, lessThanToken: ISyntaxToken, typeParameters: ISeparatedSyntaxList<TypeParameterSyntax>, greaterThanToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.lessThanToken = lessThanToken,
|
||||
this.typeParameters = typeParameters,
|
||||
@@ -1556,7 +1556,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var HeritageClauseSyntax: HeritageClauseConstructor = <any>function (data: number, extendsOrImplementsKeyword: ISyntaxToken, typeNames: ISeparatedSyntaxList<INameSyntax>) {
|
||||
export var HeritageClauseSyntax: HeritageClauseConstructor = <any>function(data: number, extendsOrImplementsKeyword: ISyntaxToken, typeNames: ISeparatedSyntaxList<INameSyntax>) {
|
||||
if (data) { this.__data = data; }
|
||||
this.extendsOrImplementsKeyword = extendsOrImplementsKeyword,
|
||||
this.typeNames = typeNames,
|
||||
@@ -1572,7 +1572,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var EqualsValueClauseSyntax: EqualsValueClauseConstructor = <any>function (data: number, equalsToken: ISyntaxToken, value: IExpressionSyntax) {
|
||||
export var EqualsValueClauseSyntax: EqualsValueClauseConstructor = <any>function(data: number, equalsToken: ISyntaxToken, value: IExpressionSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.equalsToken = equalsToken,
|
||||
this.value = value,
|
||||
@@ -1588,7 +1588,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var CaseSwitchClauseSyntax: CaseSwitchClauseConstructor = <any>function (data: number, caseKeyword: ISyntaxToken, expression: IExpressionSyntax, colonToken: ISyntaxToken, statements: IStatementSyntax[]) {
|
||||
export var CaseSwitchClauseSyntax: CaseSwitchClauseConstructor = <any>function(data: number, caseKeyword: ISyntaxToken, expression: IExpressionSyntax, colonToken: ISyntaxToken, statements: IStatementSyntax[]) {
|
||||
if (data) { this.__data = data; }
|
||||
this.caseKeyword = caseKeyword,
|
||||
this.expression = expression,
|
||||
@@ -1610,7 +1610,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var DefaultSwitchClauseSyntax: DefaultSwitchClauseConstructor = <any>function (data: number, defaultKeyword: ISyntaxToken, colonToken: ISyntaxToken, statements: IStatementSyntax[]) {
|
||||
export var DefaultSwitchClauseSyntax: DefaultSwitchClauseConstructor = <any>function(data: number, defaultKeyword: ISyntaxToken, colonToken: ISyntaxToken, statements: IStatementSyntax[]) {
|
||||
if (data) { this.__data = data; }
|
||||
this.defaultKeyword = defaultKeyword,
|
||||
this.colonToken = colonToken,
|
||||
@@ -1629,7 +1629,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ElseClauseSyntax: ElseClauseConstructor = <any>function (data: number, elseKeyword: ISyntaxToken, statement: IStatementSyntax) {
|
||||
export var ElseClauseSyntax: ElseClauseConstructor = <any>function(data: number, elseKeyword: ISyntaxToken, statement: IStatementSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.elseKeyword = elseKeyword,
|
||||
this.statement = statement,
|
||||
@@ -1645,7 +1645,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var CatchClauseSyntax: CatchClauseConstructor = <any>function (data: number, catchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, identifier: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, closeParenToken: ISyntaxToken, block: BlockSyntax) {
|
||||
export var CatchClauseSyntax: CatchClauseConstructor = <any>function(data: number, catchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, identifier: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, closeParenToken: ISyntaxToken, block: BlockSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.catchKeyword = catchKeyword,
|
||||
this.openParenToken = openParenToken,
|
||||
@@ -1673,7 +1673,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var FinallyClauseSyntax: FinallyClauseConstructor = <any>function (data: number, finallyKeyword: ISyntaxToken, block: BlockSyntax) {
|
||||
export var FinallyClauseSyntax: FinallyClauseConstructor = <any>function(data: number, finallyKeyword: ISyntaxToken, block: BlockSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.finallyKeyword = finallyKeyword,
|
||||
this.block = block,
|
||||
@@ -1689,7 +1689,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var TemplateClauseSyntax: TemplateClauseConstructor = <any>function (data: number, expression: IExpressionSyntax, templateMiddleOrEndToken: ISyntaxToken) {
|
||||
export var TemplateClauseSyntax: TemplateClauseConstructor = <any>function(data: number, expression: IExpressionSyntax, templateMiddleOrEndToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.expression = expression,
|
||||
this.templateMiddleOrEndToken = templateMiddleOrEndToken,
|
||||
@@ -1705,7 +1705,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var TypeParameterSyntax: TypeParameterConstructor = <any>function (data: number, identifier: ISyntaxToken, constraint: ConstraintSyntax) {
|
||||
export var TypeParameterSyntax: TypeParameterConstructor = <any>function(data: number, identifier: ISyntaxToken, constraint: ConstraintSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.identifier = identifier,
|
||||
this.constraint = constraint,
|
||||
@@ -1721,7 +1721,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ConstraintSyntax: ConstraintConstructor = <any>function (data: number, extendsKeyword: ISyntaxToken, typeOrExpression: ISyntaxNodeOrToken) {
|
||||
export var ConstraintSyntax: ConstraintConstructor = <any>function(data: number, extendsKeyword: ISyntaxToken, typeOrExpression: ISyntaxNodeOrToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.extendsKeyword = extendsKeyword,
|
||||
this.typeOrExpression = typeOrExpression,
|
||||
@@ -1737,7 +1737,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var SimplePropertyAssignmentSyntax: SimplePropertyAssignmentConstructor = <any>function (data: number, propertyName: ISyntaxToken, colonToken: ISyntaxToken, expression: IExpressionSyntax) {
|
||||
export var SimplePropertyAssignmentSyntax: SimplePropertyAssignmentConstructor = <any>function(data: number, propertyName: IPropertyNameSyntax, colonToken: ISyntaxToken, expression: IExpressionSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.propertyName = propertyName,
|
||||
this.colonToken = colonToken,
|
||||
@@ -1756,7 +1756,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var FunctionPropertyAssignmentSyntax: FunctionPropertyAssignmentConstructor = <any>function (data: number, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) {
|
||||
export var FunctionPropertyAssignmentSyntax: FunctionPropertyAssignmentConstructor = <any>function(data: number, propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.propertyName = propertyName,
|
||||
this.callSignature = callSignature,
|
||||
@@ -1775,7 +1775,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ParameterSyntax: ParameterConstructor = <any>function (data: number, dotDotDotToken: ISyntaxToken, modifiers: ISyntaxToken[], identifier: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax) {
|
||||
export var ParameterSyntax: ParameterConstructor = <any>function(data: number, dotDotDotToken: ISyntaxToken, modifiers: ISyntaxToken[], identifier: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.dotDotDotToken = dotDotDotToken,
|
||||
this.modifiers = modifiers,
|
||||
@@ -1803,7 +1803,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var EnumElementSyntax: EnumElementConstructor = <any>function (data: number, propertyName: ISyntaxToken, equalsValueClause: EqualsValueClauseSyntax) {
|
||||
export var EnumElementSyntax: EnumElementConstructor = <any>function(data: number, propertyName: IPropertyNameSyntax, equalsValueClause: EqualsValueClauseSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.propertyName = propertyName,
|
||||
this.equalsValueClause = equalsValueClause,
|
||||
@@ -1819,7 +1819,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var TypeAnnotationSyntax: TypeAnnotationConstructor = <any>function (data: number, colonToken: ISyntaxToken, type: ITypeSyntax) {
|
||||
export var TypeAnnotationSyntax: TypeAnnotationConstructor = <any>function(data: number, colonToken: ISyntaxToken, type: ITypeSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.colonToken = colonToken,
|
||||
this.type = type,
|
||||
@@ -1835,7 +1835,26 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ExternalModuleReferenceSyntax: ExternalModuleReferenceConstructor = <any>function (data: number, requireKeyword: ISyntaxToken, openParenToken: ISyntaxToken, stringLiteral: ISyntaxToken, closeParenToken: ISyntaxToken) {
|
||||
export var ComputedPropertyNameSyntax: ComputedPropertyNameConstructor = <any>function(data: number, openBracketToken: ISyntaxToken, expression: IExpressionSyntax, closeBracketToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.openBracketToken = openBracketToken,
|
||||
this.expression = expression,
|
||||
this.closeBracketToken = closeBracketToken,
|
||||
openBracketToken.parent = this,
|
||||
expression.parent = this,
|
||||
closeBracketToken.parent = this;
|
||||
};
|
||||
ComputedPropertyNameSyntax.prototype.kind = SyntaxKind.ComputedPropertyName;
|
||||
ComputedPropertyNameSyntax.prototype.childCount = 3;
|
||||
ComputedPropertyNameSyntax.prototype.childAt = function(index: number): ISyntaxElement {
|
||||
switch (index) {
|
||||
case 0: return this.openBracketToken;
|
||||
case 1: return this.expression;
|
||||
case 2: return this.closeBracketToken;
|
||||
}
|
||||
}
|
||||
|
||||
export var ExternalModuleReferenceSyntax: ExternalModuleReferenceConstructor = <any>function(data: number, requireKeyword: ISyntaxToken, openParenToken: ISyntaxToken, stringLiteral: ISyntaxToken, closeParenToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.requireKeyword = requireKeyword,
|
||||
this.openParenToken = openParenToken,
|
||||
@@ -1857,7 +1876,7 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ModuleNameModuleReferenceSyntax: ModuleNameModuleReferenceConstructor = <any>function (data: number, moduleName: INameSyntax) {
|
||||
export var ModuleNameModuleReferenceSyntax: ModuleNameModuleReferenceConstructor = <any>function(data: number, moduleName: INameSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.moduleName = moduleName,
|
||||
moduleName.parent = this;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export interface ISyntaxToken extends ISyntaxNodeOrToken, INameSyntax, IPrimaryExpressionSyntax {
|
||||
export interface ISyntaxToken extends ISyntaxNodeOrToken, INameSyntax, IPrimaryExpressionSyntax, IPropertyAssignmentSyntax, IPropertyNameSyntax {
|
||||
// Adjusts the full start of this token. Should only be called by the parser.
|
||||
setFullStart(fullStart: number): void;
|
||||
|
||||
@@ -304,7 +304,8 @@ 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 _nameBrand: 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 _propertyAssignmentBrand: any; public _propertyNameBrand: any;
|
||||
|
||||
public parent: ISyntaxElement;
|
||||
public childCount: number;
|
||||
|
||||
@@ -418,7 +419,7 @@ 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 _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _nameBrand: any; public _propertyAssignmentBrand: any; public _propertyNameBrand: any;
|
||||
|
||||
private _fullStart: number;
|
||||
private _isKeywordConvertedToIdentifier: boolean;
|
||||
@@ -430,11 +431,11 @@ module TypeScript.Syntax {
|
||||
public childCount: number;
|
||||
|
||||
constructor(fullStart: number,
|
||||
public kind: SyntaxKind,
|
||||
isKeywordConvertedToIdentifier: boolean,
|
||||
leadingTrivia: ISyntaxTriviaList,
|
||||
text: string,
|
||||
trailingTrivia: ISyntaxTriviaList) {
|
||||
public kind: SyntaxKind,
|
||||
isKeywordConvertedToIdentifier: boolean,
|
||||
leadingTrivia: ISyntaxTriviaList,
|
||||
text: string,
|
||||
trailingTrivia: ISyntaxTriviaList) {
|
||||
this._fullStart = fullStart;
|
||||
this._isKeywordConvertedToIdentifier = isKeywordConvertedToIdentifier;
|
||||
this._text = text;
|
||||
@@ -491,7 +492,7 @@ 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 _nameBrand: 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 _propertyAssignmentBrand: any; public _propertyNameBrand: any;
|
||||
|
||||
public parent: ISyntaxElement;
|
||||
public kind: SyntaxKind;
|
||||
|
||||
@@ -556,7 +556,8 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public visitMethodSignature(node: MethodSignatureSyntax): void {
|
||||
if (this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
if (this.checkForDisallowedTemplatePropertyName(node.propertyName) ||
|
||||
this.checkForDisallowedComputedPropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -564,7 +565,8 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public visitPropertySignature(node: PropertySignatureSyntax): void {
|
||||
if (this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
if (this.checkForDisallowedTemplatePropertyName(node.propertyName) ||
|
||||
this.checkForDisallowedComputedPropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -573,7 +575,7 @@ module TypeScript {
|
||||
|
||||
public visitMemberFunctionDeclaration(node: MemberFunctionDeclarationSyntax): void {
|
||||
if (this.checkClassElementModifiers(node.modifiers) ||
|
||||
this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
this.checkForDisallowedTemplatePropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -624,12 +626,12 @@ module TypeScript {
|
||||
|
||||
public visitGetAccessor(node: GetAccessorSyntax): void {
|
||||
if (this.checkForAccessorDeclarationInAmbientContext(node) ||
|
||||
this.checkEcmaScriptVersionIsAtLeast(node.propertyName, ts.ScriptTarget.ES5, DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) ||
|
||||
this.checkEcmaScriptVersionIsAtLeast(node.getKeyword, ts.ScriptTarget.ES5, DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) ||
|
||||
this.checkForDisallowedModifiers(node.modifiers) ||
|
||||
this.checkClassElementModifiers(node.modifiers) ||
|
||||
this.checkForDisallowedAccessorTypeParameters(node.callSignature) ||
|
||||
this.checkGetAccessorParameter(node) ||
|
||||
this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
this.checkForDisallowedTemplatePropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -691,7 +693,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public visitSimplePropertyAssignment(node: SimplePropertyAssignmentSyntax): void {
|
||||
if (this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
if (this.checkForDisallowedTemplatePropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -700,13 +702,13 @@ module TypeScript {
|
||||
|
||||
public visitSetAccessor(node: SetAccessorSyntax): void {
|
||||
if (this.checkForAccessorDeclarationInAmbientContext(node) ||
|
||||
this.checkEcmaScriptVersionIsAtLeast(node.propertyName, ts.ScriptTarget.ES5, DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) ||
|
||||
this.checkEcmaScriptVersionIsAtLeast(node.setKeyword, ts.ScriptTarget.ES5, DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) ||
|
||||
this.checkForDisallowedModifiers(node.modifiers) ||
|
||||
this.checkClassElementModifiers(node.modifiers) ||
|
||||
this.checkForDisallowedAccessorTypeParameters(node.callSignature) ||
|
||||
this.checkForDisallowedSetAccessorTypeAnnotation(node) ||
|
||||
this.checkSetAccessorParameter(node) ||
|
||||
this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
this.checkForDisallowedTemplatePropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -747,7 +749,8 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public visitEnumElement(node: EnumElementSyntax): void {
|
||||
if (this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
if (this.checkForDisallowedTemplatePropertyName(node.propertyName) ||
|
||||
this.checkForDisallowedComputedPropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1338,7 +1341,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public visitFunctionPropertyAssignment(node: FunctionPropertyAssignmentSyntax): void {
|
||||
if (this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
if (this.checkForDisallowedTemplatePropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1410,16 +1413,25 @@ module TypeScript {
|
||||
public visitVariableDeclarator(node: VariableDeclaratorSyntax): void {
|
||||
if (this.checkVariableDeclaratorInitializer(node) ||
|
||||
this.checkVariableDeclaratorIdentifier(node) ||
|
||||
this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
this.checkForDisallowedTemplatePropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.visitVariableDeclarator(node);
|
||||
}
|
||||
|
||||
private checkForTemplatePropertyName(token: ISyntaxToken): boolean {
|
||||
if (token.kind === SyntaxKind.NoSubstitutionTemplateToken) {
|
||||
this.pushDiagnostic(token, DiagnosticCode.Template_literal_cannot_be_used_as_an_element_name);
|
||||
private checkForDisallowedTemplatePropertyName(propertyName: IPropertyNameSyntax): boolean {
|
||||
if (propertyName.kind === SyntaxKind.NoSubstitutionTemplateToken) {
|
||||
this.pushDiagnostic(propertyName, DiagnosticCode.Template_literal_cannot_be_used_as_an_element_name);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private checkForDisallowedComputedPropertyName(propertyName: IPropertyNameSyntax): boolean {
|
||||
if (propertyName.kind === SyntaxKind.ComputedPropertyName) {
|
||||
this.pushDiagnostic(propertyName, DiagnosticCode.Computed_property_names_cannot_be_used_here);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1428,7 +1440,8 @@ module TypeScript {
|
||||
|
||||
private checkVariableDeclaratorIdentifier(node: VariableDeclaratorSyntax): boolean {
|
||||
if (node.parent.kind !== SyntaxKind.MemberVariableDeclaration) {
|
||||
if (this.checkForDisallowedEvalOrArguments(node, node.propertyName)) {
|
||||
Debug.assert(isToken(node.propertyName), "A normal variable declarator must always have a token for a name.");
|
||||
if (this.checkForDisallowedEvalOrArguments(node, <ISyntaxToken>node.propertyName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ module TypeScript {
|
||||
case SyntaxKind.Parameter: return visitor.visitParameter(<ParameterSyntax>element);
|
||||
case SyntaxKind.EnumElement: return visitor.visitEnumElement(<EnumElementSyntax>element);
|
||||
case SyntaxKind.TypeAnnotation: return visitor.visitTypeAnnotation(<TypeAnnotationSyntax>element);
|
||||
case SyntaxKind.ComputedPropertyName: return visitor.visitComputedPropertyName(<ComputedPropertyNameSyntax>element);
|
||||
case SyntaxKind.ExternalModuleReference: return visitor.visitExternalModuleReference(<ExternalModuleReferenceSyntax>element);
|
||||
case SyntaxKind.ModuleNameModuleReference: return visitor.visitModuleNameModuleReference(<ModuleNameModuleReferenceSyntax>element);
|
||||
default: return visitor.visitToken(<ISyntaxToken>element);
|
||||
@@ -190,6 +191,7 @@ module TypeScript {
|
||||
visitParameter(node: ParameterSyntax): any;
|
||||
visitEnumElement(node: EnumElementSyntax): any;
|
||||
visitTypeAnnotation(node: TypeAnnotationSyntax): any;
|
||||
visitComputedPropertyName(node: ComputedPropertyNameSyntax): any;
|
||||
visitExternalModuleReference(node: ExternalModuleReferenceSyntax): any;
|
||||
visitModuleNameModuleReference(node: ModuleNameModuleReferenceSyntax): any;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ module TypeScript {
|
||||
|
||||
public visitMemberFunctionDeclaration(node: MemberFunctionDeclarationSyntax): void {
|
||||
this.visitList(node.modifiers);
|
||||
this.visitToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
visitNodeOrToken(this, node.block);
|
||||
this.visitOptionalToken(node.semicolonToken);
|
||||
@@ -180,7 +180,7 @@ module TypeScript {
|
||||
public visitGetAccessor(node: GetAccessorSyntax): void {
|
||||
this.visitList(node.modifiers);
|
||||
this.visitToken(node.getKeyword);
|
||||
this.visitToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
visitNodeOrToken(this, node.block);
|
||||
}
|
||||
@@ -188,13 +188,13 @@ module TypeScript {
|
||||
public visitSetAccessor(node: SetAccessorSyntax): void {
|
||||
this.visitList(node.modifiers);
|
||||
this.visitToken(node.setKeyword);
|
||||
this.visitToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
visitNodeOrToken(this, node.block);
|
||||
}
|
||||
|
||||
public visitPropertySignature(node: PropertySignatureSyntax): void {
|
||||
this.visitToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
this.visitOptionalToken(node.questionToken);
|
||||
visitNodeOrToken(this, node.typeAnnotation);
|
||||
}
|
||||
@@ -218,7 +218,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public visitMethodSignature(node: MethodSignatureSyntax): void {
|
||||
this.visitToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
this.visitOptionalToken(node.questionToken);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
}
|
||||
@@ -483,7 +483,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public visitVariableDeclarator(node: VariableDeclaratorSyntax): void {
|
||||
this.visitToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
visitNodeOrToken(this, node.typeAnnotation);
|
||||
visitNodeOrToken(this, node.equalsValueClause);
|
||||
}
|
||||
@@ -571,13 +571,13 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public visitSimplePropertyAssignment(node: SimplePropertyAssignmentSyntax): void {
|
||||
this.visitToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
this.visitToken(node.colonToken);
|
||||
visitNodeOrToken(this, node.expression);
|
||||
}
|
||||
|
||||
public visitFunctionPropertyAssignment(node: FunctionPropertyAssignmentSyntax): void {
|
||||
this.visitToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
visitNodeOrToken(this, node.block);
|
||||
}
|
||||
@@ -592,7 +592,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public visitEnumElement(node: EnumElementSyntax): void {
|
||||
this.visitToken(node.propertyName);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
visitNodeOrToken(this, node.equalsValueClause);
|
||||
}
|
||||
|
||||
@@ -601,6 +601,12 @@ module TypeScript {
|
||||
visitNodeOrToken(this, node.type);
|
||||
}
|
||||
|
||||
public visitComputedPropertyName(node: ComputedPropertyNameSyntax): void {
|
||||
this.visitToken(node.openBracketToken);
|
||||
visitNodeOrToken(this, node.expression);
|
||||
this.visitToken(node.closeBracketToken);
|
||||
}
|
||||
|
||||
public visitExternalModuleReference(node: ExternalModuleReferenceSyntax): void {
|
||||
this.visitToken(node.requireKeyword);
|
||||
this.visitToken(node.openParenToken);
|
||||
|
||||
@@ -284,7 +284,10 @@ module ts {
|
||||
return nodeHasTokens((<ExpressionStatement>n).expression);
|
||||
}
|
||||
|
||||
if (n.kind === SyntaxKind.EndOfFileToken || n.kind === SyntaxKind.OmittedExpression || n.kind === SyntaxKind.Missing) {
|
||||
if (n.kind === SyntaxKind.EndOfFileToken ||
|
||||
n.kind === SyntaxKind.OmittedExpression ||
|
||||
n.kind === SyntaxKind.Missing ||
|
||||
n.kind === SyntaxKind.Unknown) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -298,7 +301,7 @@ module ts {
|
||||
}
|
||||
|
||||
if (isAnyFunction(node) || node.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.InterfaceDeclaration) {
|
||||
return (<FunctionDeclaration>node).typeParameters;
|
||||
return (<FunctionLikeDeclaration>node).typeParameters;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
@@ -316,6 +319,10 @@ module ts {
|
||||
return kind === SyntaxKind.StringLiteral || kind === SyntaxKind.NumericLiteral || isWord(kind);
|
||||
}
|
||||
|
||||
export var switchToForwardSlashesRegEx = /\\/g;
|
||||
export function switchToForwardSlashes(path: string) {
|
||||
return path.replace(switchToForwardSlashesRegEx, "/");
|
||||
}
|
||||
export function isComment(kind: SyntaxKind): boolean {
|
||||
return kind === SyntaxKind.SingleLineCommentTrivia || kind === SyntaxKind.MultiLineCommentTrivia;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user