mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-12 04:17:34 -06:00
Merge branch 'master' into taggedTemplates
Conflicts: tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt
This commit is contained in:
commit
1508350cb8
20
Jakefile
20
Jakefile
@ -133,7 +133,7 @@ function concatenateFiles(destinationFile, sourceFiles) {
|
||||
fs.renameSync(temp, destinationFile);
|
||||
}
|
||||
|
||||
var useDebugMode = false;
|
||||
var useDebugMode = true;
|
||||
var generateDeclarations = false;
|
||||
var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node");
|
||||
var compilerFilename = "tsc.js";
|
||||
@ -148,15 +148,16 @@ var compilerFilename = "tsc.js";
|
||||
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile) {
|
||||
file(outFile, prereqs, function() {
|
||||
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory;
|
||||
var options = "-removeComments --module commonjs -noImplicitAny "; //" -propagateEnumConstants "
|
||||
var options = "-removeComments --module commonjs -noImplicitAny ";
|
||||
if (generateDeclarations) {
|
||||
options += "--declaration ";
|
||||
}
|
||||
|
||||
if (useDebugMode) {
|
||||
options += "--preserveConstEnums ";
|
||||
}
|
||||
|
||||
var cmd = host + " " + dir + compilerFilename + " " + options + " ";
|
||||
if (useDebugMode) {
|
||||
cmd = cmd + " " + path.join(harnessDirectory, "external/es5compat.ts") + " " + path.join(harnessDirectory, "external/json2.ts") + " ";
|
||||
}
|
||||
cmd = cmd + sources.join(" ") + (!noOutFile ? " -out " + outFile : "");
|
||||
if (useDebugMode) {
|
||||
cmd = cmd + " -sourcemap -mapRoot file:///" + path.resolve(path.dirname(outFile));
|
||||
@ -258,12 +259,11 @@ task("local", ["generate-diagnostics", "lib", tscFile, servicesFile]);
|
||||
|
||||
|
||||
// Local target to build the compiler and services
|
||||
desc("Emit debug mode files with sourcemaps");
|
||||
task("debug", function() {
|
||||
useDebugMode = true;
|
||||
desc("Sets release mode flag");
|
||||
task("release", function() {
|
||||
useDebugMode = false;
|
||||
});
|
||||
|
||||
|
||||
// Set the default task to "local"
|
||||
task("default", ["local"]);
|
||||
|
||||
@ -312,7 +312,7 @@ task("generate-spec", [specMd])
|
||||
|
||||
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
|
||||
desc("Makes a new LKG out of the built js files");
|
||||
task("LKG", libraryTargets, function() {
|
||||
task("LKG", ["clean", "release", "local"].concat(libraryTargets), function() {
|
||||
var expectedFiles = [tscFile, servicesFile].concat(libraryTargets);
|
||||
var missingFiles = expectedFiles.filter(function (f) {
|
||||
return !fs.existsSync(f);
|
||||
|
||||
5879
bin/tsc.js
5879
bin/tsc.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
580
doc/spec.md
580
doc/spec.md
File diff suppressed because it is too large
Load Diff
@ -5,25 +5,51 @@
|
||||
|
||||
module ts {
|
||||
|
||||
export function isInstantiated(node: Node): boolean {
|
||||
export const enum ModuleInstanceState {
|
||||
NonInstantiated = 0,
|
||||
Instantiated = 1,
|
||||
ConstEnumOnly = 2
|
||||
}
|
||||
|
||||
export function getModuleInstanceState(node: Node): ModuleInstanceState {
|
||||
// A module is uninstantiated if it contains only
|
||||
// 1. interface declarations
|
||||
if (node.kind === SyntaxKind.InterfaceDeclaration) {
|
||||
return false;
|
||||
return ModuleInstanceState.NonInstantiated;
|
||||
}
|
||||
// 2. non - exported import declarations
|
||||
// 2. const enum declarations don't make module instantiated
|
||||
else if (node.kind === SyntaxKind.EnumDeclaration && isConstEnumDeclaration(<EnumDeclaration>node)) {
|
||||
return ModuleInstanceState.ConstEnumOnly;
|
||||
}
|
||||
// 3. non - exported import declarations
|
||||
else if (node.kind === SyntaxKind.ImportDeclaration && !(node.flags & NodeFlags.Export)) {
|
||||
return false;
|
||||
return ModuleInstanceState.NonInstantiated;
|
||||
}
|
||||
// 3. other uninstantiated module declarations.
|
||||
else if (node.kind === SyntaxKind.ModuleBlock && !forEachChild(node, isInstantiated)) {
|
||||
return false;
|
||||
// 4. other uninstantiated module declarations.
|
||||
else if (node.kind === SyntaxKind.ModuleBlock) {
|
||||
var state = ModuleInstanceState.NonInstantiated;
|
||||
forEachChild(node, n => {
|
||||
switch (getModuleInstanceState(n)) {
|
||||
case ModuleInstanceState.NonInstantiated:
|
||||
// child is non-instantiated - continue searching
|
||||
return false;
|
||||
case ModuleInstanceState.ConstEnumOnly:
|
||||
// child is const enum only - record state and continue searching
|
||||
state = ModuleInstanceState.ConstEnumOnly;
|
||||
return false;
|
||||
case ModuleInstanceState.Instantiated:
|
||||
// child is instantiated - record state and stop
|
||||
state = ModuleInstanceState.Instantiated;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return state;
|
||||
}
|
||||
else if (node.kind === SyntaxKind.ModuleDeclaration && !isInstantiated((<ModuleDeclaration>node).body)) {
|
||||
return false;
|
||||
else if (node.kind === SyntaxKind.ModuleDeclaration) {
|
||||
return getModuleInstanceState((<ModuleDeclaration>node).body);
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
return ModuleInstanceState.Instantiated;
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,11 +274,22 @@ module ts {
|
||||
if (node.name.kind === SyntaxKind.StringLiteral) {
|
||||
bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true);
|
||||
}
|
||||
else if (isInstantiated(node)) {
|
||||
bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true);
|
||||
}
|
||||
else {
|
||||
bindDeclaration(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes, /*isBlockScopeContainer*/ true);
|
||||
var state = getModuleInstanceState(node);
|
||||
if (state === ModuleInstanceState.NonInstantiated) {
|
||||
bindDeclaration(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes, /*isBlockScopeContainer*/ true);
|
||||
}
|
||||
else {
|
||||
bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true);
|
||||
if (state === ModuleInstanceState.ConstEnumOnly) {
|
||||
// mark value module as module that contains only enums
|
||||
node.symbol.constEnumOnlyModule = true;
|
||||
}
|
||||
else if (node.symbol.constEnumOnlyModule) {
|
||||
// const only value module was merged with instantiated module - reset flag
|
||||
node.symbol.constEnumOnlyModule = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -364,7 +401,12 @@ module ts {
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes, /*isBlockScopeContainer*/ false);
|
||||
break;
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.Enum, SymbolFlags.EnumExcludes, /*isBlockScopeContainer*/ false);
|
||||
if (isConstEnumDeclaration(<EnumDeclaration>node)) {
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes, /*isBlockScopeContainer*/ false);
|
||||
}
|
||||
else {
|
||||
bindDeclaration(<Declaration>node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes, /*isBlockScopeContainer*/ false);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
bindModuleDeclaration(<ModuleDeclaration>node);
|
||||
|
||||
@ -187,7 +187,8 @@ module ts {
|
||||
if (flags & SymbolFlags.Function) result |= SymbolFlags.FunctionExcludes;
|
||||
if (flags & SymbolFlags.Class) result |= SymbolFlags.ClassExcludes;
|
||||
if (flags & SymbolFlags.Interface) result |= SymbolFlags.InterfaceExcludes;
|
||||
if (flags & SymbolFlags.Enum) result |= SymbolFlags.EnumExcludes;
|
||||
if (flags & SymbolFlags.RegularEnum) result |= SymbolFlags.RegularEnumExcludes;
|
||||
if (flags & SymbolFlags.ConstEnum) result |= SymbolFlags.ConstEnumExcludes;
|
||||
if (flags & SymbolFlags.ValueModule) result |= SymbolFlags.ValueModuleExcludes;
|
||||
if (flags & SymbolFlags.Method) result |= SymbolFlags.MethodExcludes;
|
||||
if (flags & SymbolFlags.GetAccessor) result |= SymbolFlags.GetAccessorExcludes;
|
||||
@ -208,6 +209,7 @@ module ts {
|
||||
result.declarations = symbol.declarations.slice(0);
|
||||
result.parent = symbol.parent;
|
||||
if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration;
|
||||
if (symbol.constEnumOnlyModule) result.constEnumOnlyModule = true;
|
||||
if (symbol.members) result.members = cloneSymbolTable(symbol.members);
|
||||
if (symbol.exports) result.exports = cloneSymbolTable(symbol.exports);
|
||||
recordMergedSymbol(result, symbol);
|
||||
@ -216,6 +218,10 @@ module ts {
|
||||
|
||||
function extendSymbol(target: Symbol, source: Symbol) {
|
||||
if (!(target.flags & getExcludedSymbolFlags(source.flags))) {
|
||||
if (source.flags & SymbolFlags.ValueModule && target.flags & SymbolFlags.ValueModule && target.constEnumOnlyModule && !source.constEnumOnlyModule) {
|
||||
// reset flag when merging instantiated module into value module that has only const enums
|
||||
target.constEnumOnlyModule = false;
|
||||
}
|
||||
target.flags |= source.flags;
|
||||
if (!target.valueDeclaration && source.valueDeclaration) target.valueDeclaration = source.valueDeclaration;
|
||||
forEach(source.declarations, node => {
|
||||
@ -310,6 +316,22 @@ module ts {
|
||||
// return undefined if we can't find a symbol.
|
||||
}
|
||||
|
||||
/** Returns true if node1 is defined before node 2**/
|
||||
function isDefinedBefore(node1: Node, node2: Node): boolean {
|
||||
var file1 = getSourceFileOfNode(node1);
|
||||
var file2 = getSourceFileOfNode(node2);
|
||||
if (file1 === file2) {
|
||||
return node1.pos <= node2.pos;
|
||||
}
|
||||
|
||||
if (!compilerOptions.out) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var sourceFiles = program.getSourceFiles();
|
||||
return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2);
|
||||
}
|
||||
|
||||
// Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and
|
||||
// the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with
|
||||
// the given name can be found.
|
||||
@ -429,18 +451,8 @@ module ts {
|
||||
// Block-scoped variables cannot be used before their definition
|
||||
var declaration = forEach(result.declarations, d => d.flags & NodeFlags.BlockScoped ? d : undefined);
|
||||
Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined");
|
||||
var declarationSourceFile = getSourceFileOfNode(declaration);
|
||||
var referenceSourceFile = getSourceFileOfNode(errorLocation);
|
||||
if (declarationSourceFile === referenceSourceFile) {
|
||||
if (declaration.pos > errorLocation.pos) {
|
||||
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, identifierToString(declaration.name));
|
||||
}
|
||||
}
|
||||
else if (compilerOptions.out) {
|
||||
var sourceFiles = program.getSourceFiles();
|
||||
if (sourceFiles.indexOf(referenceSourceFile) < sourceFiles.indexOf(declarationSourceFile)) {
|
||||
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, identifierToString(declaration.name));
|
||||
}
|
||||
if (!isDefinedBefore(declaration, errorLocation)) {
|
||||
error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, identifierToString(declaration.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1595,7 +1607,7 @@ module ts {
|
||||
return true;
|
||||
|
||||
default:
|
||||
Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + SyntaxKind[node.kind]);
|
||||
Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4452,8 +4464,8 @@ module ts {
|
||||
|
||||
if (symbol.flags & SymbolFlags.Import) {
|
||||
// Mark the import as referenced so that we emit it in the final .js file.
|
||||
// exception: identifiers that appear in type queries
|
||||
getSymbolLinks(symbol).referenced = !isInTypeQuery(node);
|
||||
// exception: identifiers that appear in type queries, const enums, modules that contain only const enums
|
||||
getSymbolLinks(symbol).referenced = !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveImport(symbol));
|
||||
}
|
||||
|
||||
checkCollisionWithCapturedSuperVariable(node, node);
|
||||
@ -5107,6 +5119,10 @@ module ts {
|
||||
|
||||
if (objectType === unknownType) return unknownType;
|
||||
|
||||
if (isConstEnumObjectType(objectType) && node.index.kind !== SyntaxKind.StringLiteral) {
|
||||
error(node.index, Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string);
|
||||
}
|
||||
|
||||
// TypeScript 1.0 spec (April 2014): 4.10 Property Access
|
||||
// - If IndexExpr is a string literal or a numeric literal and ObjExpr's apparent type has a property with the name
|
||||
// given by that literal(converted to its string representation in the case of a numeric literal), the property access is of the type of that property.
|
||||
@ -5121,6 +5137,7 @@ module ts {
|
||||
var name = (<LiteralExpression>node.index).text;
|
||||
var prop = getPropertyOfType(objectType, name);
|
||||
if (prop) {
|
||||
getNodeLinks(node).resolvedSymbol = prop;
|
||||
return getTypeOfSymbol(prop);
|
||||
}
|
||||
}
|
||||
@ -6086,6 +6103,14 @@ module ts {
|
||||
return (type.flags & TypeFlags.Structured) !== 0;
|
||||
}
|
||||
|
||||
function isConstEnumObjectType(type: Type) : boolean {
|
||||
return type.flags & (TypeFlags.ObjectType | TypeFlags.Anonymous) && type.symbol && isConstEnumSymbol(type.symbol);
|
||||
}
|
||||
|
||||
function isConstEnumSymbol(symbol: Symbol): boolean {
|
||||
return (symbol.flags & SymbolFlags.ConstEnum) !== 0;
|
||||
}
|
||||
|
||||
function checkInstanceOfExpression(node: BinaryExpression, leftType: Type, rightType: Type): Type {
|
||||
// TypeScript 1.0 spec (April 2014): 4.15.4
|
||||
// The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type,
|
||||
@ -6323,6 +6348,21 @@ module ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isConstEnumObjectType(type)) {
|
||||
// enum object type for const enums are only permitted in:
|
||||
// - 'left' in property access
|
||||
// - 'object' in indexed access
|
||||
// - target in rhs of import statement
|
||||
var ok =
|
||||
(node.parent.kind === SyntaxKind.PropertyAccess && (<PropertyAccess>node.parent).left === node) ||
|
||||
(node.parent.kind === SyntaxKind.IndexedAccess && (<IndexedAccess>node.parent).object === node) ||
|
||||
((node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName) && isInRightSideOfImportOrExportAssignment(<EntityName>node));
|
||||
|
||||
if (!ok) {
|
||||
error(node, Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment);
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@ -6997,7 +7037,7 @@ module ts {
|
||||
case SyntaxKind.InterfaceDeclaration:
|
||||
return SymbolFlags.ExportType;
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
return (<ModuleDeclaration>d).name.kind === SyntaxKind.StringLiteral || isInstantiated(d)
|
||||
return (<ModuleDeclaration>d).name.kind === SyntaxKind.StringLiteral || getModuleInstanceState(d) !== ModuleInstanceState.NonInstantiated
|
||||
? SymbolFlags.ExportNamespace | SymbolFlags.ExportValue
|
||||
: SymbolFlags.ExportNamespace;
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
@ -7234,7 +7274,7 @@ module ts {
|
||||
}
|
||||
|
||||
// Uninstantiated modules shouldnt do this check
|
||||
if (node.kind === SyntaxKind.ModuleDeclaration && !isInstantiated(node)) {
|
||||
if (node.kind === SyntaxKind.ModuleDeclaration && getModuleInstanceState(node) !== ModuleInstanceState.Instantiated) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -7796,26 +7836,10 @@ module ts {
|
||||
}
|
||||
|
||||
function checkTypeAliasDeclaration(node: TypeAliasDeclaration) {
|
||||
checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0);
|
||||
checkSourceElement(node.type);
|
||||
}
|
||||
|
||||
function getConstantValueForExpression(node: Expression): number {
|
||||
var isNegative = false;
|
||||
if (node.kind === SyntaxKind.PrefixOperator) {
|
||||
var unaryExpression = <UnaryExpression>node;
|
||||
if (unaryExpression.operator === SyntaxKind.MinusToken || unaryExpression.operator === SyntaxKind.PlusToken) {
|
||||
node = unaryExpression.operand;
|
||||
isNegative = unaryExpression.operator === SyntaxKind.MinusToken;
|
||||
}
|
||||
}
|
||||
if (node.kind === SyntaxKind.NumericLiteral) {
|
||||
var literalText = (<LiteralExpression>node).text;
|
||||
return isNegative ? -literalText : +literalText;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function computeEnumMemberValues(node: EnumDeclaration) {
|
||||
var nodeLinks = getNodeLinks(node);
|
||||
|
||||
@ -7824,6 +7848,7 @@ module ts {
|
||||
var enumType = getDeclaredTypeOfSymbol(enumSymbol);
|
||||
var autoValue = 0;
|
||||
var ambient = isInAmbientContext(node);
|
||||
var enumIsConst = isConstEnumDeclaration(node);
|
||||
|
||||
forEach(node.members, member => {
|
||||
if(isNumericName(member.name.text)) {
|
||||
@ -7831,16 +7856,30 @@ module ts {
|
||||
}
|
||||
var initializer = member.initializer;
|
||||
if (initializer) {
|
||||
autoValue = getConstantValueForExpression(initializer);
|
||||
if (autoValue === undefined && !ambient) {
|
||||
// Only here do we need to check that the initializer is assignable to the enum type.
|
||||
// If it is a constant value (not undefined), it is syntactically constrained to be a number.
|
||||
// Also, we do not need to check this for ambients because there is already
|
||||
// a syntax error if it is not a constant.
|
||||
autoValue = getConstantValueForEnumMemberInitializer(initializer, enumIsConst);
|
||||
if (autoValue === undefined) {
|
||||
if (enumIsConst) {
|
||||
error(initializer, Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression);
|
||||
}
|
||||
else if (!ambient) {
|
||||
// Only here do we need to check that the initializer is assignable to the enum type.
|
||||
// If it is a constant value (not undefined), it is syntactically constrained to be a number.
|
||||
// Also, we do not need to check this for ambients because there is already
|
||||
// a syntax error if it is not a constant.
|
||||
checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined);
|
||||
}
|
||||
}
|
||||
else if (enumIsConst) {
|
||||
if (isNaN(autoValue)) {
|
||||
error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN);
|
||||
}
|
||||
else if (!isFinite(autoValue)) {
|
||||
error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (ambient) {
|
||||
else if (ambient && !enumIsConst) {
|
||||
autoValue = undefined;
|
||||
}
|
||||
|
||||
@ -7851,6 +7890,110 @@ module ts {
|
||||
|
||||
nodeLinks.flags |= NodeCheckFlags.EnumValuesComputed;
|
||||
}
|
||||
|
||||
function getConstantValueForEnumMemberInitializer(initializer: Expression, enumIsConst: boolean): number {
|
||||
return evalConstant(initializer);
|
||||
|
||||
function evalConstant(e: Node): number {
|
||||
switch (e.kind) {
|
||||
case SyntaxKind.PrefixOperator:
|
||||
var value = evalConstant((<UnaryExpression>e).operand);
|
||||
if (value === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
switch ((<UnaryExpression>e).operator) {
|
||||
case SyntaxKind.PlusToken: return value;
|
||||
case SyntaxKind.MinusToken: return -value;
|
||||
case SyntaxKind.TildeToken: return enumIsConst ? ~value : undefined;
|
||||
}
|
||||
return undefined;
|
||||
case SyntaxKind.BinaryExpression:
|
||||
if (!enumIsConst) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var left = evalConstant((<BinaryExpression>e).left);
|
||||
if (left === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
var right = evalConstant((<BinaryExpression>e).right);
|
||||
if (right === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
switch ((<BinaryExpression>e).operator) {
|
||||
case SyntaxKind.BarToken: return left | right;
|
||||
case SyntaxKind.AmpersandToken: return left & right;
|
||||
case SyntaxKind.GreaterThanGreaterThanToken: return left >> right;
|
||||
case SyntaxKind.GreaterThanGreaterThanGreaterThanToken: return left >>> right;
|
||||
case SyntaxKind.LessThanLessThanToken: return left << right;
|
||||
case SyntaxKind.CaretToken: return left ^ right;
|
||||
case SyntaxKind.AsteriskToken: return left * right;
|
||||
case SyntaxKind.SlashToken: return left / right;
|
||||
case SyntaxKind.PlusToken: return left + right;
|
||||
case SyntaxKind.MinusToken: return left - right;
|
||||
case SyntaxKind.PercentToken: return left % right;
|
||||
}
|
||||
return undefined;
|
||||
case SyntaxKind.NumericLiteral:
|
||||
return +(<LiteralExpression>e).text;
|
||||
case SyntaxKind.ParenExpression:
|
||||
return enumIsConst ? evalConstant((<ParenExpression>e).expression) : undefined;
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.IndexedAccess:
|
||||
case SyntaxKind.PropertyAccess:
|
||||
if (!enumIsConst) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var member = initializer.parent;
|
||||
var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent));
|
||||
var enumType: Type;
|
||||
var propertyName: string;
|
||||
|
||||
if (e.kind === SyntaxKind.Identifier) {
|
||||
// unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work.
|
||||
// instead pick current enum type and later try to fetch member from the type
|
||||
enumType = currentType;
|
||||
propertyName = (<Identifier>e).text;
|
||||
}
|
||||
else {
|
||||
if (e.kind === SyntaxKind.IndexedAccess) {
|
||||
if ((<IndexedAccess>e).index.kind !== SyntaxKind.StringLiteral) {
|
||||
return undefined;
|
||||
}
|
||||
var enumType = getTypeOfNode((<IndexedAccess>e).object);
|
||||
propertyName = (<LiteralExpression>(<IndexedAccess>e).index).text;
|
||||
}
|
||||
else {
|
||||
var enumType = getTypeOfNode((<PropertyAccess>e).left);
|
||||
propertyName = (<PropertyAccess>e).right.text;
|
||||
}
|
||||
if (enumType !== currentType) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if (propertyName === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
var property = getPropertyOfObjectType(enumType, propertyName);
|
||||
if (!property || !(property.flags & SymbolFlags.EnumMember)) {
|
||||
return undefined;
|
||||
}
|
||||
var propertyDecl = property.valueDeclaration;
|
||||
// self references are illegal
|
||||
if (member === propertyDecl) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// illegal case: forward reference
|
||||
if (!isDefinedBefore(propertyDecl, member)) {
|
||||
return undefined;
|
||||
}
|
||||
return <number>getNodeLinks(propertyDecl).enumMemberValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkEnumDeclaration(node: EnumDeclaration) {
|
||||
@ -7874,6 +8017,16 @@ module ts {
|
||||
var enumSymbol = getSymbolOfNode(node);
|
||||
var firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind);
|
||||
if (node === firstDeclaration) {
|
||||
if (enumSymbol.declarations.length > 1) {
|
||||
var enumIsConst = isConstEnumDeclaration(node);
|
||||
// check that const is placed\omitted on all enum declarations
|
||||
forEach(enumSymbol.declarations, decl => {
|
||||
if (isConstEnumDeclaration(<EnumDeclaration>decl) !== enumIsConst) {
|
||||
error(decl.name, Diagnostics.Enum_declarations_must_all_be_const_or_non_const);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var seenEnumMissingInitialInitializer = false;
|
||||
forEach(enumSymbol.declarations, declaration => {
|
||||
// return true if we hit a violation of the rule, false otherwise
|
||||
@ -8707,17 +8860,16 @@ module ts {
|
||||
|
||||
function getExportAssignmentName(node: SourceFile): string {
|
||||
var symbol = getExportAssignmentSymbol(getSymbolOfNode(node));
|
||||
return symbol && symbolIsValue(symbol) ? symbolToString(symbol): undefined;
|
||||
return symbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol) ? symbolToString(symbol): undefined;
|
||||
}
|
||||
|
||||
function isTopLevelValueImportedViaEntityName(node: ImportDeclaration): boolean {
|
||||
function isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean {
|
||||
if (node.parent.kind !== SyntaxKind.SourceFile || !node.entityName) {
|
||||
// parent is not source file or it is not reference to internal module
|
||||
return false;
|
||||
}
|
||||
var symbol = getSymbolOfNode(node);
|
||||
var target = resolveImport(symbol);
|
||||
return target !== unknownSymbol && ((target.flags & SymbolFlags.Value) !== 0);
|
||||
return isImportResolvedToValue(getSymbolOfNode(node));
|
||||
}
|
||||
|
||||
function hasSemanticErrors() {
|
||||
@ -8729,6 +8881,16 @@ module ts {
|
||||
return forEach(getDiagnostics(sourceFile), d => d.isEarly);
|
||||
}
|
||||
|
||||
function isImportResolvedToValue(symbol: Symbol): boolean {
|
||||
var target = resolveImport(symbol);
|
||||
// const enums and modules that contain only const enums are not considered values from the emit perespective
|
||||
return target !== unknownSymbol && target.flags & SymbolFlags.Value && !isConstEnumOrConstEnumOnlyModule(target);
|
||||
}
|
||||
|
||||
function isConstEnumOrConstEnumOnlyModule(s: Symbol): boolean {
|
||||
return isConstEnumSymbol(s) || s.constEnumOnlyModule;
|
||||
}
|
||||
|
||||
function isReferencedImportDeclaration(node: ImportDeclaration): boolean {
|
||||
var symbol = getSymbolOfNode(node);
|
||||
if (getSymbolLinks(symbol).referenced) {
|
||||
@ -8737,10 +8899,7 @@ module ts {
|
||||
// logic below will answer 'true' for exported import declaration in a nested module that itself is not exported.
|
||||
// As a consequence this might cause emitting extra.
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
var target = resolveImport(symbol);
|
||||
if (target !== unknownSymbol && target.flags & SymbolFlags.Value) {
|
||||
return true;
|
||||
}
|
||||
return isImportResolvedToValue(symbol);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -8775,7 +8934,7 @@ module ts {
|
||||
return getNodeLinks(node).enumMemberValue;
|
||||
}
|
||||
|
||||
function getConstantValue(node: PropertyAccess): number {
|
||||
function getConstantValue(node: PropertyAccess | IndexedAccess): number {
|
||||
var symbol = getNodeLinks(node).resolvedSymbol;
|
||||
if (symbol && (symbol.flags & SymbolFlags.EnumMember)) {
|
||||
var declaration = symbol.valueDeclaration;
|
||||
@ -8810,7 +8969,7 @@ module ts {
|
||||
isReferencedImportDeclaration: isReferencedImportDeclaration,
|
||||
getNodeCheckFlags: getNodeCheckFlags,
|
||||
getEnumMemberValue: getEnumMemberValue,
|
||||
isTopLevelValueImportedViaEntityName: isTopLevelValueImportedViaEntityName,
|
||||
isTopLevelValueImportWithEntityName: isTopLevelValueImportWithEntityName,
|
||||
hasSemanticErrors: hasSemanticErrors,
|
||||
hasEarlyErrors: hasEarlyErrors,
|
||||
isDeclarationVisible: isDeclarationVisible,
|
||||
|
||||
@ -24,7 +24,7 @@ module ts {
|
||||
type: "boolean",
|
||||
},
|
||||
{
|
||||
name: "emitBOM",
|
||||
name: "emitBOM",
|
||||
type: "boolean"
|
||||
},
|
||||
{
|
||||
@ -102,7 +102,7 @@ module ts {
|
||||
{
|
||||
name: "target",
|
||||
shortName: "t",
|
||||
type: { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5 , "es6": ScriptTarget.ES6 },
|
||||
type: { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES6 },
|
||||
description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental,
|
||||
paramType: Diagnostics.VERSION,
|
||||
error: Diagnostics.Argument_for_target_option_must_be_es3_es5_or_es6
|
||||
@ -118,6 +118,11 @@ module ts {
|
||||
shortName: "w",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Watch_input_files,
|
||||
},
|
||||
{
|
||||
name: "preserveConstEnums",
|
||||
type: "boolean",
|
||||
description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ module ts {
|
||||
// x | y is False if both x and y are False.
|
||||
// x | y is Maybe if either x or y is Maybe, but neither x or y is True.
|
||||
// x | y is True if either x or y is True.
|
||||
export enum Ternary {
|
||||
export const enum Ternary {
|
||||
False = 0,
|
||||
Maybe = 1,
|
||||
True = -1
|
||||
@ -19,7 +19,7 @@ module ts {
|
||||
[index: string]: T;
|
||||
}
|
||||
|
||||
export enum Comparison {
|
||||
export const enum Comparison {
|
||||
LessThan = -1,
|
||||
EqualTo = 0,
|
||||
GreaterThan = 1
|
||||
@ -648,7 +648,7 @@ module ts {
|
||||
getSignatureConstructor: () => <any>Signature
|
||||
}
|
||||
|
||||
export enum AssertionLevel {
|
||||
export const enum AssertionLevel {
|
||||
None = 0,
|
||||
Normal = 1,
|
||||
Aggressive = 2,
|
||||
|
||||
@ -120,9 +120,8 @@ module ts {
|
||||
const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized" },
|
||||
const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." },
|
||||
let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." },
|
||||
Aliased_type_cannot_be_an_object_type_literal_Use_an_interface_declaration_instead: { code: 1158, category: DiagnosticCategory.Error, key: "Aliased type cannot be an object type literal. Use an interface declaration instead." },
|
||||
Invalid_template_literal_expected: { code: 1159, category: DiagnosticCategory.Error, key: "Invalid template literal; expected '}'" },
|
||||
Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1160, category: DiagnosticCategory.Error, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." },
|
||||
Invalid_template_literal_expected: { code: 1158, category: DiagnosticCategory.Error, key: "Invalid template literal; expected '}'" },
|
||||
Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: DiagnosticCategory.Error, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." },
|
||||
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
|
||||
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
|
||||
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
|
||||
@ -270,6 +269,7 @@ module ts {
|
||||
The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: DiagnosticCategory.Error, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." },
|
||||
Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: DiagnosticCategory.Error, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." },
|
||||
Type_alias_0_circularly_references_itself: { code: 2456, category: DiagnosticCategory.Error, key: "Type alias '{0}' circularly references itself." },
|
||||
Type_alias_name_cannot_be_0: { code: 2457, category: DiagnosticCategory.Error, key: "Type alias name cannot be '{0}'" },
|
||||
Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." },
|
||||
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." },
|
||||
@ -352,6 +352,12 @@ module ts {
|
||||
Exported_type_alias_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4079, category: DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using name '{1}' from external module {2} but cannot be named." },
|
||||
Exported_type_alias_0_has_or_is_using_name_1_from_private_module_2: { code: 4080, category: DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using name '{1}' from private module '{2}'." },
|
||||
Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." },
|
||||
Enum_declarations_must_all_be_const_or_non_const: { code: 4082, category: DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." },
|
||||
In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 4083, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression.", isEarly: true },
|
||||
const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 4084, category: DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." },
|
||||
Index_expression_arguments_in_const_enums_must_be_of_type_string: { code: 4085, category: DiagnosticCategory.Error, key: "Index expression arguments in 'const' enums must be of type 'string'." },
|
||||
const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 4086, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." },
|
||||
const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 4087, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." },
|
||||
The_current_host_does_not_support_the_0_option: { code: 5001, category: DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." },
|
||||
Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." },
|
||||
Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" },
|
||||
@ -366,6 +372,7 @@ module ts {
|
||||
Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." },
|
||||
Watch_input_files: { code: 6005, category: DiagnosticCategory.Message, key: "Watch input files." },
|
||||
Redirect_output_structure_to_the_directory: { code: 6006, category: DiagnosticCategory.Message, key: "Redirect output structure to the directory." },
|
||||
Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: DiagnosticCategory.Message, key: "Do not erase const enum declarations in generated code." },
|
||||
Do_not_emit_comments_to_output: { code: 6009, category: DiagnosticCategory.Message, key: "Do not emit comments to output." },
|
||||
Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" },
|
||||
Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" },
|
||||
|
||||
@ -471,17 +471,13 @@
|
||||
"category": "Error",
|
||||
"code": 1157
|
||||
},
|
||||
"Aliased type cannot be an object type literal. Use an interface declaration instead.": {
|
||||
"Invalid template literal; expected '}'": {
|
||||
"category": "Error",
|
||||
"code": 1158
|
||||
},
|
||||
"Invalid template literal; expected '}'": {
|
||||
"category": "Error",
|
||||
"code": 1159
|
||||
},
|
||||
"Tagged templates are only available when targeting ECMAScript 6 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1160
|
||||
"code": 1159
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
@ -1080,6 +1076,10 @@
|
||||
"category": "Error",
|
||||
"code": 2456
|
||||
},
|
||||
"Type alias name cannot be '{0}'": {
|
||||
"category": "Error",
|
||||
"code": 2457
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
@ -1409,13 +1409,35 @@
|
||||
"category": "Error",
|
||||
"code": 4081
|
||||
},
|
||||
|
||||
|
||||
"Enum declarations must all be const or non-const.": {
|
||||
"category": "Error",
|
||||
"code": 4082
|
||||
},
|
||||
"In 'const' enum declarations member initializer must be constant expression.": {
|
||||
"category": "Error",
|
||||
"code": 4083,
|
||||
"isEarly": true
|
||||
},
|
||||
"'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.": {
|
||||
"category": "Error",
|
||||
"code": 4084
|
||||
},
|
||||
"Index expression arguments in 'const' enums must be of type 'string'.": {
|
||||
"category": "Error",
|
||||
"code": 4085
|
||||
},
|
||||
"'const' enum member initializer was evaluated to a non-finite value.": {
|
||||
"category": "Error",
|
||||
"code": 4086
|
||||
},
|
||||
"'const' enum member initializer was evaluated to disallowed value 'NaN'.": {
|
||||
"category": "Error",
|
||||
"code": 4087
|
||||
},
|
||||
"The current host does not support the '{0}' option.": {
|
||||
"category": "Error",
|
||||
"code": 5001
|
||||
},
|
||||
|
||||
"Cannot find the common subdirectory path for the input files.": {
|
||||
"category": "Error",
|
||||
"code": 5009
|
||||
@ -1468,6 +1490,10 @@
|
||||
"category": "Message",
|
||||
"code": 6006
|
||||
},
|
||||
"Do not erase const enum declarations in generated code.": {
|
||||
"category": "Message",
|
||||
"code": 6007
|
||||
},
|
||||
"Do not emit comments to output.": {
|
||||
"category": "Message",
|
||||
"code": 6009
|
||||
|
||||
@ -1031,19 +1031,29 @@ module ts {
|
||||
emitTrailingComments(node);
|
||||
}
|
||||
|
||||
function emitPropertyAccess(node: PropertyAccess) {
|
||||
function tryEmitConstantValue(node: PropertyAccess | IndexedAccess): boolean {
|
||||
var constantValue = resolver.getConstantValue(node);
|
||||
if (constantValue !== undefined) {
|
||||
write(constantValue.toString() + " /* " + identifierToString(node.right) + " */");
|
||||
var propertyName = node.kind === SyntaxKind.PropertyAccess ? identifierToString((<PropertyAccess>node).right) : getTextOfNode((<IndexedAccess>node).index);
|
||||
write(constantValue.toString() + " /* " + propertyName + " */");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
emit(node.left);
|
||||
write(".");
|
||||
emit(node.right);
|
||||
return false;
|
||||
}
|
||||
|
||||
function emitPropertyAccess(node: PropertyAccess) {
|
||||
if (tryEmitConstantValue(node)) {
|
||||
return;
|
||||
}
|
||||
emit(node.left);
|
||||
write(".");
|
||||
emit(node.right);
|
||||
}
|
||||
|
||||
function emitIndexedAccess(node: IndexedAccess) {
|
||||
if (tryEmitConstantValue(node)) {
|
||||
return;
|
||||
}
|
||||
emit(node.object);
|
||||
write("[");
|
||||
emit(node.index);
|
||||
@ -1341,6 +1351,10 @@ module ts {
|
||||
emitToken(SyntaxKind.CloseBraceToken, node.clauses.end);
|
||||
}
|
||||
|
||||
function isOnSameLine(node1: Node, node2: Node) {
|
||||
return getLineOfLocalPosition(skipTrivia(currentSourceFile.text, node1.pos)) === getLineOfLocalPosition(skipTrivia(currentSourceFile.text, node2.pos));
|
||||
}
|
||||
|
||||
function emitCaseOrDefaultClause(node: CaseOrDefaultClause) {
|
||||
if (node.kind === SyntaxKind.CaseClause) {
|
||||
write("case ");
|
||||
@ -1350,9 +1364,16 @@ module ts {
|
||||
else {
|
||||
write("default:");
|
||||
}
|
||||
increaseIndent();
|
||||
emitLines(node.statements);
|
||||
decreaseIndent();
|
||||
|
||||
if (node.statements.length === 1 && isOnSameLine(node, node.statements[0])) {
|
||||
write(" ");
|
||||
emit(node.statements[0]);
|
||||
}
|
||||
else {
|
||||
increaseIndent();
|
||||
emitLines(node.statements);
|
||||
decreaseIndent();
|
||||
}
|
||||
}
|
||||
|
||||
function emitThrowStatement(node: ThrowStatement) {
|
||||
@ -1876,6 +1897,11 @@ module ts {
|
||||
}
|
||||
|
||||
function emitEnumDeclaration(node: EnumDeclaration) {
|
||||
// const enums are completely erased during compilation.
|
||||
var isConstEnum = isConstEnumDeclaration(node);
|
||||
if (isConstEnum && !compilerOptions.preserveConstEnums) {
|
||||
return;
|
||||
}
|
||||
emitLeadingComments(node);
|
||||
if (!(node.flags & NodeFlags.Export)) {
|
||||
emitStart(node);
|
||||
@ -1893,7 +1919,7 @@ module ts {
|
||||
write(") {");
|
||||
increaseIndent();
|
||||
scopeEmitStart(node);
|
||||
emitEnumMemberDeclarations();
|
||||
emitEnumMemberDeclarations(isConstEnum);
|
||||
decreaseIndent();
|
||||
writeLine();
|
||||
emitToken(SyntaxKind.CloseBraceToken, node.members.end);
|
||||
@ -1916,7 +1942,7 @@ module ts {
|
||||
}
|
||||
emitTrailingComments(node);
|
||||
|
||||
function emitEnumMemberDeclarations() {
|
||||
function emitEnumMemberDeclarations(isConstEnum: boolean) {
|
||||
forEach(node.members, member => {
|
||||
writeLine();
|
||||
emitLeadingComments(member);
|
||||
@ -1927,7 +1953,7 @@ module ts {
|
||||
write("[");
|
||||
emitQuotedIdentifier(member.name);
|
||||
write("] = ");
|
||||
if (member.initializer) {
|
||||
if (member.initializer && !isConstEnum) {
|
||||
emit(member.initializer);
|
||||
}
|
||||
else {
|
||||
@ -1950,7 +1976,7 @@ module ts {
|
||||
}
|
||||
|
||||
function emitModuleDeclaration(node: ModuleDeclaration) {
|
||||
if (!isInstantiated(node)) {
|
||||
if (getModuleInstanceState(node) !== ModuleInstanceState.Instantiated) {
|
||||
return emitPinnedOrTripleSlashComments(node);
|
||||
}
|
||||
emitLeadingComments(node);
|
||||
@ -2002,7 +2028,7 @@ module ts {
|
||||
// preserve old compiler's behavior: emit 'var' for import declaration (even if we do not consider them referenced) when
|
||||
// - current file is not external module
|
||||
// - import declaration is top level and target is value imported by entity name
|
||||
emitImportDeclaration = !isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportedViaEntityName(node);
|
||||
emitImportDeclaration = !isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportWithEntityName(node);
|
||||
}
|
||||
|
||||
if (emitImportDeclaration) {
|
||||
@ -2722,6 +2748,9 @@ module ts {
|
||||
if (resolver.isDeclarationVisible(node)) {
|
||||
emitJsDocComments(node);
|
||||
emitDeclarationFlags(node);
|
||||
if (isConstEnumDeclaration(node)) {
|
||||
write("const ")
|
||||
}
|
||||
write("enum ");
|
||||
emitSourceTextOfNode(node.name);
|
||||
write(" {");
|
||||
@ -2801,7 +2830,7 @@ module ts {
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.fail("This is unknown parent for type parameter: " + SyntaxKind[node.parent.kind]);
|
||||
Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
|
||||
}
|
||||
|
||||
return {
|
||||
@ -3197,7 +3226,7 @@ module ts {
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.fail("This is unknown kind for signature: " + SyntaxKind[node.kind]);
|
||||
Debug.fail("This is unknown kind for signature: " + node.kind);
|
||||
}
|
||||
|
||||
return {
|
||||
@ -3282,7 +3311,7 @@ module ts {
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.fail("This is unknown parent for parameter: " + SyntaxKind[node.parent.kind]);
|
||||
Debug.fail("This is unknown parent for parameter: " + node.parent.kind);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@ -115,6 +115,10 @@ module ts {
|
||||
return (file.flags & NodeFlags.DeclarationFile) !== 0;
|
||||
}
|
||||
|
||||
export function isConstEnumDeclaration(node: EnumDeclaration): boolean {
|
||||
return (node.flags & NodeFlags.Const) !== 0;
|
||||
}
|
||||
|
||||
export function isPrologueDirective(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.ExpressionStatement && (<ExpressionStatement>node).expression.kind === SyntaxKind.StringLiteral;
|
||||
}
|
||||
@ -662,7 +666,7 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
enum ParsingContext {
|
||||
const enum ParsingContext {
|
||||
SourceElements, // Elements in source file
|
||||
ModuleElements, // Elements in module declaration
|
||||
BlockStatements, // Statements in block
|
||||
@ -683,7 +687,7 @@ module ts {
|
||||
Count // Number of parsing contexts
|
||||
}
|
||||
|
||||
enum Tristate {
|
||||
const enum Tristate {
|
||||
False,
|
||||
True,
|
||||
Unknown
|
||||
@ -711,13 +715,13 @@ module ts {
|
||||
}
|
||||
};
|
||||
|
||||
enum LookAheadMode {
|
||||
const enum LookAheadMode {
|
||||
NotLookingAhead,
|
||||
NoErrorYet,
|
||||
Error
|
||||
}
|
||||
|
||||
enum ModifierContext {
|
||||
const enum ModifierContext {
|
||||
SourceElements, // Top level elements in a source file
|
||||
ModuleElements, // Elements in module declaration
|
||||
ClassMembers, // Members in class declaration
|
||||
@ -726,7 +730,7 @@ module ts {
|
||||
|
||||
// Tracks whether we nested (directly or indirectly) in a certain control block.
|
||||
// Used for validating break and continue statements.
|
||||
enum ControlBlockContext {
|
||||
const enum ControlBlockContext {
|
||||
NotNested,
|
||||
Nested,
|
||||
CrossingFunctionBoundary
|
||||
@ -2730,7 +2734,7 @@ module ts {
|
||||
currentKind = SetAccesor;
|
||||
}
|
||||
else {
|
||||
Debug.fail("Unexpected syntax kind:" + SyntaxKind[p.kind]);
|
||||
Debug.fail("Unexpected syntax kind:" + p.kind);
|
||||
}
|
||||
|
||||
if (!hasProperty(seen, p.name.text)) {
|
||||
@ -3246,7 +3250,6 @@ module ts {
|
||||
case SyntaxKind.OpenBraceToken:
|
||||
case SyntaxKind.VarKeyword:
|
||||
case SyntaxKind.LetKeyword:
|
||||
case SyntaxKind.ConstKeyword:
|
||||
case SyntaxKind.FunctionKeyword:
|
||||
case SyntaxKind.IfKeyword:
|
||||
case SyntaxKind.DoKeyword:
|
||||
@ -3265,6 +3268,12 @@ module ts {
|
||||
case SyntaxKind.CatchKeyword:
|
||||
case SyntaxKind.FinallyKeyword:
|
||||
return true;
|
||||
case SyntaxKind.ConstKeyword:
|
||||
// const keyword can precede enum keyword when defining constant enums
|
||||
// 'const enum' do not start statement.
|
||||
// In ES 6 'enum' is a future reserved keyword, so it should not be used as identifier
|
||||
var isConstEnum = lookAhead(() => nextToken() === SyntaxKind.EnumKeyword);
|
||||
return !isConstEnum;
|
||||
case SyntaxKind.InterfaceKeyword:
|
||||
case SyntaxKind.ClassKeyword:
|
||||
case SyntaxKind.ModuleKeyword:
|
||||
@ -3275,6 +3284,7 @@ module ts {
|
||||
if (isDeclarationStart()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
case SyntaxKind.PublicKeyword:
|
||||
case SyntaxKind.PrivateKeyword:
|
||||
case SyntaxKind.ProtectedKeyword:
|
||||
@ -3296,6 +3306,7 @@ module ts {
|
||||
case SyntaxKind.VarKeyword:
|
||||
case SyntaxKind.LetKeyword:
|
||||
case SyntaxKind.ConstKeyword:
|
||||
// const here should always be parsed as const declaration because of check in 'isStatement'
|
||||
return parseVariableStatement(allowLetAndConstDeclarations);
|
||||
case SyntaxKind.FunctionKeyword:
|
||||
return parseFunctionDeclaration();
|
||||
@ -3856,17 +3867,11 @@ module ts {
|
||||
parseExpected(SyntaxKind.EqualsToken);
|
||||
node.type = parseType();
|
||||
parseSemicolon();
|
||||
var n = node.type;
|
||||
while (n.kind === SyntaxKind.ParenType) {
|
||||
n = (<ParenTypeNode>n).type;
|
||||
}
|
||||
if (n.kind === SyntaxKind.TypeLiteral && (n.pos !== (<TypeLiteralNode>n).members.pos || n.end !== (<TypeLiteralNode>n).members.end)) {
|
||||
grammarErrorOnNode(node.type, Diagnostics.Aliased_type_cannot_be_an_object_type_literal_Use_an_interface_declaration_instead);
|
||||
}
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
function parseAndCheckEnumDeclaration(pos: number, flags: NodeFlags): EnumDeclaration {
|
||||
var enumIsConst = flags & NodeFlags.Const;
|
||||
function isIntegerLiteral(expression: Expression): boolean {
|
||||
function isInteger(literalExpression: LiteralExpression): boolean {
|
||||
// Allows for scientific notation since literalExpression.text was formed by
|
||||
@ -3901,22 +3906,29 @@ module ts {
|
||||
node.name = parsePropertyName();
|
||||
node.initializer = parseInitializer(/*inParameter*/ false);
|
||||
|
||||
if (inAmbientContext) {
|
||||
if (node.initializer && !isIntegerLiteral(node.initializer) && errorCountBeforeEnumMember === file.syntacticErrors.length) {
|
||||
grammarErrorOnNode(node.name, Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers);
|
||||
// skip checks below for const enums - they allow arbitrary initializers as long as they can be evaluated to constant expressions.
|
||||
// since all values are known in compile time - it is not necessary to check that constant enum section precedes computed enum members.
|
||||
if (!enumIsConst) {
|
||||
if (inAmbientContext) {
|
||||
if (node.initializer && !isIntegerLiteral(node.initializer) && errorCountBeforeEnumMember === file.syntacticErrors.length) {
|
||||
grammarErrorOnNode(node.name, Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers);
|
||||
}
|
||||
}
|
||||
else if (node.initializer) {
|
||||
inConstantEnumMemberSection = isIntegerLiteral(node.initializer);
|
||||
}
|
||||
else if (!inConstantEnumMemberSection && errorCountBeforeEnumMember === file.syntacticErrors.length) {
|
||||
grammarErrorOnNode(node.name, Diagnostics.Enum_member_must_have_initializer);
|
||||
}
|
||||
}
|
||||
else if (node.initializer) {
|
||||
inConstantEnumMemberSection = isIntegerLiteral(node.initializer);
|
||||
}
|
||||
else if (!inConstantEnumMemberSection && errorCountBeforeEnumMember === file.syntacticErrors.length) {
|
||||
grammarErrorOnNode(node.name, Diagnostics.Enum_member_must_have_initializer);
|
||||
}
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
var node = <EnumDeclaration>createNode(SyntaxKind.EnumDeclaration, pos);
|
||||
node.flags = flags;
|
||||
if (enumIsConst) {
|
||||
parseExpected(SyntaxKind.ConstKeyword);
|
||||
}
|
||||
parseExpected(SyntaxKind.EnumKeyword);
|
||||
node.name = parseIdentifier();
|
||||
if (parseExpected(SyntaxKind.OpenBraceToken)) {
|
||||
@ -4073,9 +4085,17 @@ module ts {
|
||||
switch (token) {
|
||||
case SyntaxKind.VarKeyword:
|
||||
case SyntaxKind.LetKeyword:
|
||||
case SyntaxKind.ConstKeyword:
|
||||
result = parseVariableStatement(/*allowLetAndConstDeclarations*/ true, pos, flags);
|
||||
break;
|
||||
case SyntaxKind.ConstKeyword:
|
||||
var isConstEnum = lookAhead(() => nextToken() === SyntaxKind.EnumKeyword);
|
||||
if (isConstEnum) {
|
||||
result = parseAndCheckEnumDeclaration(pos, flags | NodeFlags.Const);
|
||||
}
|
||||
else {
|
||||
result = parseVariableStatement(/*allowLetAndConstDeclarations*/ true, pos, flags);
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.FunctionKeyword:
|
||||
result = parseFunctionDeclaration(pos, flags);
|
||||
break;
|
||||
|
||||
@ -9,7 +9,7 @@ module ts {
|
||||
}
|
||||
|
||||
// token > SyntaxKind.Identifer => token is a keyword
|
||||
export enum SyntaxKind {
|
||||
export const enum SyntaxKind {
|
||||
Unknown,
|
||||
EndOfFileToken,
|
||||
SingleLineCommentTrivia,
|
||||
@ -249,7 +249,7 @@ module ts {
|
||||
LastTemplateToken = TemplateTail
|
||||
}
|
||||
|
||||
export enum NodeFlags {
|
||||
export const enum NodeFlags {
|
||||
Export = 0x00000001, // Declarations
|
||||
Ambient = 0x00000002, // Declarations
|
||||
QuestionMark = 0x00000004, // Parameter/Property/Method
|
||||
@ -722,7 +722,7 @@ module ts {
|
||||
trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void;
|
||||
}
|
||||
|
||||
export enum TypeFormatFlags {
|
||||
export const enum TypeFormatFlags {
|
||||
None = 0x00000000,
|
||||
WriteArrayAsGenericType = 0x00000001, // Write Array<T> instead T[]
|
||||
UseTypeOfFunction = 0x00000002, // Write typeof instead of function type literal
|
||||
@ -733,7 +733,7 @@ module ts {
|
||||
InElementType = 0x00000040, // Writing an array or union element type
|
||||
}
|
||||
|
||||
export enum SymbolFormatFlags {
|
||||
export const enum SymbolFormatFlags {
|
||||
None = 0x00000000,
|
||||
WriteTypeParametersOrArguments = 0x00000001, // Write symbols's type argument if it is instantiated symbol
|
||||
// eg. class C<T> { p: T } <-- Show p as C<T>.p here
|
||||
@ -744,7 +744,7 @@ module ts {
|
||||
// When this flag is specified m.c will be used to refer to the class instead of alias symbol x
|
||||
}
|
||||
|
||||
export enum SymbolAccessibility {
|
||||
export const enum SymbolAccessibility {
|
||||
Accessible,
|
||||
NotAccessible,
|
||||
CannotBeNamed
|
||||
@ -763,7 +763,7 @@ module ts {
|
||||
getExpressionNamePrefix(node: Identifier): string;
|
||||
getExportAssignmentName(node: SourceFile): string;
|
||||
isReferencedImportDeclaration(node: ImportDeclaration): boolean;
|
||||
isTopLevelValueImportedViaEntityName(node: ImportDeclaration): boolean;
|
||||
isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean;
|
||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||
getEnumMemberValue(node: EnumMember): number;
|
||||
hasSemanticErrors(): boolean;
|
||||
@ -774,11 +774,11 @@ module ts {
|
||||
isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult;
|
||||
isImportDeclarationEntityNameReferenceDeclarationVisibile(entityName: EntityName): SymbolAccessiblityResult;
|
||||
// Returns the constant value this property access resolves to, or 'undefined' for a non-constant
|
||||
getConstantValue(node: PropertyAccess): number;
|
||||
getConstantValue(node: PropertyAccess | IndexedAccess): number;
|
||||
hasEarlyErrors(sourceFile?: SourceFile): boolean;
|
||||
}
|
||||
|
||||
export enum SymbolFlags {
|
||||
export const enum SymbolFlags {
|
||||
FunctionScopedVariable = 0x00000001, // Variable (var) or parameter
|
||||
BlockScopedVariable = 0x00000002, // A block-scoped variable (let or const)
|
||||
Property = 0x00000004, // Property or enum member
|
||||
@ -786,32 +786,34 @@ module ts {
|
||||
Function = 0x00000010, // Function
|
||||
Class = 0x00000020, // Class
|
||||
Interface = 0x00000040, // Interface
|
||||
Enum = 0x00000080, // Enum
|
||||
ValueModule = 0x00000100, // Instantiated module
|
||||
NamespaceModule = 0x00000200, // Uninstantiated module
|
||||
TypeLiteral = 0x00000400, // Type Literal
|
||||
ObjectLiteral = 0x00000800, // Object Literal
|
||||
Method = 0x00001000, // Method
|
||||
Constructor = 0x00002000, // Constructor
|
||||
GetAccessor = 0x00004000, // Get accessor
|
||||
SetAccessor = 0x00008000, // Set accessor
|
||||
CallSignature = 0x00010000, // Call signature
|
||||
ConstructSignature = 0x00020000, // Construct signature
|
||||
IndexSignature = 0x00040000, // Index signature
|
||||
TypeParameter = 0x00080000, // Type parameter
|
||||
TypeAlias = 0x00100000, // Type alias
|
||||
ConstEnum = 0x00000080, // Const enum
|
||||
RegularEnum = 0x00000100, // Enum
|
||||
ValueModule = 0x00000200, // Instantiated module
|
||||
NamespaceModule = 0x00000400, // Uninstantiated module
|
||||
TypeLiteral = 0x00000800, // Type Literal
|
||||
ObjectLiteral = 0x00001000, // Object Literal
|
||||
Method = 0x00002000, // Method
|
||||
Constructor = 0x00004000, // Constructor
|
||||
GetAccessor = 0x00008000, // Get accessor
|
||||
SetAccessor = 0x00010000, // Set accessor
|
||||
CallSignature = 0x00020000, // Call signature
|
||||
ConstructSignature = 0x00040000, // Construct signature
|
||||
IndexSignature = 0x00080000, // Index signature
|
||||
TypeParameter = 0x00100000, // Type parameter
|
||||
TypeAlias = 0x00200000, // Type alias
|
||||
|
||||
// Export markers (see comment in declareModuleMember in binder)
|
||||
ExportValue = 0x00200000, // Exported value marker
|
||||
ExportType = 0x00400000, // Exported type marker
|
||||
ExportNamespace = 0x00800000, // Exported namespace marker
|
||||
Import = 0x01000000, // Import
|
||||
Instantiated = 0x02000000, // Instantiated symbol
|
||||
Merged = 0x04000000, // Merged symbol (created during program binding)
|
||||
Transient = 0x08000000, // Transient symbol (created during type check)
|
||||
Prototype = 0x10000000, // Prototype property (no source representation)
|
||||
UnionProperty = 0x20000000, // Property in union type
|
||||
ExportValue = 0x00400000, // Exported value marker
|
||||
ExportType = 0x00800000, // Exported type marker
|
||||
ExportNamespace = 0x01000000, // Exported namespace marker
|
||||
Import = 0x02000000, // Import
|
||||
Instantiated = 0x04000000, // Instantiated symbol
|
||||
Merged = 0x08000000, // Merged symbol (created during program binding)
|
||||
Transient = 0x10000000, // Transient symbol (created during type check)
|
||||
Prototype = 0x20000000, // Prototype property (no source representation)
|
||||
UnionProperty = 0x40000000, // Property in union type
|
||||
|
||||
Enum = RegularEnum | ConstEnum,
|
||||
Variable = FunctionScopedVariable | BlockScopedVariable,
|
||||
Value = Variable | Property | EnumMember | Function | Class | Enum | ValueModule | Method | GetAccessor | SetAccessor,
|
||||
Type = Class | Interface | Enum | TypeLiteral | ObjectLiteral | TypeParameter | TypeAlias,
|
||||
@ -834,8 +836,9 @@ module ts {
|
||||
FunctionExcludes = Value & ~(Function | ValueModule),
|
||||
ClassExcludes = (Value | Type) & ~ValueModule,
|
||||
InterfaceExcludes = Type & ~Interface,
|
||||
EnumExcludes = (Value | Type) & ~(Enum | ValueModule),
|
||||
ValueModuleExcludes = Value & ~(Function | Class | Enum | ValueModule),
|
||||
RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules
|
||||
ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums
|
||||
ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule),
|
||||
NamespaceModuleExcludes = 0,
|
||||
MethodExcludes = Value & ~Method,
|
||||
GetAccessorExcludes = Value & ~SetAccessor,
|
||||
@ -867,7 +870,8 @@ module ts {
|
||||
members?: SymbolTable; // Class, interface or literal instance members
|
||||
exports?: SymbolTable; // Module exports
|
||||
exportSymbol?: Symbol; // Exported symbol associated with this symbol
|
||||
valueDeclaration?: Declaration // First value declaration of the symbol
|
||||
valueDeclaration?: Declaration // First value declaration of the symbol,
|
||||
constEnumOnlyModule?: boolean // For modules - if true - module contains only const enums or other modules with only const enums.
|
||||
}
|
||||
|
||||
export interface SymbolLinks {
|
||||
@ -886,7 +890,7 @@ module ts {
|
||||
[index: string]: Symbol;
|
||||
}
|
||||
|
||||
export enum NodeCheckFlags {
|
||||
export const enum NodeCheckFlags {
|
||||
TypeChecked = 0x00000001, // Node has been type checked
|
||||
LexicalThis = 0x00000002, // Lexical 'this' reference
|
||||
CaptureThis = 0x00000004, // Lexical 'this' used in body
|
||||
@ -911,7 +915,7 @@ module ts {
|
||||
assignmentChecks?: Map<boolean>; // Cache of assignment checks
|
||||
}
|
||||
|
||||
export enum TypeFlags {
|
||||
export const enum TypeFlags {
|
||||
Any = 0x00000001,
|
||||
String = 0x00000002,
|
||||
Number = 0x00000004,
|
||||
@ -1008,7 +1012,7 @@ module ts {
|
||||
mapper?: TypeMapper; // Instantiation mapper
|
||||
}
|
||||
|
||||
export enum SignatureKind {
|
||||
export const enum SignatureKind {
|
||||
Call,
|
||||
Construct,
|
||||
}
|
||||
@ -1028,7 +1032,7 @@ module ts {
|
||||
isolatedSignatureType?: ObjectType; // A manufactured type that just contains the signature for purposes of signature comparison
|
||||
}
|
||||
|
||||
export enum IndexKind {
|
||||
export const enum IndexKind {
|
||||
String,
|
||||
Number,
|
||||
}
|
||||
@ -1104,10 +1108,11 @@ module ts {
|
||||
target?: ScriptTarget;
|
||||
version?: boolean;
|
||||
watch?: boolean;
|
||||
preserveConstEnums?: boolean;
|
||||
[option: string]: string | number | boolean;
|
||||
}
|
||||
|
||||
export enum ModuleKind {
|
||||
export const enum ModuleKind {
|
||||
None,
|
||||
CommonJS,
|
||||
AMD,
|
||||
@ -1122,7 +1127,7 @@ module ts {
|
||||
}
|
||||
|
||||
|
||||
export enum ScriptTarget {
|
||||
export const enum ScriptTarget {
|
||||
ES3,
|
||||
ES5,
|
||||
ES6,
|
||||
@ -1144,7 +1149,7 @@ module ts {
|
||||
error?: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'.
|
||||
}
|
||||
|
||||
export enum CharacterCodes {
|
||||
export const enum CharacterCodes {
|
||||
nullCharacter = 0,
|
||||
maxAsciiCharacter = 0x7F,
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
/// <reference path='typeWriter.ts' />
|
||||
/// <reference path='syntacticCleaner.ts' />
|
||||
|
||||
enum CompilerTestType {
|
||||
const enum CompilerTestType {
|
||||
Conformance,
|
||||
Regressions,
|
||||
Test262
|
||||
|
||||
@ -2368,7 +2368,7 @@ module FourSlash {
|
||||
};
|
||||
}
|
||||
|
||||
enum State {
|
||||
const enum State {
|
||||
none,
|
||||
inSlashStarMarker,
|
||||
inObjectMarker
|
||||
|
||||
@ -30,7 +30,7 @@ module Utils {
|
||||
var global = <any>Function("return this").call(null);
|
||||
|
||||
// Setup some globals based on the current environment
|
||||
export enum ExecutionEnvironment {
|
||||
export const enum ExecutionEnvironment {
|
||||
Node,
|
||||
Browser,
|
||||
CScript
|
||||
@ -757,7 +757,6 @@ module Harness {
|
||||
case 'codepage':
|
||||
case 'createFileLog':
|
||||
case 'filename':
|
||||
case 'propagateenumconstants':
|
||||
case 'removecomments':
|
||||
case 'watch':
|
||||
case 'allowautomaticsemicoloninsertion':
|
||||
@ -772,7 +771,9 @@ module Harness {
|
||||
case 'errortruncation':
|
||||
options.noErrorTruncation = setting.value === 'false';
|
||||
break;
|
||||
|
||||
case 'preserveconstenums':
|
||||
options.preserveConstEnums = setting.value === 'true';
|
||||
break;
|
||||
default:
|
||||
throw new Error('Unsupported compiler setting ' + setting.flag);
|
||||
}
|
||||
@ -1147,7 +1148,7 @@ module Harness {
|
||||
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
|
||||
|
||||
// List of allowed metadata names
|
||||
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames"];
|
||||
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums"];
|
||||
|
||||
function extractCompilerSettings(content: string): CompilerSetting[] {
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
interface TypeWriterResult {
|
||||
line: number;
|
||||
column: number;
|
||||
syntaxKind: string;
|
||||
syntaxKind: number;
|
||||
sourceText: string;
|
||||
type: string;
|
||||
}
|
||||
@ -84,7 +84,7 @@ class TypeWriterWalker {
|
||||
this.results.push({
|
||||
line: lineAndCharacter.line - 1,
|
||||
column: lineAndCharacter.character,
|
||||
syntaxKind: ts.SyntaxKind[node.kind],
|
||||
syntaxKind: node.kind,
|
||||
sourceText: sourceText,
|
||||
type: this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.WriteOwnNameForAnyLike)
|
||||
});
|
||||
|
||||
@ -178,7 +178,7 @@ module ts.BreakpointResolver {
|
||||
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
// span on complete module if it is instantiated
|
||||
if (!isInstantiated(node)) {
|
||||
if (getModuleInstanceState(node) !== ModuleInstanceState.Instantiated) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -350,7 +350,7 @@ module ts.BreakpointResolver {
|
||||
function spanInBlock(block: Block): TypeScript.TextSpan {
|
||||
switch (block.parent.kind) {
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
if (!isInstantiated(block.parent)) {
|
||||
if (getModuleInstanceState(block.parent) !== ModuleInstanceState.Instantiated) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -407,7 +407,7 @@ module ts.BreakpointResolver {
|
||||
switch (node.parent.kind) {
|
||||
case SyntaxKind.ModuleBlock:
|
||||
// If this is not instantiated module block no bp span
|
||||
if (!isInstantiated(node.parent.parent)) {
|
||||
if (getModuleInstanceState(node.parent.parent) !== ModuleInstanceState.Instantiated) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
@ -99,26 +99,26 @@ module TypeScript {
|
||||
var start = new Date().getTime();
|
||||
// Look for:
|
||||
// import foo = module("foo")
|
||||
while (token.kind() !== SyntaxKind.EndOfFileToken) {
|
||||
if (token.kind() === SyntaxKind.ImportKeyword) {
|
||||
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) {
|
||||
if (token.kind === SyntaxKind.EqualsToken) {
|
||||
token = scanner.scan(/*allowRegularExpression:*/ false);
|
||||
|
||||
if (token.kind() === SyntaxKind.ModuleKeyword || token.kind() === SyntaxKind.RequireKeyword) {
|
||||
if (token.kind === SyntaxKind.ModuleKeyword || token.kind === SyntaxKind.RequireKeyword) {
|
||||
token = scanner.scan(/*allowRegularExpression:*/ false);
|
||||
|
||||
if (token.kind() === SyntaxKind.OpenParenToken) {
|
||||
if (token.kind === SyntaxKind.OpenParenToken) {
|
||||
token = scanner.scan(/*allowRegularExpression:*/ false);
|
||||
|
||||
lineMap.fillLineAndCharacterFromPosition(TypeScript.start(importToken, text), lineChar);
|
||||
|
||||
if (token.kind() === SyntaxKind.StringLiteral) {
|
||||
if (token.kind === SyntaxKind.StringLiteral) {
|
||||
var ref = {
|
||||
line: lineChar.line,
|
||||
character: lineChar.character,
|
||||
|
||||
@ -78,7 +78,7 @@ module TypeScript.Services.Formatting {
|
||||
}
|
||||
|
||||
// Push the token
|
||||
var currentTokenSpan = new TokenSpan(token.kind(), position, width(token));
|
||||
var currentTokenSpan = new TokenSpan(token.kind, position, width(token));
|
||||
if (!this.parent().hasSkippedOrMissingTokenChild()) {
|
||||
if (this.previousTokenSpan) {
|
||||
// Note that formatPair calls TrimWhitespaceInLineRange in between the 2 tokens
|
||||
|
||||
@ -42,12 +42,12 @@ module TypeScript.Services.Formatting {
|
||||
var sourceUnit = this.syntaxTree.sourceUnit();
|
||||
var semicolonPositionedToken = findToken(sourceUnit, caretPosition - 1);
|
||||
|
||||
if (semicolonPositionedToken.kind() === SyntaxKind.SemicolonToken) {
|
||||
if (semicolonPositionedToken.kind === SyntaxKind.SemicolonToken) {
|
||||
// Find the outer most parent that this semicolon terminates
|
||||
var current: ISyntaxElement = semicolonPositionedToken;
|
||||
while (current.parent !== null &&
|
||||
end(current.parent) === end(semicolonPositionedToken) &&
|
||||
current.parent.kind() !== SyntaxKind.List) {
|
||||
current.parent.kind !== SyntaxKind.List) {
|
||||
current = current.parent;
|
||||
}
|
||||
|
||||
@ -65,12 +65,12 @@ module TypeScript.Services.Formatting {
|
||||
var sourceUnit = this.syntaxTree.sourceUnit();
|
||||
var closeBracePositionedToken = findToken(sourceUnit, caretPosition - 1);
|
||||
|
||||
if (closeBracePositionedToken.kind() === SyntaxKind.CloseBraceToken) {
|
||||
if (closeBracePositionedToken.kind === SyntaxKind.CloseBraceToken) {
|
||||
// Find the outer most parent that this closing brace terminates
|
||||
var current: ISyntaxElement = closeBracePositionedToken;
|
||||
while (current.parent !== null &&
|
||||
end(current.parent) === end(closeBracePositionedToken) &&
|
||||
current.parent.kind() !== SyntaxKind.List) {
|
||||
current.parent.kind !== SyntaxKind.List) {
|
||||
current = current.parent;
|
||||
}
|
||||
|
||||
|
||||
@ -66,7 +66,7 @@ module TypeScript.Services.Formatting {
|
||||
}
|
||||
|
||||
public kind(): SyntaxKind {
|
||||
return this._node.kind();
|
||||
return this._node.kind;
|
||||
}
|
||||
|
||||
public hasSkippedOrMissingTokenChild(): boolean {
|
||||
|
||||
@ -99,11 +99,11 @@ module TypeScript.Services.Formatting {
|
||||
}
|
||||
|
||||
public walk(element: ISyntaxElement) {
|
||||
if (element && !isShared(element)) {
|
||||
if (element) {
|
||||
if (isToken(element)) {
|
||||
this.visitToken(<ISyntaxToken>element);
|
||||
}
|
||||
else if (element.kind() === SyntaxKind.List || element.kind() === SyntaxKind.SeparatedList) {
|
||||
else if (element.kind === SyntaxKind.List) {
|
||||
for (var i = 0, n = childCount(element); i < n; i++) {
|
||||
this.walk(childAt(element, i));
|
||||
}
|
||||
@ -148,9 +148,9 @@ module TypeScript.Services.Formatting {
|
||||
// }
|
||||
// Also in a do-while statement, the while should be indented like the parent.
|
||||
if (firstToken(this._parent.node()) === token ||
|
||||
token.kind() === SyntaxKind.OpenBraceToken || token.kind() === SyntaxKind.CloseBraceToken ||
|
||||
token.kind() === SyntaxKind.OpenBracketToken || token.kind() === SyntaxKind.CloseBracketToken ||
|
||||
(token.kind() === SyntaxKind.WhileKeyword && this._parent.node().kind() == SyntaxKind.DoStatement)) {
|
||||
token.kind === SyntaxKind.OpenBraceToken || token.kind === SyntaxKind.CloseBraceToken ||
|
||||
token.kind === SyntaxKind.OpenBracketToken || token.kind === SyntaxKind.CloseBracketToken ||
|
||||
(token.kind === SyntaxKind.WhileKeyword && this._parent.node().kind == SyntaxKind.DoStatement)) {
|
||||
return this._parent.indentationAmount();
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ module TypeScript.Services.Formatting {
|
||||
// If this is token terminating an indentation scope, leading comments should be indented to follow the children
|
||||
// indentation level and not the node
|
||||
|
||||
if (token.kind() === SyntaxKind.CloseBraceToken || token.kind() === SyntaxKind.CloseBracketToken) {
|
||||
if (token.kind === SyntaxKind.CloseBraceToken || token.kind === SyntaxKind.CloseBracketToken) {
|
||||
return (this._parent.indentationAmount() + this._parent.childIndentationAmountDelta());
|
||||
}
|
||||
return this._parent.indentationAmount();
|
||||
@ -213,7 +213,7 @@ module TypeScript.Services.Formatting {
|
||||
var indentationAmountDelta: number;
|
||||
var parentNode = parent.node();
|
||||
|
||||
switch (node.kind()) {
|
||||
switch (node.kind) {
|
||||
default:
|
||||
// General case
|
||||
// This node should follow the child indentation set by its parent
|
||||
|
||||
@ -119,7 +119,7 @@ module TypeScript.Services.Formatting {
|
||||
|
||||
}
|
||||
|
||||
if (token.kind() !== SyntaxKind.EndOfFileToken && indentNextTokenOrTrivia) {
|
||||
if (token.kind !== SyntaxKind.EndOfFileToken && indentNextTokenOrTrivia) {
|
||||
// If the last trivia item was a new line, or no trivia items were encounterd record the
|
||||
// indentation edit at the token position
|
||||
if (indentationString.length > 0) {
|
||||
|
||||
@ -13,7 +13,6 @@ module TypeScript {
|
||||
Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.",
|
||||
Unexpected_token_0_expected: "Unexpected token; '{0}' expected.",
|
||||
Trailing_comma_not_allowed: "Trailing comma not allowed.",
|
||||
AsteriskSlash_expected: "'*/' expected.",
|
||||
public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.",
|
||||
Unexpected_token: "Unexpected token.",
|
||||
Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.",
|
||||
@ -95,6 +94,7 @@ module TypeScript {
|
||||
return_statement_must_be_contained_within_a_function_body: "'return' statement must be contained within a function body.",
|
||||
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.",
|
||||
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.",
|
||||
|
||||
@ -96,6 +96,7 @@ module TypeScript {
|
||||
"'return' statement must be contained within a function body.": { "code": 1108, "category": DiagnosticCategory.Error },
|
||||
"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 },
|
||||
"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 },
|
||||
|
||||
@ -47,10 +47,6 @@
|
||||
"category": "Error",
|
||||
"code": 1009
|
||||
},
|
||||
"'*/' expected.": {
|
||||
"category": "Error",
|
||||
"code": 1010
|
||||
},
|
||||
"'public' or 'private' modifier must precede 'static'.": {
|
||||
"category": "Error",
|
||||
"code": 1011
|
||||
@ -375,6 +371,10 @@
|
||||
"category": "Error",
|
||||
"code": 1110
|
||||
},
|
||||
"Template literal cannot be used as an element name.": {
|
||||
"category": "Error",
|
||||
"code": 1111
|
||||
},
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2000
|
||||
|
||||
@ -1065,7 +1065,7 @@ module ts {
|
||||
emitOutputStatus: EmitReturnStatus;
|
||||
}
|
||||
|
||||
export enum OutputFileType {
|
||||
export const enum OutputFileType {
|
||||
JavaScript,
|
||||
SourceMap,
|
||||
Declaration
|
||||
@ -1077,7 +1077,7 @@ module ts {
|
||||
text: string;
|
||||
}
|
||||
|
||||
export enum EndOfLineState {
|
||||
export const enum EndOfLineState {
|
||||
Start,
|
||||
InMultiLineCommentTrivia,
|
||||
InSingleQuoteStringLiteral,
|
||||
@ -1780,7 +1780,7 @@ module ts {
|
||||
var buckets: Map<Map<DocumentRegistryEntry>> = {};
|
||||
|
||||
function getKeyFromCompilationSettings(settings: CompilerOptions): string {
|
||||
return "_" + ScriptTarget[settings.target]; // + "|" + settings.propagateEnumConstantoString()
|
||||
return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString()
|
||||
}
|
||||
|
||||
function getBucketForCompilationSettings(settings: CompilerOptions, createIfMissing: boolean): Map<DocumentRegistryEntry> {
|
||||
@ -2028,7 +2028,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
enum SemanticMeaning {
|
||||
const enum SemanticMeaning {
|
||||
None = 0x0,
|
||||
Value = 0x1,
|
||||
Type = 0x2,
|
||||
@ -2036,7 +2036,7 @@ module ts {
|
||||
All = Value | Type | Namespace
|
||||
}
|
||||
|
||||
enum BreakContinueSearchType {
|
||||
const enum BreakContinueSearchType {
|
||||
None = 0x0,
|
||||
Unlabeled = 0x1,
|
||||
Labeled = 0x2,
|
||||
@ -2335,24 +2335,35 @@ module ts {
|
||||
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
|
||||
var syntacticStart = new Date().getTime();
|
||||
var sourceFile = getSourceFile(filename);
|
||||
|
||||
var start = new Date().getTime();
|
||||
var currentToken = getTokenAtPosition(sourceFile, position);
|
||||
host.log("getCompletionsAtPosition: Get current token: " + (new Date().getTime() - start));
|
||||
|
||||
var start = new Date().getTime();
|
||||
// Completion not allowed inside comments, bail out if this is the case
|
||||
if (isInsideComment(sourceFile, currentToken, position)) {
|
||||
var insideComment = isInsideComment(sourceFile, currentToken, position);
|
||||
host.log("getCompletionsAtPosition: Is inside comment: " + (new Date().getTime() - start));
|
||||
|
||||
if (insideComment) {
|
||||
host.log("Returning an empty list because completion was inside a comment.");
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// The decision to provide completion depends on the previous token, so find it
|
||||
// Note: previousToken can be undefined if we are the beginning of the file
|
||||
var start = new Date().getTime();
|
||||
var previousToken = findPrecedingToken(position, sourceFile);
|
||||
host.log("getCompletionsAtPosition: Get previous token 1: " + (new Date().getTime() - start));
|
||||
|
||||
// The caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS|
|
||||
// Skip this partial identifier to the previous token
|
||||
if (previousToken && position <= previousToken.end && previousToken.kind === SyntaxKind.Identifier) {
|
||||
var start = new Date().getTime();
|
||||
previousToken = findPrecedingToken(previousToken.pos, sourceFile);
|
||||
host.log("getCompletionsAtPosition: Get previous token 2: " + (new Date().getTime() - start));
|
||||
}
|
||||
|
||||
// Check if this is a valid completion location
|
||||
@ -2383,8 +2394,10 @@ module ts {
|
||||
symbols: {},
|
||||
typeChecker: typeInfoResolver
|
||||
};
|
||||
host.log("getCompletionsAtPosition: Syntactic work: " + (new Date().getTime() - syntacticStart));
|
||||
|
||||
// Populate the completion list
|
||||
var semanticStart = new Date().getTime();
|
||||
if (isRightOfDot) {
|
||||
// Right of dot member completion list
|
||||
var symbols: Symbol[] = [];
|
||||
@ -2454,6 +2467,7 @@ module ts {
|
||||
if (!isMemberCompletion) {
|
||||
Array.prototype.push.apply(activeCompletionSession.entries, keywordCompletions);
|
||||
}
|
||||
host.log("getCompletionsAtPosition: Semantic work: " + (new Date().getTime() - semanticStart));
|
||||
|
||||
return {
|
||||
isMemberCompletion: isMemberCompletion,
|
||||
@ -2461,6 +2475,7 @@ module ts {
|
||||
};
|
||||
|
||||
function getCompletionEntriesFromSymbols(symbols: Symbol[], session: CompletionSession): void {
|
||||
var start = new Date().getTime();
|
||||
forEach(symbols, symbol => {
|
||||
var entry = createCompletionEntry(symbol, session.typeChecker);
|
||||
if (entry && !lookUp(session.symbols, entry.name)) {
|
||||
@ -2468,12 +2483,16 @@ module ts {
|
||||
session.symbols[entry.name] = symbol;
|
||||
}
|
||||
});
|
||||
host.log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - semanticStart));
|
||||
}
|
||||
|
||||
function isCompletionListBlocker(previousToken: Node): boolean {
|
||||
return isInStringOrRegularExpressionOrTemplateLiteral(previousToken) ||
|
||||
var start = new Date().getTime();
|
||||
var result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) ||
|
||||
isIdentifierDefinitionLocation(previousToken) ||
|
||||
isRightOfIllegalDot(previousToken);
|
||||
host.log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - semanticStart));
|
||||
return result;
|
||||
}
|
||||
|
||||
function isInStringOrRegularExpressionOrTemplateLiteral(previousToken: Node): boolean {
|
||||
@ -4572,7 +4591,7 @@ module ts {
|
||||
if ((<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral) {
|
||||
return SemanticMeaning.Namespace | SemanticMeaning.Value;
|
||||
}
|
||||
else if (isInstantiated(node)) {
|
||||
else if (getModuleInstanceState(node) === ModuleInstanceState.Instantiated) {
|
||||
return SemanticMeaning.Namespace | SemanticMeaning.Value;
|
||||
}
|
||||
else {
|
||||
@ -4849,7 +4868,7 @@ module ts {
|
||||
*/
|
||||
function hasValueSideModule(symbol: Symbol): boolean {
|
||||
return forEach(symbol.declarations, declaration => {
|
||||
return declaration.kind === SyntaxKind.ModuleDeclaration && isInstantiated(declaration);
|
||||
return declaration.kind === SyntaxKind.ModuleDeclaration && getModuleInstanceState(declaration) == ModuleInstanceState.Instantiated;
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -5135,9 +5154,17 @@ module ts {
|
||||
}
|
||||
|
||||
function getTodoComments(filename: string, descriptors: TodoCommentDescriptor[]): TodoComment[] {
|
||||
// Note: while getting todo comments seems like a syntactic operation, we actually
|
||||
// treat it as a semantic operation here. This is because we expect our host to call
|
||||
// this on every single file. If we treat this syntactically, then that will cause
|
||||
// us to populate and throw away the tree in our syntax tree cache for each file. By
|
||||
// treating this as a semantic operation, we can access any tree without throwing
|
||||
// anything away.
|
||||
synchronizeHostData();
|
||||
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
|
||||
var sourceFile = getCurrentSourceFile(filename);
|
||||
var sourceFile = getSourceFile(filename);
|
||||
|
||||
cancellationToken.throwIfCancellationRequested();
|
||||
|
||||
|
||||
@ -171,13 +171,13 @@ module ts {
|
||||
}
|
||||
|
||||
/// TODO: delete this, it is only needed until the VS interface is updated
|
||||
export enum LanguageVersion {
|
||||
export const enum LanguageVersion {
|
||||
EcmaScript3 = 0,
|
||||
EcmaScript5 = 1,
|
||||
EcmaScript6 = 2,
|
||||
}
|
||||
|
||||
export enum ModuleGenTarget {
|
||||
export const enum ModuleGenTarget {
|
||||
Unspecified = 0,
|
||||
Synchronous = 1,
|
||||
Asynchronous = 2,
|
||||
|
||||
@ -244,7 +244,7 @@ module ts.SignatureHelp {
|
||||
// If the node is not a subspan of its parent, this is a big problem.
|
||||
// There have been crashes that might be caused by this violation.
|
||||
if (n.pos < n.parent.pos || n.end > n.parent.end) {
|
||||
Debug.fail("Node of kind " + SyntaxKind[n.kind] + " is not a subspan of its parent of kind " + SyntaxKind[n.parent.kind]);
|
||||
Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind);
|
||||
}
|
||||
|
||||
var argumentInfo = getImmediatelyContainingArgumentInfo(n);
|
||||
|
||||
2304
src/services/syntax/SyntaxGenerator.js
Normal file
2304
src/services/syntax/SyntaxGenerator.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,365 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export class SyntaxVisitor implements ISyntaxVisitor {
|
||||
public defaultVisit(node: ISyntaxNodeOrToken): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public visitToken(token: ISyntaxToken): any {
|
||||
return this.defaultVisit(token);
|
||||
}
|
||||
|
||||
public visitSourceUnit(node: SourceUnitSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitQualifiedName(node: QualifiedNameSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitObjectType(node: ObjectTypeSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitFunctionType(node: FunctionTypeSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitArrayType(node: ArrayTypeSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitConstructorType(node: ConstructorTypeSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitGenericType(node: GenericTypeSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitTypeQuery(node: TypeQuerySyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitTupleType(node: TupleTypeSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitUnionType(node: UnionTypeSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitParenthesizedType(node: ParenthesizedTypeSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitInterfaceDeclaration(node: InterfaceDeclarationSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitFunctionDeclaration(node: FunctionDeclarationSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitModuleDeclaration(node: ModuleDeclarationSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitClassDeclaration(node: ClassDeclarationSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitEnumDeclaration(node: EnumDeclarationSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitImportDeclaration(node: ImportDeclarationSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitExportAssignment(node: ExportAssignmentSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitMemberFunctionDeclaration(node: MemberFunctionDeclarationSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitMemberVariableDeclaration(node: MemberVariableDeclarationSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitConstructorDeclaration(node: ConstructorDeclarationSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitIndexMemberDeclaration(node: IndexMemberDeclarationSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitGetAccessor(node: GetAccessorSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitSetAccessor(node: SetAccessorSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitPropertySignature(node: PropertySignatureSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitCallSignature(node: CallSignatureSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitConstructSignature(node: ConstructSignatureSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitIndexSignature(node: IndexSignatureSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitMethodSignature(node: MethodSignatureSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitBlock(node: BlockSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitIfStatement(node: IfStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitVariableStatement(node: VariableStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitExpressionStatement(node: ExpressionStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitReturnStatement(node: ReturnStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitSwitchStatement(node: SwitchStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitBreakStatement(node: BreakStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitContinueStatement(node: ContinueStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitForStatement(node: ForStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitForInStatement(node: ForInStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitEmptyStatement(node: EmptyStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitThrowStatement(node: ThrowStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitWhileStatement(node: WhileStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitTryStatement(node: TryStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitLabeledStatement(node: LabeledStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitDoStatement(node: DoStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitDebuggerStatement(node: DebuggerStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitWithStatement(node: WithStatementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitPrefixUnaryExpression(node: PrefixUnaryExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitDeleteExpression(node: DeleteExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitTypeOfExpression(node: TypeOfExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitVoidExpression(node: VoidExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitConditionalExpression(node: ConditionalExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitBinaryExpression(node: BinaryExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitPostfixUnaryExpression(node: PostfixUnaryExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitMemberAccessExpression(node: MemberAccessExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitInvocationExpression(node: InvocationExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitArrayLiteralExpression(node: ArrayLiteralExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitObjectLiteralExpression(node: ObjectLiteralExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitObjectCreationExpression(node: ObjectCreationExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitParenthesizedExpression(node: ParenthesizedExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitParenthesizedArrowFunctionExpression(node: ParenthesizedArrowFunctionExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitSimpleArrowFunctionExpression(node: SimpleArrowFunctionExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitCastExpression(node: CastExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitElementAccessExpression(node: ElementAccessExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitFunctionExpression(node: FunctionExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitOmittedExpression(node: OmittedExpressionSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitVariableDeclaration(node: VariableDeclarationSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitVariableDeclarator(node: VariableDeclaratorSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitArgumentList(node: ArgumentListSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitParameterList(node: ParameterListSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitTypeArgumentList(node: TypeArgumentListSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitTypeParameterList(node: TypeParameterListSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitHeritageClause(node: HeritageClauseSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitEqualsValueClause(node: EqualsValueClauseSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitCaseSwitchClause(node: CaseSwitchClauseSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitDefaultSwitchClause(node: DefaultSwitchClauseSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitElseClause(node: ElseClauseSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitCatchClause(node: CatchClauseSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitFinallyClause(node: FinallyClauseSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitTypeParameter(node: TypeParameterSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitConstraint(node: ConstraintSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitSimplePropertyAssignment(node: SimplePropertyAssignmentSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitFunctionPropertyAssignment(node: FunctionPropertyAssignmentSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitParameter(node: ParameterSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitEnumElement(node: EnumElementSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitTypeAnnotation(node: TypeAnnotationSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitExternalModuleReference(node: ExternalModuleReferenceSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
|
||||
public visitModuleNameModuleReference(node: ModuleNameModuleReferenceSyntax): any {
|
||||
return this.defaultVisit(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -235,7 +235,7 @@ module TypeScript.IncrementalParser {
|
||||
!_oldSourceUnitCursor.isFinished();
|
||||
}
|
||||
|
||||
function updateTokens(nodeOrToken: ISyntaxNodeOrToken): void {
|
||||
function updateTokenPosition(token: ISyntaxToken): void {
|
||||
// If we got a node or token, and we're past the range of edited text, then walk its
|
||||
// constituent tokens, making sure all their positions are correct. We don't need to
|
||||
// do this for the tokens before the edited range (since their positions couldn't have
|
||||
@ -243,16 +243,48 @@ module TypeScript.IncrementalParser {
|
||||
// edited range, as their positions will be correct when the underlying parser source
|
||||
// creates them.
|
||||
|
||||
var position = absolutePosition();
|
||||
var tokenWasMoved = isPastChangeRange() && fullStart(nodeOrToken) !== position;
|
||||
|
||||
if (tokenWasMoved) {
|
||||
setTokenFullStartWalker.position = position;
|
||||
|
||||
visitNodeOrToken(setTokenFullStartWalker, nodeOrToken);
|
||||
if (isPastChangeRange()) {
|
||||
token.setFullStart(absolutePosition());
|
||||
}
|
||||
}
|
||||
|
||||
function updateNodePosition(node: ISyntaxNode): void {
|
||||
// If we got a node or token, and we're past the range of edited text, then walk its
|
||||
// constituent tokens, making sure all their positions are correct. We don't need to
|
||||
// do this for the tokens before the edited range (since their positions couldn't have
|
||||
// been affected by the edit), and we don't need to do this for the tokens in the
|
||||
// edited range, as their positions will be correct when the underlying parser source
|
||||
// creates them.
|
||||
|
||||
if (isPastChangeRange()) {
|
||||
var position = absolutePosition();
|
||||
|
||||
var tokens = getTokens(node);
|
||||
|
||||
for (var i = 0, n = tokens.length; i < n; i++) {
|
||||
var token = tokens[i];
|
||||
token.setFullStart(position);
|
||||
|
||||
position += token.fullWidth();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getTokens(node: ISyntaxNode): ISyntaxToken[] {
|
||||
var tokens = node.__cachedTokens;
|
||||
if (!tokens) {
|
||||
tokens = [];
|
||||
tokenCollectorWalker.tokens = tokens;
|
||||
|
||||
visitNodeOrToken(tokenCollectorWalker, node);
|
||||
|
||||
node.__cachedTokens = tokens;
|
||||
tokenCollectorWalker.tokens = undefined;
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
function currentNode(): ISyntaxNode {
|
||||
if (canReadFromOldSourceUnit()) {
|
||||
// Try to read a node. If we can't then our caller will call back in and just try
|
||||
@ -260,7 +292,7 @@ module TypeScript.IncrementalParser {
|
||||
var node = tryGetNodeFromOldSourceUnit();
|
||||
if (node) {
|
||||
// Make sure the positions for the tokens in this node are correct.
|
||||
updateTokens(node);
|
||||
updateNodePosition(node);
|
||||
return node;
|
||||
}
|
||||
}
|
||||
@ -274,7 +306,7 @@ module TypeScript.IncrementalParser {
|
||||
var token = tryGetTokenFromOldSourceUnit();
|
||||
if (token) {
|
||||
// Make sure the token's position/text is correct.
|
||||
updateTokens(token);
|
||||
updateTokenPosition(token);
|
||||
return token;
|
||||
}
|
||||
}
|
||||
@ -702,6 +734,10 @@ module TypeScript.IncrementalParser {
|
||||
return isNode(element) ? <ISyntaxNode>element : undefined;
|
||||
}
|
||||
|
||||
function isEmptyList(element: ISyntaxElement) {
|
||||
return isList(element) && (<ISyntaxNodeOrToken[]>element).length === 0;
|
||||
}
|
||||
|
||||
function moveToFirstChild() {
|
||||
var nodeOrToken = currentNodeOrToken();
|
||||
if (nodeOrToken === undefined) {
|
||||
@ -721,7 +757,7 @@ module TypeScript.IncrementalParser {
|
||||
// next sibling of the empty node.
|
||||
for (var i = 0, n = childCount(nodeOrToken); i < n; i++) {
|
||||
var child = childAt(nodeOrToken, i);
|
||||
if (child && !isShared(child)) {
|
||||
if (child && !isEmptyList(child)) {
|
||||
// Great, we found a real child. Push that.
|
||||
pushElement(child, /*indexInParent:*/ i);
|
||||
|
||||
@ -749,14 +785,13 @@ module TypeScript.IncrementalParser {
|
||||
for (var i = currentPiece.indexInParent + 1, n = childCount(parent); i < n; i++) {
|
||||
var sibling = childAt(parent, i);
|
||||
|
||||
if (sibling && !isShared(sibling)) {
|
||||
if (sibling && !isEmptyList(sibling)) {
|
||||
// We found a good sibling that we can move to. Just reuse our existing piece
|
||||
// so we don't have to push/pop.
|
||||
currentPiece.element = sibling;
|
||||
currentPiece.indexInParent = i;
|
||||
|
||||
// The sibling might have been a list. Move to it's first child. it must have
|
||||
// one since this was a non-shared element.
|
||||
// The sibling might have been a list. Move to it's first child.
|
||||
moveToFirstChildIfList();
|
||||
return;
|
||||
}
|
||||
@ -777,7 +812,7 @@ module TypeScript.IncrementalParser {
|
||||
function moveToFirstChildIfList(): void {
|
||||
var element = pieces[currentPieceIndex].element;
|
||||
|
||||
if (isList(element) || isSeparatedList(element)) {
|
||||
if (isList(element)) {
|
||||
// We cannot ever get an empty list in our piece path. Empty lists are 'shared' and
|
||||
// we make sure to filter that out before pushing any children.
|
||||
// Debug.assert(childCount(element) > 0);
|
||||
@ -841,21 +876,17 @@ module TypeScript.IncrementalParser {
|
||||
// A simple walker we use to hit all the tokens of a node and update their positions when they
|
||||
// are reused in a different location because of an incremental parse.
|
||||
|
||||
class SetTokenFullStartWalker extends SyntaxWalker {
|
||||
public position: number;
|
||||
class TokenCollectorWalker extends SyntaxWalker {
|
||||
public tokens: ISyntaxToken[] = [];
|
||||
|
||||
public visitToken(token: ISyntaxToken): void {
|
||||
var position = this.position;
|
||||
token.setFullStart(position);
|
||||
|
||||
this.position = position + token.fullWidth();
|
||||
this.tokens.push(token);
|
||||
}
|
||||
}
|
||||
|
||||
var setTokenFullStartWalker = new SetTokenFullStartWalker();
|
||||
var tokenCollectorWalker = new TokenCollectorWalker();
|
||||
|
||||
export function parse(oldSyntaxTree: SyntaxTree, textChangeRange: TextChangeRange, newText: ISimpleText): SyntaxTree {
|
||||
Debug.assert(oldSyntaxTree.isConcrete(), "Can only incrementally parse a concrete syntax tree.");
|
||||
if (textChangeRange.isUnchanged()) {
|
||||
return oldSyntaxTree;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -20,7 +20,7 @@ module TypeScript.PrettyPrinter {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lastToken(element1).kind() === SyntaxKind.CloseBraceToken) {
|
||||
if (lastToken(element1).kind === SyntaxKind.CloseBraceToken) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ module TypeScript.PrettyPrinter {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lastToken(element1).kind() === SyntaxKind.CloseBraceToken) {
|
||||
if (lastToken(element1).kind === SyntaxKind.CloseBraceToken) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ module TypeScript.PrettyPrinter {
|
||||
this.ensureSpace();
|
||||
}
|
||||
|
||||
visitNodeOrToken(this, childAt(list, i));
|
||||
visitNodeOrToken(this, list[i]);
|
||||
}
|
||||
else {
|
||||
this.appendToken(<ISyntaxToken>childAt(list, i));
|
||||
@ -165,7 +165,7 @@ module TypeScript.PrettyPrinter {
|
||||
this.ensureNewLine();
|
||||
}
|
||||
|
||||
visitNodeOrToken(this, childAt(list, i));
|
||||
visitNodeOrToken(this, list[i]);
|
||||
}
|
||||
else {
|
||||
this.appendToken(<ISyntaxToken>childAt(list, i));
|
||||
@ -278,7 +278,7 @@ module TypeScript.PrettyPrinter {
|
||||
}
|
||||
|
||||
for (var i = 0, n = childCount(node.typeMembers); i < n; i++) {
|
||||
visitNodeOrToken(this, childAt(node.typeMembers, i));
|
||||
visitNodeOrToken(this, node.typeMembers[i]);
|
||||
|
||||
if (appendNewLines) {
|
||||
this.ensureNewLine();
|
||||
@ -552,7 +552,7 @@ module TypeScript.PrettyPrinter {
|
||||
public visitBinaryExpression(node: BinaryExpressionSyntax): void {
|
||||
visitNodeOrToken(this, node.left);
|
||||
|
||||
if (node.operatorToken.kind() !== SyntaxKind.CommaToken) {
|
||||
if (node.operatorToken.kind !== SyntaxKind.CommaToken) {
|
||||
this.ensureSpace();
|
||||
}
|
||||
|
||||
@ -628,7 +628,7 @@ module TypeScript.PrettyPrinter {
|
||||
}
|
||||
|
||||
private appendBlockOrStatement(node: IStatementSyntax): void {
|
||||
if (node.kind() === SyntaxKind.Block) {
|
||||
if (node.kind === SyntaxKind.Block) {
|
||||
this.ensureSpace();
|
||||
visitNodeOrToken(this, node);
|
||||
}
|
||||
@ -654,7 +654,7 @@ module TypeScript.PrettyPrinter {
|
||||
this.ensureNewLine();
|
||||
this.appendToken(node.elseKeyword);
|
||||
|
||||
if (node.statement.kind() === SyntaxKind.IfStatement) {
|
||||
if (node.statement.kind === SyntaxKind.IfStatement) {
|
||||
this.ensureSpace();
|
||||
visitNodeOrToken(this, node.statement);
|
||||
}
|
||||
@ -774,9 +774,9 @@ module TypeScript.PrettyPrinter {
|
||||
}
|
||||
|
||||
private appendSwitchClauseStatements(node: ISwitchClauseSyntax): void {
|
||||
if (childCount(node.statements) === 1 && childAt(node.statements, 0).kind() === SyntaxKind.Block) {
|
||||
if (childCount(node.statements) === 1 && childAt(node.statements, 0).kind === SyntaxKind.Block) {
|
||||
this.ensureSpace();
|
||||
visitNodeOrToken(this, childAt(node.statements, 0));
|
||||
visitNodeOrToken(this, node.statements[0]);
|
||||
}
|
||||
else if (childCount(node.statements) > 0) {
|
||||
this.ensureNewLine();
|
||||
@ -1023,5 +1023,23 @@ module TypeScript.PrettyPrinter {
|
||||
this.appendToken(node.debuggerKeyword);
|
||||
this.appendToken(node.semicolonToken);
|
||||
}
|
||||
|
||||
public visitTemplateExpression(node: TemplateExpressionSyntax): void {
|
||||
this.appendToken(node.templateStartToken);
|
||||
this.ensureSpace();
|
||||
this.appendSpaceList(node.templateClauses);
|
||||
}
|
||||
|
||||
public visitTemplateClause(node: TemplateClauseSyntax): void {
|
||||
visitNodeOrToken(this, node.expression);
|
||||
this.ensureSpace();
|
||||
this.appendToken(node.templateMiddleOrEndToken);
|
||||
}
|
||||
|
||||
public visitTemplateAccessExpression(node: TemplateAccessExpressionSyntax): void {
|
||||
visitNodeOrToken(this, node.expression);
|
||||
this.ensureSpace();
|
||||
visitNodeOrToken(this, node.templateExpression);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,9 +17,7 @@
|
||||
///<reference path='syntaxElement.ts' />
|
||||
///<reference path='syntaxFacts2.ts' />
|
||||
///<reference path='syntaxList.ts' />
|
||||
///<reference path='syntaxNode.ts' />
|
||||
///<reference path='syntaxNodeOrToken.ts' />
|
||||
///<reference path='syntaxNodes.interfaces.generated.ts' />
|
||||
|
||||
// SyntaxDedenter depends on SyntaxRewriter
|
||||
// ///<reference path='syntaxDedenter.ts' />
|
||||
@ -30,6 +28,7 @@
|
||||
///<reference path='syntaxTrivia.ts' />
|
||||
///<reference path='syntaxTriviaList.ts' />
|
||||
///<reference path='syntaxUtilities.ts' />
|
||||
///<reference path='syntaxUtilities.generated.ts' />
|
||||
///<reference path='syntaxVisitor.generated.ts' />
|
||||
///<reference path='syntaxWalker.generated.ts' />
|
||||
|
||||
@ -41,6 +40,7 @@
|
||||
///<reference path='parser.ts' />
|
||||
|
||||
// Concrete nodes depend on the parser.
|
||||
///<reference path='syntaxInterfaces.generated.ts' />
|
||||
///<reference path='syntaxNodes.concrete.generated.ts' />
|
||||
|
||||
// SyntaxTree depends on PositionTrackingWalker
|
||||
|
||||
@ -60,84 +60,52 @@ module TypeScript.Scanner {
|
||||
// This gives us 23bit for width (or 8MB of width which should be enough for any codebase).
|
||||
|
||||
enum ScannerConstants {
|
||||
LargeTokenFullStartShift = 4,
|
||||
LargeTokenFullWidthShift = 7,
|
||||
LargeTokenLeadingTriviaBitMask = 0x01, // 00000001
|
||||
LargeTokenLeadingCommentBitMask = 0x02, // 00000010
|
||||
LargeTokenTrailingTriviaBitMask = 0x04, // 00000100
|
||||
LargeTokenTrailingCommentBitMask = 0x08, // 00001000
|
||||
LargeTokenTriviaBitMask = 0x0F, // 00001111
|
||||
LargeTokenFullWidthShift = 6,
|
||||
LargeTokenLeadingTriviaShift = 3,
|
||||
|
||||
FixedWidthTokenFullStartShift = 7,
|
||||
FixedWidthTokenMaxFullStart = 0x7FFFFF, // 23 ones.
|
||||
WhitespaceTrivia = 0x01, // 00000001
|
||||
NewlineTrivia = 0x02, // 00000010
|
||||
CommentTrivia = 0x04, // 00000100
|
||||
TriviaMask = 0x07, // 00000111
|
||||
|
||||
SmallTokenFullWidthShift = 7,
|
||||
SmallTokenFullStartShift = 12,
|
||||
SmallTokenMaxFullStart = 0x3FFFF, // 18 ones.
|
||||
SmallTokenMaxFullWidth = 0x1F, // 5 ones
|
||||
SmallTokenFullWidthMask = 0x1F, // 00011111
|
||||
|
||||
KindMask = 0x7F, // 01111111
|
||||
IsVariableWidthMask = 0x80, // 10000000
|
||||
KindMask = 0x7F, // 01111111
|
||||
IsVariableWidthMask = 0x80, // 10000000
|
||||
}
|
||||
|
||||
// Make sure our math works for packing/unpacking large fullStarts.
|
||||
Debug.assert(largeTokenUnpackFullStart(largeTokenPackFullStartAndInfo(1 << 26, 3)) === (1 << 26));
|
||||
Debug.assert(largeTokenUnpackFullStart(largeTokenPackFullStartAndInfo(3 << 25, 1)) === (3 << 25));
|
||||
Debug.assert(largeTokenUnpackFullStart(largeTokenPackFullStartAndInfo(10 << 23, 2)) === (10 << 23));
|
||||
|
||||
function fixedWidthTokenPackData(fullStart: number, kind: SyntaxKind) {
|
||||
return (fullStart << ScannerConstants.FixedWidthTokenFullStartShift) | kind;
|
||||
function largeTokenPackData(fullWidth: number, leadingTriviaInfo: number, trailingTriviaInfo: number) {
|
||||
return (fullWidth << ScannerConstants.LargeTokenFullWidthShift) | (leadingTriviaInfo << ScannerConstants.LargeTokenLeadingTriviaShift) | trailingTriviaInfo;
|
||||
}
|
||||
|
||||
function fixedWidthTokenUnpackFullStart(packedData: number) {
|
||||
return packedData >> ScannerConstants.FixedWidthTokenFullStartShift;
|
||||
function largeTokenUnpackFullWidth(packedFullWidthAndInfo: number): number {
|
||||
return packedFullWidthAndInfo >> ScannerConstants.LargeTokenFullWidthShift;
|
||||
}
|
||||
|
||||
function smallTokenPackData(fullStart: number, fullWidth: number, kind: SyntaxKind) {
|
||||
return (fullStart << ScannerConstants.SmallTokenFullStartShift) |
|
||||
(fullWidth << ScannerConstants.SmallTokenFullWidthShift) |
|
||||
kind;
|
||||
function largeTokenUnpackLeadingTriviaInfo(packedFullWidthAndInfo: number): number {
|
||||
return (packedFullWidthAndInfo >> ScannerConstants.LargeTokenLeadingTriviaShift) & ScannerConstants.TriviaMask;
|
||||
}
|
||||
|
||||
function smallTokenUnpackFullWidth(packedData: number): SyntaxKind {
|
||||
return (packedData >> ScannerConstants.SmallTokenFullWidthShift) & ScannerConstants.SmallTokenFullWidthMask;
|
||||
}
|
||||
|
||||
function smallTokenUnpackFullStart(packedData: number): number {
|
||||
return packedData >> ScannerConstants.SmallTokenFullStartShift;
|
||||
}
|
||||
|
||||
function largeTokenPackFullStartAndInfo(fullStart: number, triviaInfo: number): number {
|
||||
return (fullStart << ScannerConstants.LargeTokenFullStartShift) | triviaInfo;
|
||||
}
|
||||
|
||||
function largeTokenUnpackFullWidth(packedFullWidthAndKind: number) {
|
||||
return packedFullWidthAndKind >> ScannerConstants.LargeTokenFullWidthShift;
|
||||
}
|
||||
|
||||
function largeTokenUnpackFullStart(packedFullStartAndInfo: number): number {
|
||||
return packedFullStartAndInfo >> ScannerConstants.LargeTokenFullStartShift;
|
||||
function largeTokenUnpackTrailingTriviaInfo(packedFullWidthAndInfo: number): number {
|
||||
return packedFullWidthAndInfo & ScannerConstants.TriviaMask;
|
||||
}
|
||||
|
||||
function largeTokenUnpackHasLeadingTrivia(packed: number): boolean {
|
||||
return (packed & ScannerConstants.LargeTokenLeadingTriviaBitMask) !== 0;
|
||||
return largeTokenUnpackLeadingTriviaInfo(packed) !== 0;
|
||||
}
|
||||
|
||||
function largeTokenUnpackHasTrailingTrivia(packed: number): boolean {
|
||||
return (packed & ScannerConstants.LargeTokenTrailingTriviaBitMask) !== 0;
|
||||
return largeTokenUnpackTrailingTriviaInfo(packed) !== 0;
|
||||
}
|
||||
|
||||
function hasComment(info: number) {
|
||||
return (info & ScannerConstants.CommentTrivia) !== 0;
|
||||
}
|
||||
|
||||
function largeTokenUnpackHasLeadingComment(packed: number): boolean {
|
||||
return (packed & ScannerConstants.LargeTokenLeadingCommentBitMask) !== 0;
|
||||
return hasComment(largeTokenUnpackLeadingTriviaInfo(packed));
|
||||
}
|
||||
|
||||
function largeTokenUnpackHasTrailingComment(packed: number): boolean {
|
||||
return (packed & ScannerConstants.LargeTokenTrailingCommentBitMask) !== 0;
|
||||
}
|
||||
|
||||
function largeTokenUnpackTriviaInfo(packed: number): number {
|
||||
return packed & ScannerConstants.LargeTokenTriviaBitMask;
|
||||
return hasComment(largeTokenUnpackTrailingTriviaInfo(packed));
|
||||
}
|
||||
|
||||
var isKeywordStartCharacter: number[] = ArrayUtilities.createArray<number>(CharacterCodes.maxAsciiCharacter, 0);
|
||||
@ -166,7 +134,7 @@ module TypeScript.Scanner {
|
||||
// These tokens are contextually created based on parsing decisions. We can't reuse
|
||||
// them in incremental scenarios as we may be in a context where the parser would not
|
||||
// create them.
|
||||
switch (token.kind()) {
|
||||
switch (token.kind) {
|
||||
// Created by the parser when it sees / or /= in a location where it needs an expression.
|
||||
case SyntaxKind.RegularExpressionLiteral:
|
||||
|
||||
@ -178,6 +146,11 @@ module TypeScript.Scanner {
|
||||
case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken:
|
||||
return true;
|
||||
|
||||
// Created by the parser when it sees } while parsing a template expression.
|
||||
case SyntaxKind.TemplateMiddleToken:
|
||||
case SyntaxKind.TemplateEndToken:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return token.isKeywordConvertedToIdentifier();
|
||||
}
|
||||
@ -246,50 +219,59 @@ 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 _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any;
|
||||
public parent: ISyntaxElement;
|
||||
|
||||
constructor(private _packedData: number) {
|
||||
constructor(private _fullStart: number, public kind: SyntaxKind) {
|
||||
}
|
||||
|
||||
public setFullStart(fullStart: number): void {
|
||||
this._packedData = fixedWidthTokenPackData(fullStart, this.kind());
|
||||
this._fullStart = fullStart;
|
||||
}
|
||||
|
||||
public childCount() { return 0 }
|
||||
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
|
||||
public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) }
|
||||
|
||||
public isIncrementallyUnusable(): boolean { return false; }
|
||||
public isKeywordConvertedToIdentifier(): boolean { return false; }
|
||||
public hasSkippedToken(): boolean { return false; }
|
||||
public fullText(): string { return SyntaxFacts.getText(this.kind()); }
|
||||
public fullText(): string { return SyntaxFacts.getText(this.kind); }
|
||||
public text(): string { return this.fullText(); }
|
||||
public leadingTrivia(): ISyntaxTriviaList { return Syntax.emptyTriviaList; }
|
||||
public trailingTrivia(): ISyntaxTriviaList { return Syntax.emptyTriviaList; }
|
||||
public leadingTriviaWidth(): number { return 0; }
|
||||
public trailingTriviaWidth(): number { return 0; }
|
||||
|
||||
public kind(): SyntaxKind { return this._packedData & ScannerConstants.KindMask; }
|
||||
public fullWidth(): number { return this.fullText().length; }
|
||||
public fullStart(): number { return fixedWidthTokenUnpackFullStart(this._packedData); }
|
||||
public fullWidth(): number { return fixedWidthTokenLength(this.kind); }
|
||||
public fullStart(): number { return this._fullStart; }
|
||||
public hasLeadingTrivia(): boolean { return false; }
|
||||
public hasTrailingTrivia(): boolean { return false; }
|
||||
public hasLeadingComment(): boolean { return false; }
|
||||
public hasTrailingComment(): boolean { return false; }
|
||||
public clone(): ISyntaxToken { return new FixedWidthTokenWithNoTrivia(this._packedData); }
|
||||
public clone(): ISyntaxToken { return new FixedWidthTokenWithNoTrivia(this._fullStart, this.kind); }
|
||||
}
|
||||
|
||||
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 _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any;
|
||||
public parent: ISyntaxElement;
|
||||
|
||||
private cachedText: string;
|
||||
constructor(private _packedFullStartAndInfo: number, private _packedFullWidthAndKind: number, cachedText: string) {
|
||||
|
||||
constructor(private _fullStart: number, public kind: SyntaxKind, private _packedFullWidthAndInfo: number, cachedText: string) {
|
||||
if (cachedText !== undefined) {
|
||||
this.cachedText = cachedText;
|
||||
}
|
||||
}
|
||||
|
||||
public setFullStart(fullStart: number): void {
|
||||
this._packedFullStartAndInfo = largeTokenPackFullStartAndInfo(fullStart,
|
||||
largeTokenUnpackTriviaInfo(this._packedFullStartAndInfo));
|
||||
this._fullStart = fullStart;
|
||||
}
|
||||
|
||||
public childCount() { return 0 }
|
||||
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
|
||||
public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) }
|
||||
|
||||
private syntaxTreeText(text: ISimpleText) {
|
||||
var result = text || syntaxTree(this).text;
|
||||
Debug.assert(result);
|
||||
@ -306,7 +288,7 @@ module TypeScript.Scanner {
|
||||
|
||||
public text(): string {
|
||||
var cachedText = this.cachedText;
|
||||
return cachedText !== undefined ? cachedText : SyntaxFacts.getText(this.kind());
|
||||
return cachedText !== undefined ? cachedText : SyntaxFacts.getText(this.kind);
|
||||
}
|
||||
|
||||
public leadingTrivia(text?: ISimpleText): ISyntaxTriviaList { return leadingTrivia(this, this.syntaxTreeText(text)); }
|
||||
@ -320,14 +302,13 @@ module TypeScript.Scanner {
|
||||
return trailingTriviaWidth(this, this.syntaxTreeText(text));
|
||||
}
|
||||
|
||||
public kind(): SyntaxKind { return this._packedFullWidthAndKind & ScannerConstants.KindMask; }
|
||||
public fullWidth(): number { return largeTokenUnpackFullWidth(this._packedFullWidthAndKind); }
|
||||
public fullStart(): number { return largeTokenUnpackFullStart(this._packedFullStartAndInfo); }
|
||||
public hasLeadingTrivia(): boolean { return largeTokenUnpackHasLeadingTrivia(this._packedFullStartAndInfo); }
|
||||
public hasTrailingTrivia(): boolean { return largeTokenUnpackHasTrailingTrivia(this._packedFullStartAndInfo); }
|
||||
public hasLeadingComment(): boolean { return largeTokenUnpackHasLeadingComment(this._packedFullStartAndInfo); }
|
||||
public hasTrailingComment(): boolean { return largeTokenUnpackHasTrailingComment(this._packedFullStartAndInfo); }
|
||||
public clone(): ISyntaxToken { return new LargeScannerToken(this._packedFullStartAndInfo, this._packedFullWidthAndKind, this.cachedText); }
|
||||
public fullWidth(): number { return largeTokenUnpackFullWidth(this._packedFullWidthAndInfo); }
|
||||
public fullStart(): number { return this._fullStart; }
|
||||
public hasLeadingTrivia(): boolean { return largeTokenUnpackHasLeadingTrivia(this._packedFullWidthAndInfo); }
|
||||
public hasTrailingTrivia(): boolean { return largeTokenUnpackHasTrailingTrivia(this._packedFullWidthAndInfo); }
|
||||
public hasLeadingComment(): boolean { return largeTokenUnpackHasLeadingComment(this._packedFullWidthAndInfo); }
|
||||
public hasTrailingComment(): boolean { return largeTokenUnpackHasTrailingComment(this._packedFullWidthAndInfo); }
|
||||
public clone(): ISyntaxToken { return new LargeScannerToken(this._fullStart, this.kind, this._packedFullWidthAndInfo, this.cachedText); }
|
||||
}
|
||||
|
||||
export interface DiagnosticCallback {
|
||||
@ -368,12 +349,13 @@ module TypeScript.Scanner {
|
||||
}
|
||||
|
||||
function reset(_text: ISimpleText, _start: number, _end: number) {
|
||||
Debug.assert(_start <= _text.length(), "Token's start was not within the bounds of text: " + _start + " - [0, " + _text.length() + ")");
|
||||
Debug.assert(_end <= _text.length(), "Token's end was not within the bounds of text: " + _end + " - [0, " + _text.length() + ")");
|
||||
var textLength = _text.length();
|
||||
Debug.assert(_start <= textLength, "Token's start was not within the bounds of text.");
|
||||
Debug.assert(_end <= textLength, "Token's end was not within the bounds of text:");
|
||||
|
||||
if (!str || text !== _text) {
|
||||
text = _text;
|
||||
str = _text.substr(0, _text.length());
|
||||
str = _text.substr(0, textLength);
|
||||
}
|
||||
|
||||
start = _start;
|
||||
@ -400,20 +382,14 @@ module TypeScript.Scanner {
|
||||
((kindAndIsVariableWidth & ScannerConstants.IsVariableWidthMask) === 0);
|
||||
|
||||
if (isFixedWidth &&
|
||||
leadingTriviaInfo === 0 && trailingTriviaInfo === 0 &&
|
||||
fullStart <= ScannerConstants.FixedWidthTokenMaxFullStart &&
|
||||
(kindAndIsVariableWidth & ScannerConstants.IsVariableWidthMask) === 0) {
|
||||
leadingTriviaInfo === 0 && trailingTriviaInfo === 0) {
|
||||
|
||||
return new FixedWidthTokenWithNoTrivia((fullStart << ScannerConstants.FixedWidthTokenFullStartShift) | kind);
|
||||
return new FixedWidthTokenWithNoTrivia(fullStart, kind);
|
||||
}
|
||||
else {
|
||||
// inline the packing logic for perf.
|
||||
var packedFullStartAndTriviaInfo = (fullStart << ScannerConstants.LargeTokenFullStartShift) |
|
||||
leadingTriviaInfo | (trailingTriviaInfo << 2);
|
||||
|
||||
var packedFullWidthAndKind = (fullWidth << ScannerConstants.LargeTokenFullWidthShift) | kind;
|
||||
var packedFullWidthAndInfo = largeTokenPackData(fullWidth, leadingTriviaInfo, trailingTriviaInfo);
|
||||
var cachedText = isFixedWidth ? undefined : text.substr(start, end - start);
|
||||
return new LargeScannerToken(packedFullStartAndTriviaInfo, packedFullWidthAndKind, cachedText);
|
||||
return new LargeScannerToken(fullStart, kind, packedFullWidthAndInfo, cachedText);
|
||||
}
|
||||
}
|
||||
|
||||
@ -523,7 +499,7 @@ module TypeScript.Scanner {
|
||||
case CharacterCodes.formFeed:
|
||||
index++;
|
||||
// we have trivia
|
||||
result |= 1;
|
||||
result |= ScannerConstants.WhitespaceTrivia;
|
||||
continue;
|
||||
|
||||
case CharacterCodes.carriageReturn:
|
||||
@ -532,10 +508,12 @@ module TypeScript.Scanner {
|
||||
}
|
||||
// fall through.
|
||||
case CharacterCodes.lineFeed:
|
||||
case CharacterCodes.paragraphSeparator:
|
||||
case CharacterCodes.lineSeparator:
|
||||
index++;
|
||||
|
||||
// we have trivia
|
||||
result |= 1;
|
||||
result |= ScannerConstants.NewlineTrivia;
|
||||
|
||||
// If we're consuming leading trivia, then we will continue consuming more
|
||||
// trivia (including newlines) up to the first token we see. If we're
|
||||
@ -551,14 +529,14 @@ module TypeScript.Scanner {
|
||||
var ch2 = str.charCodeAt(index + 1);
|
||||
if (ch2 === CharacterCodes.slash) {
|
||||
// we have a comment, and we have trivia
|
||||
result |= 3;
|
||||
result |= ScannerConstants.CommentTrivia;
|
||||
skipSingleLineCommentTrivia();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch2 === CharacterCodes.asterisk) {
|
||||
// we have a comment, and we have trivia
|
||||
result |= 3;
|
||||
result |= ScannerConstants.CommentTrivia;
|
||||
skipMultiLineCommentTrivia();
|
||||
continue;
|
||||
}
|
||||
@ -568,8 +546,8 @@ module TypeScript.Scanner {
|
||||
return result;
|
||||
|
||||
default:
|
||||
if (ch > CharacterCodes.maxAsciiCharacter && slowScanTriviaInfo(ch)) {
|
||||
result |= 1;
|
||||
if (ch > CharacterCodes.maxAsciiCharacter && slowScanWhitespaceTriviaInfo(ch)) {
|
||||
result |= ScannerConstants.WhitespaceTrivia;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -580,7 +558,7 @@ module TypeScript.Scanner {
|
||||
return result;
|
||||
}
|
||||
|
||||
function slowScanTriviaInfo(ch: number): boolean {
|
||||
function slowScanWhitespaceTriviaInfo(ch: number): boolean {
|
||||
switch (ch) {
|
||||
case CharacterCodes.nonBreakingSpace:
|
||||
case CharacterCodes.enQuad:
|
||||
@ -598,8 +576,6 @@ module TypeScript.Scanner {
|
||||
case CharacterCodes.narrowNoBreakSpace:
|
||||
case CharacterCodes.ideographicSpace:
|
||||
case CharacterCodes.byteOrderMark:
|
||||
case CharacterCodes.paragraphSeparator:
|
||||
case CharacterCodes.lineSeparator:
|
||||
index++;
|
||||
return true;
|
||||
|
||||
@ -700,7 +676,7 @@ module TypeScript.Scanner {
|
||||
|
||||
while (true) {
|
||||
if (index === end) {
|
||||
reportDiagnostic(end, 0, DiagnosticCode.AsteriskSlash_expected, undefined);
|
||||
reportDiagnostic(end, 0, DiagnosticCode._0_expected, ["*/"]);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -742,10 +718,10 @@ module TypeScript.Scanner {
|
||||
index++;
|
||||
|
||||
switch (character) {
|
||||
case CharacterCodes.exclamation /*33*/: return scanExclamationToken();
|
||||
case CharacterCodes.exclamation/*33*/: return scanExclamationToken();
|
||||
case CharacterCodes.doubleQuote/*34*/: return scanStringLiteral(character);
|
||||
case CharacterCodes.percent /*37*/: return scanPercentToken();
|
||||
case CharacterCodes.ampersand /*38*/: return scanAmpersandToken();
|
||||
case CharacterCodes.percent/*37*/: return scanPercentToken();
|
||||
case CharacterCodes.ampersand/*38*/: return scanAmpersandToken();
|
||||
case CharacterCodes.singleQuote/*39*/: return scanStringLiteral(character);
|
||||
case CharacterCodes.openParen/*40*/: return SyntaxKind.OpenParenToken;
|
||||
case CharacterCodes.closeParen/*41*/: return SyntaxKind.CloseParenToken;
|
||||
@ -771,10 +747,11 @@ module TypeScript.Scanner {
|
||||
case CharacterCodes.openBracket/*91*/: return SyntaxKind.OpenBracketToken;
|
||||
case CharacterCodes.closeBracket/*93*/: return SyntaxKind.CloseBracketToken;
|
||||
case CharacterCodes.caret/*94*/: return scanCaretToken();
|
||||
case CharacterCodes.backtick/*96*/: return scanTemplateToken(character);
|
||||
|
||||
case CharacterCodes.openBrace/*123*/: return SyntaxKind.OpenBraceToken;
|
||||
case CharacterCodes.bar/*124*/: return scanBarToken();
|
||||
case CharacterCodes.closeBrace/*125*/: return SyntaxKind.CloseBraceToken;
|
||||
case CharacterCodes.closeBrace/*125*/: return scanCloseBraceToken(allowContextualToken, character);
|
||||
case CharacterCodes.tilde/*126*/: return SyntaxKind.TildeToken;
|
||||
}
|
||||
|
||||
@ -1073,6 +1050,39 @@ module TypeScript.Scanner {
|
||||
}
|
||||
}
|
||||
|
||||
function scanCloseBraceToken(allowContextualToken: boolean, startChar: number): SyntaxKind {
|
||||
return allowContextualToken ? scanTemplateToken(startChar) : SyntaxKind.CloseBraceToken;
|
||||
}
|
||||
|
||||
function scanTemplateToken(startChar: number): SyntaxKind {
|
||||
var startedWithBacktick = startChar === CharacterCodes.backtick;
|
||||
|
||||
while (true) {
|
||||
if (index === end) {
|
||||
// Hit the end of the file.
|
||||
reportDiagnostic(end, 0, DiagnosticCode._0_expected, ["`"]);
|
||||
break;
|
||||
}
|
||||
|
||||
var ch = str.charCodeAt(index);
|
||||
index++;
|
||||
|
||||
if (ch === CharacterCodes.backtick) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (ch === CharacterCodes.$ &&
|
||||
index < end &&
|
||||
str.charCodeAt(index) === CharacterCodes.openBrace) {
|
||||
|
||||
index++;
|
||||
return startedWithBacktick ? SyntaxKind.TemplateStartToken : SyntaxKind.TemplateMiddleToken;
|
||||
}
|
||||
}
|
||||
|
||||
return startedWithBacktick ? SyntaxKind.NoSubstitutionTemplateToken : SyntaxKind.TemplateEndToken;
|
||||
}
|
||||
|
||||
function scanAmpersandToken(): SyntaxKind {
|
||||
var character = str.charCodeAt(index);
|
||||
if (character === CharacterCodes.equals) {
|
||||
@ -1638,11 +1648,14 @@ module TypeScript.Scanner {
|
||||
|
||||
function resetToPosition(absolutePosition: number): void {
|
||||
Debug.assert(absolutePosition <= text.length(), "Trying to set the position outside the bounds of the text!");
|
||||
var resetBackward = absolutePosition <= _absolutePosition;
|
||||
|
||||
_absolutePosition = absolutePosition;
|
||||
|
||||
// First, remove any diagnostics that came after this position.
|
||||
removeDiagnosticsOnOrAfterPosition(absolutePosition);
|
||||
if (resetBackward) {
|
||||
// First, remove any diagnostics that came after this position.
|
||||
removeDiagnosticsOnOrAfterPosition(absolutePosition);
|
||||
}
|
||||
|
||||
// Now, tell our sliding window to throw away all tokens after this position as well.
|
||||
slidingWindow.disgardAllItemsFromCurrentIndexOnwards();
|
||||
@ -1654,7 +1667,7 @@ module TypeScript.Scanner {
|
||||
|
||||
function currentContextualToken(): ISyntaxToken {
|
||||
// We better be on a / or > token right now.
|
||||
// Debug.assert(SyntaxFacts.isAnyDivideToken(currentToken().kind()));
|
||||
// Debug.assert(SyntaxFacts.isAnyDivideToken(currentToken().kind));
|
||||
|
||||
// First, we're going to rewind all our data to the point where this / or /= token started.
|
||||
// That's because if it does turn out to be a regular expression, then any tokens or token
|
||||
@ -1674,7 +1687,7 @@ module TypeScript.Scanner {
|
||||
|
||||
// We have better gotten some sort of regex token. Otherwise, something *very* wrong has
|
||||
// occurred.
|
||||
// Debug.assert(SyntaxFacts.isAnyDivideOrRegularExpressionToken(token.kind()));
|
||||
// Debug.assert(SyntaxFacts.isAnyDivideOrRegularExpressionToken(token.kind));
|
||||
|
||||
return token;
|
||||
}
|
||||
@ -1698,4 +1711,9 @@ module TypeScript.Scanner {
|
||||
resetToPosition: resetToPosition,
|
||||
};
|
||||
}
|
||||
|
||||
var fixedWidthArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 5, 8, 8, 7, 6, 2, 4, 5, 7, 3, 8, 2, 2, 10, 3, 4, 6, 6, 4, 5, 4, 3, 6, 3, 4, 5, 4, 5, 5, 4, 6, 7, 6, 5, 10, 9, 3, 7, 7, 9, 6, 6, 5, 3, 7, 11, 7, 3, 6, 7, 6, 3, 6, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 2, 2, 2, 1, 2];
|
||||
function fixedWidthTokenLength(kind: SyntaxKind) {
|
||||
return fixedWidthArray[kind];
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export class ScannerUtilities {
|
||||
public static identifierKind(str: string, start: number, length: number): SyntaxKind {
|
||||
export module ScannerUtilities {
|
||||
export function identifierKind(str: string, start: number, length: number): SyntaxKind {
|
||||
switch (length) {
|
||||
case 2: // do, if, in
|
||||
switch(str.charCodeAt(start)) {
|
||||
|
||||
@ -3,24 +3,13 @@
|
||||
module TypeScript.Syntax {
|
||||
export var _nextSyntaxID: number = 1;
|
||||
|
||||
export function childIndex(parent: ISyntaxElement, child: ISyntaxElement) {
|
||||
for (var i = 0, n = childCount(parent); i < n; i++) {
|
||||
var current = childAt(parent, i);
|
||||
if (current === child) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
throw Errors.invalidOperation();
|
||||
}
|
||||
|
||||
export function nodeHasSkippedOrMissingTokens(node: ISyntaxNode): boolean {
|
||||
for (var i = 0; i < childCount(node); i++) {
|
||||
var child = childAt(node, i);
|
||||
if (isToken(child)) {
|
||||
var token = <ISyntaxToken>child;
|
||||
// If a token is skipped, return true. Or if it is a missing token. The only empty token that is not missing is EOF
|
||||
if (token.hasSkippedToken() || (width(token) === 0 && token.kind() !== SyntaxKind.EndOfFileToken)) {
|
||||
if (token.hasSkippedToken() || (width(token) === 0 && token.kind !== SyntaxKind.EndOfFileToken)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -30,7 +19,7 @@ module TypeScript.Syntax {
|
||||
}
|
||||
|
||||
export function isUnterminatedStringLiteral(token: ISyntaxToken): boolean {
|
||||
if (token && token.kind() === SyntaxKind.StringLiteral) {
|
||||
if (token && token.kind === SyntaxKind.StringLiteral) {
|
||||
var text = token.text();
|
||||
return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0);
|
||||
}
|
||||
@ -66,7 +55,7 @@ module TypeScript.Syntax {
|
||||
var triviaList: ISyntaxTriviaList = undefined;
|
||||
var lastTriviaBeforeToken: ISyntaxTrivia = undefined;
|
||||
|
||||
if (positionedToken.kind() === SyntaxKind.EndOfFileToken) {
|
||||
if (positionedToken.kind === SyntaxKind.EndOfFileToken) {
|
||||
// Check if the trivia is leading on the EndOfFile token
|
||||
if (positionedToken.hasLeadingTrivia()) {
|
||||
triviaList = positionedToken.leadingTrivia();
|
||||
@ -117,14 +106,14 @@ module TypeScript.Syntax {
|
||||
var positionedToken = findToken(sourceUnit, position);
|
||||
|
||||
if (positionedToken) {
|
||||
if (positionedToken.kind() === SyntaxKind.EndOfFileToken) {
|
||||
if (positionedToken.kind === SyntaxKind.EndOfFileToken) {
|
||||
// EndOfFile token, enusre it did not follow an unterminated string literal
|
||||
positionedToken = previousToken(positionedToken);
|
||||
return positionedToken && positionedToken.trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken);
|
||||
}
|
||||
else if (position > start(positionedToken)) {
|
||||
// Ensure position falls enterily within the literal if it is terminated, or the line if it is not
|
||||
return (position < end(positionedToken) && (positionedToken.kind() === TypeScript.SyntaxKind.StringLiteral || positionedToken.kind() === TypeScript.SyntaxKind.RegularExpressionLiteral)) ||
|
||||
return (position < end(positionedToken) && (positionedToken.kind === TypeScript.SyntaxKind.StringLiteral || positionedToken.kind === TypeScript.SyntaxKind.RegularExpressionLiteral)) ||
|
||||
(position <= end(positionedToken) && isUnterminatedStringLiteral(positionedToken));
|
||||
}
|
||||
}
|
||||
@ -132,43 +121,9 @@ module TypeScript.Syntax {
|
||||
return false;
|
||||
}
|
||||
|
||||
function findSkippedTokenOnLeftInTriviaList(positionedToken: ISyntaxToken, position: number, lookInLeadingTriviaList: boolean): ISyntaxToken {
|
||||
var triviaList: TypeScript.ISyntaxTriviaList = undefined;
|
||||
var fullEnd: number;
|
||||
|
||||
if (lookInLeadingTriviaList) {
|
||||
triviaList = positionedToken.leadingTrivia();
|
||||
fullEnd = positionedToken.fullStart() + triviaList.fullWidth();
|
||||
}
|
||||
else {
|
||||
triviaList = positionedToken.trailingTrivia();
|
||||
fullEnd = TypeScript.fullEnd(positionedToken);
|
||||
}
|
||||
|
||||
if (triviaList && triviaList.hasSkippedToken()) {
|
||||
for (var i = triviaList.count() - 1; i >= 0; i--) {
|
||||
var trivia = triviaList.syntaxTriviaAt(i);
|
||||
var triviaWidth = trivia.fullWidth();
|
||||
|
||||
if (trivia.isSkippedToken() && position >= fullEnd) {
|
||||
return trivia.skippedToken();
|
||||
}
|
||||
|
||||
fullEnd -= triviaWidth;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function findSkippedTokenOnLeft(positionedToken: ISyntaxToken, position: number): ISyntaxToken {
|
||||
var positionInLeadingTriviaList = (position < start(positionedToken));
|
||||
return findSkippedTokenOnLeftInTriviaList(positionedToken, position, /*lookInLeadingTriviaList*/ positionInLeadingTriviaList);
|
||||
}
|
||||
|
||||
export function getAncestorOfKind(positionedToken: ISyntaxElement, kind: SyntaxKind): ISyntaxElement {
|
||||
while (positionedToken && positionedToken.parent) {
|
||||
if (positionedToken.parent.kind() === kind) {
|
||||
if (positionedToken.parent.kind === kind) {
|
||||
return positionedToken.parent;
|
||||
}
|
||||
|
||||
@ -184,10 +139,10 @@ module TypeScript.Syntax {
|
||||
|
||||
export function isIntegerLiteral(expression: IExpressionSyntax): boolean {
|
||||
if (expression) {
|
||||
switch (expression.kind()) {
|
||||
switch (expression.kind) {
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
var prefixExpr = <PrefixUnaryExpressionSyntax>expression;
|
||||
if (prefixExpr.operatorToken.kind() == SyntaxKind.PlusToken || prefixExpr.operatorToken.kind() === SyntaxKind.MinusToken) {
|
||||
if (prefixExpr.operatorToken.kind == SyntaxKind.PlusToken || prefixExpr.operatorToken.kind === SyntaxKind.MinusToken) {
|
||||
// Note: if there is a + or - sign, we can only allow a normal integer following
|
||||
// (and not a hex integer). i.e. -0xA is a legal expression, but it is not a
|
||||
// *literal*.
|
||||
@ -218,18 +173,14 @@ module TypeScript.Syntax {
|
||||
return <ISyntaxNode>current;
|
||||
}
|
||||
|
||||
export function findTokenOnLeft(element: ISyntaxElement, position: number, includeSkippedTokens: boolean = false): ISyntaxToken {
|
||||
var positionedToken = findToken(element, position, /*includeSkippedTokens*/ false);
|
||||
export function findTokenOnLeft(sourceUnit: SourceUnitSyntax, position: number): ISyntaxToken {
|
||||
var positionedToken = findToken(sourceUnit, position);
|
||||
var _start = start(positionedToken);
|
||||
|
||||
// Position better fall within this token.
|
||||
// Debug.assert(position >= positionedToken.fullStart());
|
||||
// Debug.assert(position < positionedToken.fullEnd() || positionedToken.token().tokenKind === SyntaxKind.EndOfFileToken);
|
||||
|
||||
if (includeSkippedTokens) {
|
||||
positionedToken = findSkippedTokenOnLeft(positionedToken, position) || positionedToken;
|
||||
}
|
||||
|
||||
// if position is after the start of the token, then this token is the token on the left.
|
||||
if (position > _start) {
|
||||
return positionedToken;
|
||||
@ -241,26 +192,22 @@ module TypeScript.Syntax {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return previousToken(positionedToken, includeSkippedTokens);
|
||||
return previousToken(positionedToken);
|
||||
}
|
||||
|
||||
export function findCompleteTokenOnLeft(element: ISyntaxElement, position: number, includeSkippedTokens: boolean = false): ISyntaxToken {
|
||||
var positionedToken = findToken(element, position, /*includeSkippedTokens*/ false);
|
||||
export function findCompleteTokenOnLeft(sourceUnit: SourceUnitSyntax, position: number): ISyntaxToken {
|
||||
var positionedToken = findToken(sourceUnit, position);
|
||||
|
||||
// Position better fall within this token.
|
||||
// Debug.assert(position >= positionedToken.fullStart());
|
||||
// Debug.assert(position < positionedToken.fullEnd() || positionedToken.token().tokenKind === SyntaxKind.EndOfFileToken);
|
||||
|
||||
if (includeSkippedTokens) {
|
||||
positionedToken = findSkippedTokenOnLeft(positionedToken, position) || positionedToken;
|
||||
}
|
||||
|
||||
// if position is after the end of the token, then this token is the token on the left.
|
||||
if (width(positionedToken) > 0 && position >= end(positionedToken)) {
|
||||
return positionedToken;
|
||||
}
|
||||
|
||||
return previousToken(positionedToken, includeSkippedTokens);
|
||||
return previousToken(positionedToken);
|
||||
}
|
||||
|
||||
export function firstTokenInLineContainingPosition(syntaxTree: SyntaxTree, position: number): ISyntaxToken {
|
||||
|
||||
@ -1,52 +1,12 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
// True if there is only a single instance of this element (and thus can be reused in many
|
||||
// places in a syntax tree). Examples of this include our empty lists. Because empty
|
||||
// lists can be found all over the tree, we want to save on memory by using this single
|
||||
// instance instead of creating new objects for each case. Note: because of this, shared
|
||||
// nodes don't have positions or parents.
|
||||
export function isShared(element: ISyntaxElement): boolean {
|
||||
var kind = element.kind();
|
||||
return (kind === SyntaxKind.List || kind === SyntaxKind.SeparatedList) && (<ISyntaxNodeOrToken[]>element).length === 0;
|
||||
}
|
||||
|
||||
export function childCount(element: ISyntaxElement): number {
|
||||
var kind = element.kind();
|
||||
if (kind === SyntaxKind.List) {
|
||||
return (<ISyntaxNodeOrToken[]>element).length;
|
||||
}
|
||||
else if (kind === SyntaxKind.SeparatedList) {
|
||||
return (<ISyntaxNodeOrToken[]>element).length + (<ISyntaxNodeOrToken[]>element).separators.length;
|
||||
}
|
||||
else if (kind >= SyntaxKind.FirstToken && kind <= SyntaxKind.LastToken) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return nodeMetadata[kind].length;
|
||||
}
|
||||
}
|
||||
|
||||
export function childAt(element: ISyntaxElement, index: number): ISyntaxElement {
|
||||
var kind = element.kind();
|
||||
if (kind === SyntaxKind.List) {
|
||||
return (<ISyntaxNodeOrToken[]>element)[index];
|
||||
}
|
||||
else if (kind === SyntaxKind.SeparatedList) {
|
||||
return (index % 2 === 0) ? (<ISyntaxNodeOrToken[]>element)[index / 2] : (<ISyntaxNodeOrToken[]>element).separators[(index - 1) / 2];
|
||||
}
|
||||
else {
|
||||
// Debug.assert(isNode(element));
|
||||
return (<any>element)[nodeMetadata[element.kind()][index]];
|
||||
}
|
||||
}
|
||||
|
||||
export function syntaxTree(element: ISyntaxElement): SyntaxTree {
|
||||
if (element) {
|
||||
Debug.assert(!isShared(element));
|
||||
// Debug.assert(!isShared(element));
|
||||
|
||||
while (element) {
|
||||
if (element.kind() === SyntaxKind.SourceUnit) {
|
||||
if (element.kind === SyntaxKind.SourceUnit) {
|
||||
return (<SourceUnitSyntax>element).syntaxTree;
|
||||
}
|
||||
|
||||
@ -58,7 +18,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
export function parsedInStrictMode(node: ISyntaxNode): boolean {
|
||||
var info = node.data;
|
||||
var info = node.__data;
|
||||
if (info === undefined) {
|
||||
return false;
|
||||
}
|
||||
@ -66,28 +26,13 @@ module TypeScript {
|
||||
return (info & SyntaxConstants.NodeParsedInStrictModeMask) !== 0;
|
||||
}
|
||||
|
||||
export function previousToken(token: ISyntaxToken, includeSkippedTokens: boolean = false): ISyntaxToken {
|
||||
if (includeSkippedTokens) {
|
||||
var triviaList = token.leadingTrivia();
|
||||
if (triviaList && triviaList.hasSkippedToken()) {
|
||||
var currentTriviaEndPosition = TypeScript.start(token);
|
||||
for (var i = triviaList.count() - 1; i >= 0; i--) {
|
||||
var trivia = triviaList.syntaxTriviaAt(i);
|
||||
if (trivia.isSkippedToken()) {
|
||||
return trivia.skippedToken();
|
||||
}
|
||||
|
||||
currentTriviaEndPosition -= trivia.fullWidth();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function previousToken(token: ISyntaxToken): ISyntaxToken {
|
||||
var start = token.fullStart();
|
||||
if (start === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return findToken(syntaxTree(token).sourceUnit(), start - 1, includeSkippedTokens);
|
||||
return findToken(syntaxTree(token).sourceUnit(), start - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,24 +48,26 @@ module TypeScript {
|
||||
* Note: findToken will always return a non-missing token with width greater than or equal to
|
||||
* 1 (except for EOF). Empty tokens synthesized by the parser are never returned.
|
||||
*/
|
||||
export function findToken(element: ISyntaxElement, position: number, includeSkippedTokens: boolean = false): ISyntaxToken {
|
||||
var endOfFileToken = tryGetEndOfFileAt(element, position);
|
||||
if (endOfFileToken) {
|
||||
return endOfFileToken;
|
||||
}
|
||||
|
||||
if (position < 0 || position >= fullWidth(element)) {
|
||||
export function findToken(sourceUnit: SourceUnitSyntax, position: number): ISyntaxToken {
|
||||
if (position < 0) {
|
||||
throw Errors.argumentOutOfRange("position");
|
||||
}
|
||||
|
||||
var positionedToken = findTokenWorker(element, position);
|
||||
|
||||
if (includeSkippedTokens) {
|
||||
return findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken;
|
||||
var token = findTokenInNodeOrToken(sourceUnit, 0, position);
|
||||
if (token) {
|
||||
Debug.assert(token.fullWidth() > 0);
|
||||
return token;
|
||||
}
|
||||
|
||||
// Could not find a better match
|
||||
return positionedToken;
|
||||
if (position === fullWidth(sourceUnit)) {
|
||||
return sourceUnit.endOfFileToken;
|
||||
}
|
||||
|
||||
if (position > fullWidth(sourceUnit)) {
|
||||
throw Errors.argumentOutOfRange("position");
|
||||
}
|
||||
|
||||
throw Errors.invalidOperation();
|
||||
}
|
||||
|
||||
export function findSkippedTokenInPositionedToken(positionedToken: ISyntaxToken, position: number): ISyntaxToken {
|
||||
@ -165,44 +112,59 @@ module TypeScript {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function findTokenWorker(element: ISyntaxElement, position: number): ISyntaxToken {
|
||||
// Debug.assert(position >= 0 && position < this.fullWidth());
|
||||
if (isToken(element)) {
|
||||
Debug.assert(fullWidth(element) > 0);
|
||||
return <ISyntaxToken>element;
|
||||
function findTokenWorker(element: ISyntaxElement, elementPosition: number, position: number): ISyntaxToken {
|
||||
if (isList(element)) {
|
||||
return findTokenInList(<ISyntaxNodeOrToken[]>element, elementPosition, position);
|
||||
}
|
||||
else {
|
||||
return findTokenInNodeOrToken(<ISyntaxNodeOrToken>element, elementPosition, position);
|
||||
}
|
||||
}
|
||||
|
||||
function findTokenInList(list: ISyntaxNodeOrToken[], elementPosition: number, position: number): ISyntaxToken {
|
||||
for (var i = 0, n = list.length; i < n; i++) {
|
||||
var child = list[i];
|
||||
|
||||
var childFullWidth = fullWidth(child);
|
||||
var elementEndPosition = elementPosition + childFullWidth;
|
||||
|
||||
if (position < elementEndPosition) {
|
||||
return findTokenWorker(child, elementPosition, position);
|
||||
}
|
||||
|
||||
elementPosition = elementEndPosition;
|
||||
}
|
||||
|
||||
if (isShared(element)) {
|
||||
// This should never have been called on this element. It has a 0 width, so the client
|
||||
// should have skipped over this.
|
||||
throw Errors.invalidOperation();
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
function findTokenInNodeOrToken(nodeOrToken: ISyntaxNodeOrToken, elementPosition: number, position: number): ISyntaxToken {
|
||||
if (isToken(nodeOrToken)) {
|
||||
return <ISyntaxToken>nodeOrToken;
|
||||
}
|
||||
|
||||
// Consider: we could use a binary search here to find the child more quickly.
|
||||
for (var i = 0, n = childCount(element); i < n; i++) {
|
||||
var child = childAt(element, i);
|
||||
var childAtFunction = getChildAtFunction(nodeOrToken);
|
||||
for (var i = 0, n = childCount(nodeOrToken); i < n; i++) {
|
||||
var child = childAtFunction(nodeOrToken, i);
|
||||
|
||||
if (child) {
|
||||
var childFullWidth = fullWidth(child);
|
||||
if (childFullWidth > 0) {
|
||||
var childFullStart = fullStart(child);
|
||||
var elementEndPosition = elementPosition + childFullWidth;
|
||||
|
||||
if (position >= childFullStart) {
|
||||
var childFullEnd = childFullStart + childFullWidth;
|
||||
|
||||
if (position < childFullEnd) {
|
||||
return findTokenWorker(child, position);
|
||||
}
|
||||
}
|
||||
if (position < elementEndPosition) {
|
||||
return findTokenWorker(child, elementPosition, position);
|
||||
}
|
||||
|
||||
elementPosition = elementEndPosition;
|
||||
}
|
||||
}
|
||||
|
||||
throw Errors.invalidOperation();
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function tryGetEndOfFileAt(element: ISyntaxElement, position: number): ISyntaxToken {
|
||||
if (element.kind() === SyntaxKind.SourceUnit && position === fullWidth(element)) {
|
||||
if (element.kind === SyntaxKind.SourceUnit && position === fullWidth(element)) {
|
||||
var sourceUnit = <SourceUnitSyntax>element;
|
||||
return sourceUnit.endOfFileToken;
|
||||
}
|
||||
@ -210,29 +172,17 @@ module TypeScript {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function nextToken(token: ISyntaxToken, text?: ISimpleText, includeSkippedTokens: boolean = false): ISyntaxToken {
|
||||
if (token.kind() === SyntaxKind.EndOfFileToken) {
|
||||
export function nextToken(token: ISyntaxToken, text?: ISimpleText): ISyntaxToken {
|
||||
if (token.kind === SyntaxKind.EndOfFileToken) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (includeSkippedTokens) {
|
||||
var triviaList = token.trailingTrivia(text);
|
||||
if (triviaList && triviaList.hasSkippedToken()) {
|
||||
for (var i = 0, n = triviaList.count(); i < n; i++) {
|
||||
var trivia = triviaList.syntaxTriviaAt(i);
|
||||
if (trivia.isSkippedToken()) {
|
||||
return trivia.skippedToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return findToken(syntaxTree(token).sourceUnit(), fullEnd(token), includeSkippedTokens);
|
||||
return findToken(syntaxTree(token).sourceUnit(), fullEnd(token));
|
||||
}
|
||||
|
||||
export function isNode(element: ISyntaxElement): boolean {
|
||||
if (element) {
|
||||
var kind = element.kind();
|
||||
var kind = element.kind;
|
||||
return kind >= SyntaxKind.FirstNode && kind <= SyntaxKind.LastNode;
|
||||
}
|
||||
|
||||
@ -245,24 +195,20 @@ module TypeScript {
|
||||
|
||||
export function isToken(element: ISyntaxElement): boolean {
|
||||
if (element) {
|
||||
return isTokenKind(element.kind());
|
||||
return isTokenKind(element.kind);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isList(element: ISyntaxElement): boolean {
|
||||
return element && element.kind() === SyntaxKind.List;
|
||||
}
|
||||
|
||||
export function isSeparatedList(element: ISyntaxElement): boolean {
|
||||
return element && element.kind() === SyntaxKind.SeparatedList;
|
||||
return element instanceof Array;
|
||||
}
|
||||
|
||||
export function syntaxID(element: ISyntaxElement): number {
|
||||
if (isShared(element)) {
|
||||
throw Errors.invalidOperation("Should not use shared syntax element as a key.");
|
||||
}
|
||||
//if (isShared(element)) {
|
||||
// throw Errors.invalidOperation("Should not use shared syntax element as a key.");
|
||||
//}
|
||||
|
||||
var obj = <any>element;
|
||||
if (obj._syntaxID === undefined) {
|
||||
@ -308,43 +254,16 @@ module TypeScript {
|
||||
|
||||
export function firstToken(element: ISyntaxElement): ISyntaxToken {
|
||||
if (element) {
|
||||
var kind = element.kind();
|
||||
var kind = element.kind;
|
||||
|
||||
if (isTokenKind(kind)) {
|
||||
return fullWidth(element) > 0 || element.kind() === SyntaxKind.EndOfFileToken ? <ISyntaxToken>element : undefined;
|
||||
return (<ISyntaxToken>element).fullWidth() > 0 || kind === SyntaxKind.EndOfFileToken ? <ISyntaxToken>element : undefined;
|
||||
}
|
||||
|
||||
if (kind === SyntaxKind.List) {
|
||||
var array = <ISyntaxNodeOrToken[]>element;
|
||||
for (var i = 0, n = array.length; i < n; i++) {
|
||||
var token = firstToken(array[i]);
|
||||
if (token) {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (kind === SyntaxKind.SeparatedList) {
|
||||
var array = <ISyntaxNodeOrToken[]>element;
|
||||
var separators = array.separators;
|
||||
for (var i = 0, n = array.length + separators.length; i < n; i++) {
|
||||
var token = firstToken(i % 2 === 0 ? array[i / 2] : separators[(i - 1) / 2]);
|
||||
if (token) {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
var metadata = nodeMetadata[kind];
|
||||
for (var i = 0, n = metadata.length; i < n; i++) {
|
||||
var child = (<any>element)[metadata[i]];
|
||||
var token = firstToken(child);
|
||||
if (token) {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
||||
if (element.kind() === SyntaxKind.SourceUnit) {
|
||||
return (<SourceUnitSyntax>element).endOfFileToken;
|
||||
for (var i = 0, n = childCount(element); i < n; i++) {
|
||||
var token = firstToken(childAt(element, i));
|
||||
if (token) {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -354,10 +273,10 @@ module TypeScript {
|
||||
|
||||
export function lastToken(element: ISyntaxElement): ISyntaxToken {
|
||||
if (isToken(element)) {
|
||||
return fullWidth(element) > 0 || element.kind() === SyntaxKind.EndOfFileToken ? <ISyntaxToken>element : undefined;
|
||||
return fullWidth(element) > 0 || element.kind === SyntaxKind.EndOfFileToken ? <ISyntaxToken>element : undefined;
|
||||
}
|
||||
|
||||
if (element.kind() === SyntaxKind.SourceUnit) {
|
||||
if (element.kind === SyntaxKind.SourceUnit) {
|
||||
return (<SourceUnitSyntax>element).endOfFileToken;
|
||||
}
|
||||
|
||||
@ -375,7 +294,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
export function fullStart(element: ISyntaxElement): number {
|
||||
Debug.assert(!isShared(element));
|
||||
// Debug.assert(!isShared(element));
|
||||
var token = isToken(element) ? <ISyntaxToken>element : firstToken(element);
|
||||
return token ? token.fullStart() : -1;
|
||||
}
|
||||
@ -385,10 +304,6 @@ module TypeScript {
|
||||
return (<ISyntaxToken>element).fullWidth();
|
||||
}
|
||||
|
||||
if (isShared(element)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var info = data(element);
|
||||
return info >>> SyntaxConstants.NodeFullWidthShift;
|
||||
}
|
||||
@ -398,28 +313,23 @@ module TypeScript {
|
||||
return (<ISyntaxToken>element).isIncrementallyUnusable();
|
||||
}
|
||||
|
||||
if (isShared(element)) {
|
||||
// All shared lists are reusable.
|
||||
return false;
|
||||
}
|
||||
|
||||
return (data(element) & SyntaxConstants.NodeIncrementallyUnusableMask) !== 0;
|
||||
}
|
||||
|
||||
function data(element: ISyntaxElement): number {
|
||||
Debug.assert(isNode(element) || isList(element) || isSeparatedList(element));
|
||||
// Debug.assert(isNode(element) || isList(element));
|
||||
|
||||
// Lists and nodes all have a 'data' element.
|
||||
var dataElement = <{ data: number }><any>element;
|
||||
var dataElement = <ISyntaxNode>element;
|
||||
|
||||
var info = dataElement.data;
|
||||
var info = dataElement.__data;
|
||||
if (info === undefined) {
|
||||
info = 0;
|
||||
}
|
||||
|
||||
if ((info & SyntaxConstants.NodeDataComputed) === 0) {
|
||||
info |= computeData(element);
|
||||
dataElement.data = info;
|
||||
dataElement.__data = info;
|
||||
}
|
||||
|
||||
return info;
|
||||
@ -431,7 +341,7 @@ module TypeScript {
|
||||
var fullWidth = 0;
|
||||
|
||||
// If we have no children (like an OmmittedExpressionSyntax), we're automatically not reusable.
|
||||
var isIncrementallyUnusable = slotCount === 0;
|
||||
var isIncrementallyUnusable = slotCount === 0 && !isList(element);
|
||||
|
||||
for (var i = 0, n = slotCount; i < n; i++) {
|
||||
var child = childAt(element, i);
|
||||
@ -483,12 +393,13 @@ module TypeScript {
|
||||
}
|
||||
|
||||
export interface ISyntaxElement {
|
||||
kind(): SyntaxKind;
|
||||
parent?: ISyntaxElement;
|
||||
kind: SyntaxKind;
|
||||
parent: ISyntaxElement;
|
||||
}
|
||||
|
||||
export interface ISyntaxNode extends ISyntaxNodeOrToken {
|
||||
data: number;
|
||||
__data: number;
|
||||
__cachedTokens: ISyntaxToken[];
|
||||
}
|
||||
|
||||
export interface IModuleReferenceSyntax extends ISyntaxNode {
|
||||
|
||||
@ -2,16 +2,8 @@
|
||||
|
||||
module TypeScript.SyntaxFacts {
|
||||
export function isDirectivePrologueElement(node: ISyntaxNodeOrToken): boolean {
|
||||
if (node.kind() === SyntaxKind.ExpressionStatement) {
|
||||
var expressionStatement = <ExpressionStatementSyntax>node;
|
||||
var expression = expressionStatement.expression;
|
||||
|
||||
if (expression.kind() === SyntaxKind.StringLiteral) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return node.kind === SyntaxKind.ExpressionStatement &&
|
||||
(<ExpressionStatementSyntax>node).expression.kind === SyntaxKind.StringLiteral;
|
||||
}
|
||||
|
||||
export function isUseStrictDirective(node: ISyntaxNodeOrToken): boolean {
|
||||
@ -23,7 +15,7 @@ module TypeScript.SyntaxFacts {
|
||||
}
|
||||
|
||||
export function isIdentifierNameOrAnyKeyword(token: ISyntaxToken): boolean {
|
||||
var tokenKind = token.kind();
|
||||
var tokenKind = token.kind;
|
||||
return tokenKind === SyntaxKind.IdentifierName || SyntaxFacts.isAnyKeyword(tokenKind);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -5,8 +5,6 @@ module TypeScript {
|
||||
// Variable width tokens, trivia and lists.
|
||||
None,
|
||||
List,
|
||||
SeparatedList,
|
||||
TriviaList,
|
||||
|
||||
// Trivia
|
||||
WhitespaceTrivia,
|
||||
@ -28,6 +26,12 @@ module TypeScript {
|
||||
NumericLiteral,
|
||||
StringLiteral,
|
||||
|
||||
// Template tokens
|
||||
NoSubstitutionTemplateToken,
|
||||
TemplateStartToken,
|
||||
TemplateMiddleToken,
|
||||
TemplateEndToken,
|
||||
|
||||
// All fixed width tokens follow.
|
||||
|
||||
// Keywords
|
||||
@ -228,6 +232,8 @@ module TypeScript {
|
||||
ElementAccessExpression,
|
||||
FunctionExpression,
|
||||
OmittedExpression,
|
||||
TemplateExpression,
|
||||
TemplateAccessExpression,
|
||||
|
||||
// Variable declarations
|
||||
VariableDeclaration,
|
||||
@ -247,6 +253,7 @@ module TypeScript {
|
||||
ElseClause,
|
||||
CatchClause,
|
||||
FinallyClause,
|
||||
TemplateClause,
|
||||
|
||||
// Generics
|
||||
TypeParameter,
|
||||
|
||||
@ -1,60 +1,53 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
interface Array<T> {
|
||||
data: number;
|
||||
separators?: TypeScript.ISyntaxToken[];
|
||||
__data: number;
|
||||
|
||||
kind(): TypeScript.SyntaxKind;
|
||||
kind: TypeScript.SyntaxKind;
|
||||
parent: TypeScript.ISyntaxElement;
|
||||
}
|
||||
|
||||
separatorCount(): number;
|
||||
separatorAt(index: number): TypeScript.ISyntaxToken;
|
||||
module TypeScript {
|
||||
export interface ISeparatedSyntaxList<T extends ISyntaxNodeOrToken> extends Array<ISyntaxNodeOrToken> {
|
||||
//separatorCount(): number;
|
||||
//separatorAt(index: number): TypeScript.ISyntaxToken;
|
||||
|
||||
//nonSeparatorCount(): number;
|
||||
//nonSeparatorAt(index: number): T;
|
||||
}
|
||||
}
|
||||
|
||||
module TypeScript {
|
||||
export function separatorCount(list: ISeparatedSyntaxList<ISyntaxNodeOrToken>) {
|
||||
return list.length >> 1;
|
||||
}
|
||||
|
||||
export function nonSeparatorCount(list: ISeparatedSyntaxList<ISyntaxNodeOrToken>) {
|
||||
return (list.length + 1) >> 1;
|
||||
}
|
||||
|
||||
export function separatorAt(list: ISeparatedSyntaxList<ISyntaxNodeOrToken>, index: number): ISyntaxToken {
|
||||
return <ISyntaxToken>list[(index << 1) + 1];
|
||||
}
|
||||
|
||||
export function nonSeparatorAt<T extends ISyntaxNodeOrToken>(list: ISeparatedSyntaxList<T>, index: number): T {
|
||||
return <T>list[index << 1];
|
||||
}
|
||||
}
|
||||
|
||||
module TypeScript.Syntax {
|
||||
var _emptyList: ISyntaxNodeOrToken[] = [];
|
||||
|
||||
var _emptySeparatedList: ISyntaxNodeOrToken[] = [];
|
||||
var _emptySeparators: ISyntaxToken[] = [];
|
||||
|
||||
_emptySeparatedList.separators = _emptySeparators;
|
||||
|
||||
function assertEmptyLists() {
|
||||
// Debug.assert(_emptyList.length === 0);
|
||||
// var separators = _emptySeparatedList.separators;
|
||||
// Debug.assert(!separators || separators.length === 0);
|
||||
function addArrayPrototypeValue(name: string, val: any) {
|
||||
if (Object.defineProperty && (<any>Array.prototype)[name] === undefined) {
|
||||
Object.defineProperty(Array.prototype, name, { value: val, writable: false });
|
||||
}
|
||||
else {
|
||||
(<any>Array.prototype)[name] = val;
|
||||
}
|
||||
}
|
||||
|
||||
Array.prototype.kind = function () {
|
||||
return this.separators === undefined ? SyntaxKind.List : SyntaxKind.SeparatedList;
|
||||
}
|
||||
|
||||
Array.prototype.separatorCount = function (): number {
|
||||
assertEmptyLists();
|
||||
// Debug.assert(this.kind === SyntaxKind.SeparatedList);
|
||||
return this.separators.length;
|
||||
}
|
||||
|
||||
Array.prototype.separatorAt = function (index: number): ISyntaxToken {
|
||||
assertEmptyLists();
|
||||
// Debug.assert(this.kind === SyntaxKind.SeparatedList);
|
||||
// Debug.assert(index >= 0 && index < this.separators.length);
|
||||
return this.separators[index];
|
||||
}
|
||||
|
||||
export function emptyList<T extends ISyntaxNodeOrToken>(): T[] {
|
||||
return <T[]><any>_emptyList;
|
||||
}
|
||||
|
||||
export function emptySeparatedList<T extends ISyntaxNodeOrToken>(): T[] {
|
||||
return <T[]><any>_emptySeparatedList;
|
||||
}
|
||||
addArrayPrototypeValue("kind", SyntaxKind.List);
|
||||
|
||||
export function list<T extends ISyntaxNodeOrToken>(nodes: T[]): T[] {
|
||||
if (!nodes || nodes.length === 0) {
|
||||
return emptyList<T>();
|
||||
}
|
||||
|
||||
for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
nodes[i].parent = nodes;
|
||||
}
|
||||
@ -62,34 +55,11 @@ module TypeScript.Syntax {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
export function separatedList<T extends ISyntaxNodeOrToken>(nodes: T[], separators: ISyntaxToken[]): T[] {
|
||||
if (!nodes || nodes.length === 0) {
|
||||
return emptySeparatedList<T>();
|
||||
export function separatedList<T extends ISyntaxNodeOrToken>(nodesAndTokens: ISyntaxNodeOrToken[]): ISeparatedSyntaxList<T> {
|
||||
for (var i = 0, n = nodesAndTokens.length; i < n; i++) {
|
||||
nodesAndTokens[i].parent = nodesAndTokens;
|
||||
}
|
||||
|
||||
// Debug.assert(separators.length === nodes.length || separators.length == (nodes.length - 1));
|
||||
|
||||
for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
nodes[i].parent = nodes;
|
||||
}
|
||||
|
||||
for (var i = 0, n = separators.length; i < n; i++) {
|
||||
separators[i].parent = nodes;
|
||||
}
|
||||
|
||||
|
||||
nodes.separators = separators.length === 0 ? _emptySeparators : separators;
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
export function nonSeparatorIndexOf<T extends ISyntaxNodeOrToken>(list: T[], ast: ISyntaxNodeOrToken): number {
|
||||
for (var i = 0, n = list.length; i < n; i++) {
|
||||
if (list[i] === ast) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return <ISeparatedSyntaxList<T>>nodesAndTokens;
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export class SyntaxNode implements ISyntaxNodeOrToken {
|
||||
private __kind: SyntaxKind;
|
||||
public data: number;
|
||||
public parent: ISyntaxElement;
|
||||
|
||||
constructor(data: number) {
|
||||
if (data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
public kind(): SyntaxKind {
|
||||
return this.__kind;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,5 +2,6 @@
|
||||
|
||||
module TypeScript {
|
||||
export interface ISyntaxNodeOrToken extends ISyntaxElement {
|
||||
_syntaxNodeOrTokenBrand: any;
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -74,7 +74,7 @@ module TypeScript {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var kind = token.kind();
|
||||
var kind = token.kind;
|
||||
var text = token.text();
|
||||
|
||||
if (kind === SyntaxKind.IdentifierName) {
|
||||
@ -98,15 +98,23 @@ module TypeScript {
|
||||
return IntegerUtilities.isHexInteger(text) ? parseInt(text, /*radix:*/ 16) : parseFloat(text);
|
||||
}
|
||||
else if (kind === SyntaxKind.StringLiteral) {
|
||||
if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) {
|
||||
// Properly terminated. Remove the quotes, and massage any escape characters we see.
|
||||
return massageEscapes(text.substr(1, text.length - 2));
|
||||
}
|
||||
else {
|
||||
// Not property terminated. Remove the first quote and massage any escape characters we see.
|
||||
return massageEscapes(text.substr(1));
|
||||
|
||||
}
|
||||
return (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0))
|
||||
? massageEscapes(text.substr(1, text.length - "''".length))
|
||||
: massageEscapes(text.substr(1));
|
||||
}
|
||||
else if (kind === SyntaxKind.NoSubstitutionTemplateToken || kind === SyntaxKind.TemplateEndToken) {
|
||||
// Both of these template types may be missing their closing backtick (if they were at
|
||||
// the end of the file). Check to make sure it is there before grabbing the portion
|
||||
// we're examining.
|
||||
return (text.length > 1 && text.charCodeAt(text.length - 1) === CharacterCodes.backtick)
|
||||
? massageTemplate(text.substr(1, text.length - "``".length))
|
||||
: massageTemplate(text.substr(1));
|
||||
}
|
||||
else if (kind === SyntaxKind.TemplateStartToken || kind === SyntaxKind.TemplateMiddleToken) {
|
||||
// Both these tokens must have been properly ended. i.e. if it didn't end with a ${
|
||||
// then we would not have parsed a start or middle token out at all. So we don't
|
||||
// need to check for an incomplete token.
|
||||
return massageTemplate(text.substr(1, text.length - "`${".length));
|
||||
}
|
||||
else if (kind === SyntaxKind.RegularExpressionLiteral) {
|
||||
return regularExpressionValue(text);
|
||||
@ -124,6 +132,18 @@ module TypeScript {
|
||||
return value === undefined ? "" : massageDisallowedIdentifiers(value.toString());
|
||||
}
|
||||
|
||||
function massageTemplate(text: string): string {
|
||||
// First, convert all carriage-return newlines into line-feed newlines. This is due to:
|
||||
//
|
||||
// The TRV of LineTerminatorSequence :: <CR> is the code unit value 0x000A.
|
||||
// ...
|
||||
// The TRV of LineTerminatorSequence :: <CR><LF> is the sequence consisting of the code unit value 0x000A.
|
||||
text = text.replace("\r\n", "\n").replace("\r", "\n");
|
||||
|
||||
// Now remove any escape characters that may be in the string.
|
||||
return massageEscapes(text);
|
||||
}
|
||||
|
||||
export function massageEscapes(text: string): string {
|
||||
return text.indexOf("\\") >= 0 ? convertEscapes(text) : text;
|
||||
}
|
||||
@ -264,7 +284,7 @@ module TypeScript {
|
||||
|
||||
module TypeScript.Syntax {
|
||||
export function realizeToken(token: ISyntaxToken, text: ISimpleText): ISyntaxToken {
|
||||
return new RealizedToken(token.fullStart(), token.kind(), token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text(), token.trailingTrivia(text));
|
||||
return new RealizedToken(token.fullStart(), token.kind, token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text(), token.trailingTrivia(text));
|
||||
}
|
||||
|
||||
export function convertKeywordToIdentifier(token: ISyntaxToken): ISyntaxToken {
|
||||
@ -272,11 +292,11 @@ module TypeScript.Syntax {
|
||||
}
|
||||
|
||||
export function withLeadingTrivia(token: ISyntaxToken, leadingTrivia: ISyntaxTriviaList, text: ISimpleText): ISyntaxToken {
|
||||
return new RealizedToken(token.fullStart(), token.kind(), token.isKeywordConvertedToIdentifier(), leadingTrivia, token.text(), token.trailingTrivia(text));
|
||||
return new RealizedToken(token.fullStart(), token.kind, token.isKeywordConvertedToIdentifier(), leadingTrivia, token.text(), token.trailingTrivia(text));
|
||||
}
|
||||
|
||||
export function withTrailingTrivia(token: ISyntaxToken, trailingTrivia: ISyntaxTriviaList, text: ISimpleText): ISyntaxToken {
|
||||
return new RealizedToken(token.fullStart(), token.kind(), token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text(), trailingTrivia);
|
||||
return new RealizedToken(token.fullStart(), token.kind, token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text(), trailingTrivia);
|
||||
}
|
||||
|
||||
export function emptyToken(kind: SyntaxKind): ISyntaxToken {
|
||||
@ -284,21 +304,22 @@ 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 _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any;
|
||||
public parent: ISyntaxElement;
|
||||
|
||||
constructor(private _kind: SyntaxKind) {
|
||||
constructor(public kind: SyntaxKind) {
|
||||
}
|
||||
|
||||
public setFullStart(fullStart: number): void {
|
||||
// An empty token is always at the -1 position.
|
||||
}
|
||||
|
||||
public kind(): SyntaxKind {
|
||||
return this._kind;
|
||||
}
|
||||
public childCount() { return 0 }
|
||||
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
|
||||
public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) }
|
||||
|
||||
public clone(): ISyntaxToken {
|
||||
return new EmptyToken(this.kind());
|
||||
return new EmptyToken(this.kind);
|
||||
}
|
||||
|
||||
// Empty tokens are never incrementally reusable.
|
||||
@ -338,7 +359,7 @@ module TypeScript.Syntax {
|
||||
while (true) {
|
||||
var parent = current.parent;
|
||||
if (parent === undefined) {
|
||||
Debug.assert(current.kind() === SyntaxKind.SourceUnit, "We had a node without a parent that was not the root node!");
|
||||
Debug.assert(current.kind === SyntaxKind.SourceUnit, "We had a node without a parent that was not the root node!");
|
||||
|
||||
// We walked all the way to the top, and never found a previous element. This
|
||||
// can happen with code like:
|
||||
@ -397,22 +418,21 @@ module TypeScript.Syntax {
|
||||
|
||||
class RealizedToken implements ISyntaxToken {
|
||||
private _fullStart: number;
|
||||
private _kind: SyntaxKind;
|
||||
private _isKeywordConvertedToIdentifier: boolean;
|
||||
private _leadingTrivia: ISyntaxTriviaList;
|
||||
private _text: string;
|
||||
private _trailingTrivia: ISyntaxTriviaList;
|
||||
|
||||
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any;
|
||||
public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any;
|
||||
public parent: ISyntaxElement;
|
||||
|
||||
constructor(fullStart: number,
|
||||
kind: SyntaxKind,
|
||||
public kind: SyntaxKind,
|
||||
isKeywordConvertedToIdentifier: boolean,
|
||||
leadingTrivia: ISyntaxTriviaList,
|
||||
text: string,
|
||||
trailingTrivia: ISyntaxTriviaList) {
|
||||
this._fullStart = fullStart;
|
||||
this._kind = kind;
|
||||
this._isKeywordConvertedToIdentifier = isKeywordConvertedToIdentifier;
|
||||
this._text = text;
|
||||
|
||||
@ -432,12 +452,12 @@ module TypeScript.Syntax {
|
||||
this._fullStart = fullStart;
|
||||
}
|
||||
|
||||
public kind(): SyntaxKind {
|
||||
return this._kind;
|
||||
}
|
||||
public childCount() { return 0 }
|
||||
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
|
||||
public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) }
|
||||
|
||||
public clone(): ISyntaxToken {
|
||||
return new RealizedToken(this._fullStart, this.kind(), this._isKeywordConvertedToIdentifier, this._leadingTrivia, this._text, this._trailingTrivia);
|
||||
return new RealizedToken(this._fullStart, this.kind, this._isKeywordConvertedToIdentifier, this._leadingTrivia, this._text, this._trailingTrivia);
|
||||
}
|
||||
|
||||
// Realized tokens are created from the parser. They are *never* incrementally reusable.
|
||||
@ -468,19 +488,21 @@ module TypeScript.Syntax {
|
||||
}
|
||||
|
||||
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 _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any;
|
||||
public parent: ISyntaxElement;
|
||||
public kind: SyntaxKind;
|
||||
|
||||
constructor(private underlyingToken: ISyntaxToken) {
|
||||
}
|
||||
|
||||
public kind() {
|
||||
return SyntaxKind.IdentifierName;
|
||||
}
|
||||
|
||||
public setFullStart(fullStart: number): void {
|
||||
this.underlyingToken.setFullStart(fullStart);
|
||||
}
|
||||
|
||||
public childCount() { return 0 }
|
||||
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
|
||||
public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) }
|
||||
|
||||
public fullStart(): number {
|
||||
return this.underlyingToken.fullStart();
|
||||
}
|
||||
@ -559,4 +581,5 @@ module TypeScript.Syntax {
|
||||
return new ConvertedKeywordToken(this.underlyingToken);
|
||||
}
|
||||
}
|
||||
ConvertedKeywordToken.prototype.kind = SyntaxKind.IdentifierName;
|
||||
}
|
||||
@ -4,7 +4,6 @@ module TypeScript {
|
||||
export var syntaxDiagnosticsTime: number = 0;
|
||||
|
||||
export class SyntaxTree {
|
||||
private _isConcrete: boolean;
|
||||
private _sourceUnit: SourceUnitSyntax;
|
||||
private _isDeclaration: boolean;
|
||||
private _parserDiagnostics: Diagnostic[];
|
||||
@ -17,14 +16,12 @@ module TypeScript {
|
||||
private _amdDependencies: string[];
|
||||
private _isExternalModule: boolean;
|
||||
|
||||
constructor(isConcrete: boolean,
|
||||
sourceUnit: SourceUnitSyntax,
|
||||
constructor(sourceUnit: SourceUnitSyntax,
|
||||
isDeclaration: boolean,
|
||||
diagnostics: Diagnostic[],
|
||||
fileName: string,
|
||||
public text: ISimpleText,
|
||||
languageVersion: ts.ScriptTarget) {
|
||||
this._isConcrete = isConcrete;
|
||||
this._sourceUnit = sourceUnit;
|
||||
this._isDeclaration = isDeclaration;
|
||||
this._parserDiagnostics = diagnostics;
|
||||
@ -35,10 +32,6 @@ module TypeScript {
|
||||
sourceUnit.syntaxTree = this;
|
||||
}
|
||||
|
||||
public isConcrete(): boolean {
|
||||
return this._isConcrete;
|
||||
}
|
||||
|
||||
public sourceUnit(): SourceUnitSyntax {
|
||||
return this._sourceUnit;
|
||||
}
|
||||
@ -169,10 +162,10 @@ module TypeScript {
|
||||
|
||||
private checkParameterListOrder(node: ParameterListSyntax): boolean {
|
||||
var seenOptionalParameter = false;
|
||||
var parameterCount = node.parameters.length;
|
||||
var parameterCount = nonSeparatorCount(node.parameters);
|
||||
|
||||
for (var i = 0; i < parameterCount; i++) {
|
||||
var parameter = node.parameters[i];
|
||||
var parameter = nonSeparatorAt(node.parameters, i);
|
||||
|
||||
if (parameter.dotDotDotToken) {
|
||||
if (i !== (parameterCount - 1)) {
|
||||
@ -210,8 +203,8 @@ module TypeScript {
|
||||
}
|
||||
|
||||
private checkParameterListAcessibilityModifiers(node: ParameterListSyntax): boolean {
|
||||
for (var i = 0, n = node.parameters.length; i < n; i++) {
|
||||
var parameter = node.parameters[i];
|
||||
for (var i = 0, n = nonSeparatorCount(node.parameters); i < n; i++) {
|
||||
var parameter = nonSeparatorAt(node.parameters, i);
|
||||
|
||||
if (this.checkParameterAccessibilityModifiers(node, parameter)) {
|
||||
return true;
|
||||
@ -238,7 +231,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
private checkParameterAccessibilityModifier(parameterList: ParameterListSyntax, modifier: ISyntaxToken, modifierIndex: number): boolean {
|
||||
if (!SyntaxFacts.isAccessibilityModifier(modifier.kind())) {
|
||||
if (!SyntaxFacts.isAccessibilityModifier(modifier.kind)) {
|
||||
this.pushDiagnostic(modifier, DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]);
|
||||
return true;
|
||||
}
|
||||
@ -255,17 +248,17 @@ module TypeScript {
|
||||
private checkForTrailingComma(list: ISyntaxNodeOrToken[]): boolean {
|
||||
// If we have at least one child, and we have an even number of children, then that
|
||||
// means we have an illegal trailing separator.
|
||||
if (childCount(list) === 0 || childCount(list) % 2 === 1) {
|
||||
if (list.length === 0 || list.length % 2 === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var child = childAt(list, childCount(list) - 1);
|
||||
var child = list[list.length - 1];
|
||||
this.pushDiagnostic(child, DiagnosticCode.Trailing_comma_not_allowed);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private checkForAtLeastOneElement(parent: ISyntaxElement, list: ISyntaxNodeOrToken[], reportToken: ISyntaxToken, listKind: string): boolean {
|
||||
private checkForAtLeastOneElement(list: ISyntaxNodeOrToken[], reportToken: ISyntaxToken, listKind: string): boolean {
|
||||
if (childCount(list) > 0) {
|
||||
return false;
|
||||
}
|
||||
@ -287,7 +280,7 @@ module TypeScript {
|
||||
|
||||
public visitHeritageClause(node: HeritageClauseSyntax): void {
|
||||
if (this.checkForTrailingComma(node.typeNames) ||
|
||||
this.checkForAtLeastOneElement(node, node.typeNames, node.extendsOrImplementsKeyword, SyntaxFacts.getText(node.extendsOrImplementsKeyword.kind()))) {
|
||||
this.checkForAtLeastOneElement(node.typeNames, node.extendsOrImplementsKeyword, SyntaxFacts.getText(node.extendsOrImplementsKeyword.kind))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -303,7 +296,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public visitVariableDeclaration(node: VariableDeclarationSyntax): void {
|
||||
if (this.checkForAtLeastOneElement(node, node.variableDeclarators, node.varKeyword, getLocalizedText(DiagnosticCode.variable_declaration, undefined)) ||
|
||||
if (this.checkForAtLeastOneElement(node.variableDeclarators, node.varKeyword, getLocalizedText(DiagnosticCode.variable_declaration, undefined)) ||
|
||||
this.checkForTrailingComma(node.variableDeclarators)) {
|
||||
return;
|
||||
}
|
||||
@ -313,7 +306,7 @@ module TypeScript {
|
||||
|
||||
public visitTypeArgumentList(node: TypeArgumentListSyntax): void {
|
||||
if (this.checkForTrailingComma(node.typeArguments) ||
|
||||
this.checkForAtLeastOneElement(node, node.typeArguments, node.lessThanToken, getLocalizedText(DiagnosticCode.type_argument, undefined))) {
|
||||
this.checkForAtLeastOneElement(node.typeArguments, node.lessThanToken, getLocalizedText(DiagnosticCode.type_argument, undefined))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -322,7 +315,7 @@ module TypeScript {
|
||||
|
||||
public visitTupleType(node: TupleTypeSyntax): void {
|
||||
if (this.checkForTrailingComma(node.types) ||
|
||||
this.checkForAtLeastOneElement(node, node.types, node.openBracketToken, getLocalizedText(DiagnosticCode.type, undefined))) {
|
||||
this.checkForAtLeastOneElement(node.types, node.openBracketToken, getLocalizedText(DiagnosticCode.type, undefined))) {
|
||||
return
|
||||
}
|
||||
|
||||
@ -331,7 +324,7 @@ module TypeScript {
|
||||
|
||||
public visitTypeParameterList(node: TypeParameterListSyntax): void {
|
||||
if (this.checkForTrailingComma(node.typeParameters) ||
|
||||
this.checkForAtLeastOneElement(node, node.typeParameters, node.lessThanToken, getLocalizedText(DiagnosticCode.type_parameter, undefined))) {
|
||||
this.checkForAtLeastOneElement(node.typeParameters, node.lessThanToken, getLocalizedText(DiagnosticCode.type_parameter, undefined))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -344,7 +337,7 @@ module TypeScript {
|
||||
return true;
|
||||
}
|
||||
|
||||
var parameter = node.parameters[0];
|
||||
var parameter = nonSeparatorAt(node.parameters, 0);
|
||||
|
||||
if (parameter.dotDotDotToken) {
|
||||
this.pushDiagnostic(parameter, DiagnosticCode.Index_signatures_cannot_have_rest_parameters);
|
||||
@ -366,8 +359,8 @@ module TypeScript {
|
||||
this.pushDiagnostic(parameter, DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation);
|
||||
return true;
|
||||
}
|
||||
else if (parameter.typeAnnotation.type.kind() !== SyntaxKind.StringKeyword &&
|
||||
parameter.typeAnnotation.type.kind() !== SyntaxKind.NumberKeyword) {
|
||||
else if (parameter.typeAnnotation.type.kind !== SyntaxKind.StringKeyword &&
|
||||
parameter.typeAnnotation.type.kind !== SyntaxKind.NumberKeyword) {
|
||||
this.pushDiagnostic(parameter, DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number);
|
||||
return true;
|
||||
}
|
||||
@ -396,7 +389,7 @@ module TypeScript {
|
||||
Debug.assert(i <= 2);
|
||||
var heritageClause = node.heritageClauses[i];
|
||||
|
||||
if (heritageClause.extendsOrImplementsKeyword.kind() === SyntaxKind.ExtendsKeyword) {
|
||||
if (heritageClause.extendsOrImplementsKeyword.kind === SyntaxKind.ExtendsKeyword) {
|
||||
if (seenExtendsClause) {
|
||||
this.pushDiagnostic(heritageClause, DiagnosticCode.extends_clause_already_seen);
|
||||
return true;
|
||||
@ -407,7 +400,7 @@ module TypeScript {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (heritageClause.typeNames.length > 1) {
|
||||
if (nonSeparatorCount(heritageClause.typeNames) > 1) {
|
||||
this.pushDiagnostic(heritageClause, DiagnosticCode.Classes_can_only_extend_a_single_class);
|
||||
return true;
|
||||
}
|
||||
@ -415,7 +408,7 @@ module TypeScript {
|
||||
seenExtendsClause = true;
|
||||
}
|
||||
else {
|
||||
Debug.assert(heritageClause.extendsOrImplementsKeyword.kind() === SyntaxKind.ImplementsKeyword);
|
||||
Debug.assert(heritageClause.extendsOrImplementsKeyword.kind === SyntaxKind.ImplementsKeyword);
|
||||
if (seenImplementsClause) {
|
||||
this.pushDiagnostic(heritageClause, DiagnosticCode.implements_clause_already_seen);
|
||||
return true;
|
||||
@ -475,7 +468,7 @@ module TypeScript {
|
||||
Debug.assert(i <= 1);
|
||||
var heritageClause = node.heritageClauses[i];
|
||||
|
||||
if (heritageClause.extendsOrImplementsKeyword.kind() === SyntaxKind.ExtendsKeyword) {
|
||||
if (heritageClause.extendsOrImplementsKeyword.kind === SyntaxKind.ExtendsKeyword) {
|
||||
if (seenExtendsClause) {
|
||||
this.pushDiagnostic(heritageClause, DiagnosticCode.extends_clause_already_seen);
|
||||
return true;
|
||||
@ -484,7 +477,7 @@ module TypeScript {
|
||||
seenExtendsClause = true;
|
||||
}
|
||||
else {
|
||||
Debug.assert(heritageClause.extendsOrImplementsKeyword.kind() === SyntaxKind.ImplementsKeyword);
|
||||
Debug.assert(heritageClause.extendsOrImplementsKeyword.kind === SyntaxKind.ImplementsKeyword);
|
||||
this.pushDiagnostic(heritageClause, DiagnosticCode.Interface_declaration_cannot_have_implements_clause);
|
||||
return true;
|
||||
}
|
||||
@ -496,7 +489,7 @@ module TypeScript {
|
||||
private checkInterfaceModifiers(modifiers: ISyntaxToken[]): boolean {
|
||||
for (var i = 0, n = modifiers.length; i < n; i++) {
|
||||
var modifier = modifiers[i];
|
||||
if (modifier.kind() === SyntaxKind.DeclareKeyword) {
|
||||
if (modifier.kind === SyntaxKind.DeclareKeyword) {
|
||||
this.pushDiagnostic(modifier,
|
||||
DiagnosticCode.A_declare_modifier_cannot_be_used_with_an_interface_declaration);
|
||||
return true;
|
||||
@ -523,7 +516,7 @@ module TypeScript {
|
||||
|
||||
for (var i = 0, n = list.length; i < n; i++) {
|
||||
var modifier = list[i];
|
||||
if (SyntaxFacts.isAccessibilityModifier(modifier.kind())) {
|
||||
if (SyntaxFacts.isAccessibilityModifier(modifier.kind)) {
|
||||
if (seenAccessibilityModifier) {
|
||||
this.pushDiagnostic(modifier, DiagnosticCode.Accessibility_modifier_already_seen);
|
||||
return true;
|
||||
@ -537,7 +530,7 @@ module TypeScript {
|
||||
|
||||
seenAccessibilityModifier = true;
|
||||
}
|
||||
else if (modifier.kind() === SyntaxKind.StaticKeyword) {
|
||||
else if (modifier.kind === SyntaxKind.StaticKeyword) {
|
||||
if (seenStaticModifier) {
|
||||
this.pushDiagnostic(modifier, DiagnosticCode._0_modifier_already_seen, [modifier.text()]);
|
||||
return true;
|
||||
@ -562,8 +555,25 @@ module TypeScript {
|
||||
super.visitMemberVariableDeclaration(node);
|
||||
}
|
||||
|
||||
public visitMethodSignature(node: MethodSignatureSyntax): void {
|
||||
if (this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.visitMethodSignature(node);
|
||||
}
|
||||
|
||||
public visitPropertySignature(node: PropertySignatureSyntax): void {
|
||||
if (this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.visitPropertySignature(node);
|
||||
}
|
||||
|
||||
public visitMemberFunctionDeclaration(node: MemberFunctionDeclarationSyntax): void {
|
||||
if (this.checkClassElementModifiers(node.modifiers)) {
|
||||
if (this.checkClassElementModifiers(node.modifiers) ||
|
||||
this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -589,14 +599,14 @@ module TypeScript {
|
||||
|
||||
private checkIndexMemberModifiers(node: IndexMemberDeclarationSyntax): boolean {
|
||||
if (node.modifiers.length > 0) {
|
||||
this.pushDiagnostic(childAt(node.modifiers, 0), DiagnosticCode.Modifiers_cannot_appear_here);
|
||||
this.pushDiagnostic(node.modifiers[0], DiagnosticCode.Modifiers_cannot_appear_here);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private checkEcmaScriptVersionIsAtLeast(parent: ISyntaxElement, reportToken: ISyntaxToken, languageVersion: ts.ScriptTarget, diagnosticKey: string): boolean {
|
||||
private checkEcmaScriptVersionIsAtLeast(reportToken: ISyntaxToken, languageVersion: ts.ScriptTarget, diagnosticKey: string): boolean {
|
||||
if (this.syntaxTree.languageVersion() < languageVersion) {
|
||||
this.pushDiagnostic(reportToken, diagnosticKey);
|
||||
return true;
|
||||
@ -614,11 +624,12 @@ module TypeScript {
|
||||
|
||||
public visitGetAccessor(node: GetAccessorSyntax): void {
|
||||
if (this.checkForAccessorDeclarationInAmbientContext(node) ||
|
||||
this.checkEcmaScriptVersionIsAtLeast(node, node.propertyName, ts.ScriptTarget.ES5, DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) ||
|
||||
this.checkForDisallowedModifiers(node, node.modifiers) ||
|
||||
this.checkEcmaScriptVersionIsAtLeast(node.propertyName, 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.checkGetAccessorParameter(node) ||
|
||||
this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -654,12 +665,12 @@ module TypeScript {
|
||||
|
||||
private checkSetAccessorParameter(node: SetAccessorSyntax): boolean {
|
||||
var parameters = node.callSignature.parameterList.parameters;
|
||||
if (childCount(parameters) !== 1) {
|
||||
if (nonSeparatorCount(parameters) !== 1) {
|
||||
this.pushDiagnostic(node.propertyName, DiagnosticCode.set_accessor_must_have_exactly_one_parameter);
|
||||
return true;
|
||||
}
|
||||
|
||||
var parameter = parameters[0];
|
||||
var parameter = nonSeparatorAt(parameters, 0);
|
||||
|
||||
if (parameter.questionToken) {
|
||||
this.pushDiagnostic(parameter, DiagnosticCode.set_accessor_parameter_cannot_be_optional);
|
||||
@ -679,14 +690,23 @@ module TypeScript {
|
||||
return false;
|
||||
}
|
||||
|
||||
public visitSimplePropertyAssignment(node: SimplePropertyAssignmentSyntax): void {
|
||||
if (this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.visitSimplePropertyAssignment(node);
|
||||
}
|
||||
|
||||
public visitSetAccessor(node: SetAccessorSyntax): void {
|
||||
if (this.checkForAccessorDeclarationInAmbientContext(node) ||
|
||||
this.checkEcmaScriptVersionIsAtLeast(node, node.propertyName, ts.ScriptTarget.ES5, DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) ||
|
||||
this.checkForDisallowedModifiers(node, node.modifiers) ||
|
||||
this.checkEcmaScriptVersionIsAtLeast(node.propertyName, 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.checkSetAccessorParameter(node) ||
|
||||
this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -710,28 +730,27 @@ module TypeScript {
|
||||
|
||||
private checkEnumElements(node: EnumDeclarationSyntax): boolean {
|
||||
var previousValueWasComputed = false;
|
||||
for (var i = 0, n = childCount(node.enumElements); i < n; i++) {
|
||||
var child = childAt(node.enumElements, i);
|
||||
for (var i = 0, n = nonSeparatorCount(node.enumElements); i < n; i++) {
|
||||
var enumElement = nonSeparatorAt(node.enumElements, i);
|
||||
|
||||
if (i % 2 === 0) {
|
||||
var enumElement = <EnumElementSyntax>child;
|
||||
if (!enumElement.equalsValueClause && previousValueWasComputed) {
|
||||
this.pushDiagnostic(enumElement, DiagnosticCode.Enum_member_must_have_initializer);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!enumElement.equalsValueClause && previousValueWasComputed) {
|
||||
this.pushDiagnostic(enumElement, DiagnosticCode.Enum_member_must_have_initializer);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (enumElement.equalsValueClause) {
|
||||
var value = enumElement.equalsValueClause.value;
|
||||
previousValueWasComputed = !Syntax.isIntegerLiteral(value);
|
||||
}
|
||||
if (enumElement.equalsValueClause) {
|
||||
var value = enumElement.equalsValueClause.value;
|
||||
previousValueWasComputed = !Syntax.isIntegerLiteral(value);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public visitEnumElement(node: EnumElementSyntax): void {
|
||||
if (this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.inAmbientDeclaration && node.equalsValueClause) {
|
||||
var expression = node.equalsValueClause.value;
|
||||
if (!Syntax.isIntegerLiteral(expression)) {
|
||||
@ -744,7 +763,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public visitInvocationExpression(node: InvocationExpressionSyntax): void {
|
||||
if (node.expression.kind() === SyntaxKind.SuperKeyword &&
|
||||
if (node.expression.kind === SyntaxKind.SuperKeyword &&
|
||||
node.argumentList.typeArgumentList) {
|
||||
this.pushDiagnostic(node, DiagnosticCode.super_invocation_cannot_have_type_arguments);
|
||||
}
|
||||
@ -758,13 +777,13 @@ module TypeScript {
|
||||
|
||||
for (var i = 0, n = modifiers.length; i < n; i++) {
|
||||
var modifier = modifiers[i];
|
||||
if (SyntaxFacts.isAccessibilityModifier(modifier.kind()) ||
|
||||
modifier.kind() === SyntaxKind.StaticKeyword) {
|
||||
if (SyntaxFacts.isAccessibilityModifier(modifier.kind) ||
|
||||
modifier.kind === SyntaxKind.StaticKeyword) {
|
||||
this.pushDiagnostic(modifier, DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (modifier.kind() === SyntaxKind.DeclareKeyword) {
|
||||
if (modifier.kind === SyntaxKind.DeclareKeyword) {
|
||||
if (seenDeclareModifier) {
|
||||
this.pushDiagnostic(modifier, DiagnosticCode.Accessibility_modifier_already_seen);
|
||||
return;
|
||||
@ -772,7 +791,7 @@ module TypeScript {
|
||||
|
||||
seenDeclareModifier = true;
|
||||
}
|
||||
else if (modifier.kind() === SyntaxKind.ExportKeyword) {
|
||||
else if (modifier.kind === SyntaxKind.ExportKeyword) {
|
||||
if (seenExportModifier) {
|
||||
this.pushDiagnostic(modifier, DiagnosticCode._0_modifier_already_seen, [modifier.text()]);
|
||||
return;
|
||||
@ -795,9 +814,9 @@ module TypeScript {
|
||||
if (!node.stringLiteral) {
|
||||
for (var i = 0, n = node.moduleElements.length; i < n; i++) {
|
||||
var child = node.moduleElements[i];
|
||||
if (child.kind() === SyntaxKind.ImportDeclaration) {
|
||||
if (child.kind === SyntaxKind.ImportDeclaration) {
|
||||
var importDeclaration = <ImportDeclarationSyntax>child;
|
||||
if (importDeclaration.moduleReference.kind() === SyntaxKind.ExternalModuleReference) {
|
||||
if (importDeclaration.moduleReference.kind === SyntaxKind.ExternalModuleReference) {
|
||||
this.pushDiagnostic(importDeclaration, DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module);
|
||||
}
|
||||
}
|
||||
@ -855,7 +874,7 @@ module TypeScript {
|
||||
for (var i = 0, n = node.moduleElements.length; i < n; i++) {
|
||||
var child = node.moduleElements[i];
|
||||
|
||||
if (child.kind() === SyntaxKind.ExportAssignment) {
|
||||
if (child.kind === SyntaxKind.ExportAssignment) {
|
||||
this.pushDiagnostic(child, DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules);
|
||||
return true;
|
||||
}
|
||||
@ -879,7 +898,7 @@ module TypeScript {
|
||||
if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) {
|
||||
// Provide a specialized message for a block as a statement versus the block as a
|
||||
// function body.
|
||||
if (node.parent.kind() === SyntaxKind.List) {
|
||||
if (node.parent.kind === SyntaxKind.List) {
|
||||
this.pushDiagnostic(firstToken(node), DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts);
|
||||
}
|
||||
else {
|
||||
@ -960,7 +979,7 @@ module TypeScript {
|
||||
|
||||
private inSwitchStatement(ast: ISyntaxElement): boolean {
|
||||
while (ast) {
|
||||
if (ast.kind() === SyntaxKind.SwitchStatement) {
|
||||
if (ast.kind === SyntaxKind.SwitchStatement) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -975,7 +994,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
private isIterationStatement(ast: ISyntaxElement): boolean {
|
||||
switch (ast.kind()) {
|
||||
switch (ast.kind) {
|
||||
case SyntaxKind.ForStatement:
|
||||
case SyntaxKind.ForInStatement:
|
||||
case SyntaxKind.WhileStatement:
|
||||
@ -1007,7 +1026,7 @@ module TypeScript {
|
||||
|
||||
element = element.parent;
|
||||
while (element) {
|
||||
if (element.kind() === SyntaxKind.LabeledStatement) {
|
||||
if (element.kind === SyntaxKind.LabeledStatement) {
|
||||
var labeledStatement = <LabeledStatementSyntax>element;
|
||||
if (breakable) {
|
||||
// Breakable labels can be placed on any construct
|
||||
@ -1033,7 +1052,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
private labelIsOnContinuableConstruct(statement: ISyntaxElement): boolean {
|
||||
switch (statement.kind()) {
|
||||
switch (statement.kind) {
|
||||
case SyntaxKind.LabeledStatement:
|
||||
// Labels work transitively. i.e. if you have:
|
||||
// foo:
|
||||
@ -1283,10 +1302,10 @@ module TypeScript {
|
||||
return false;
|
||||
}
|
||||
|
||||
private checkForDisallowedModifiers(parent: ISyntaxElement, modifiers: ISyntaxToken[]): boolean {
|
||||
private checkForDisallowedModifiers(modifiers: ISyntaxToken[]): boolean {
|
||||
if (this.inBlock || this.inObjectLiteralExpression) {
|
||||
if (modifiers.length > 0) {
|
||||
this.pushDiagnostic(childAt(modifiers, 0), DiagnosticCode.Modifiers_cannot_appear_here);
|
||||
this.pushDiagnostic(modifiers[0], DiagnosticCode.Modifiers_cannot_appear_here);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1296,7 +1315,7 @@ module TypeScript {
|
||||
|
||||
public visitFunctionDeclaration(node: FunctionDeclarationSyntax): void {
|
||||
if (this.checkForDisallowedDeclareModifier(node.modifiers) ||
|
||||
this.checkForDisallowedModifiers(node, node.modifiers) ||
|
||||
this.checkForDisallowedModifiers(node.modifiers) ||
|
||||
this.checkForRequiredDeclareModifier(node, node.identifier, node.modifiers) ||
|
||||
this.checkModuleElementModifiers(node.modifiers) ||
|
||||
this.checkForDisallowedEvalOrArguments(node, node.identifier)) {
|
||||
@ -1318,9 +1337,17 @@ module TypeScript {
|
||||
super.visitFunctionExpression(node);
|
||||
}
|
||||
|
||||
public visitFunctionPropertyAssignment(node: FunctionPropertyAssignmentSyntax): void {
|
||||
if (this.checkForTemplatePropertyName(node.propertyName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.visitFunctionPropertyAssignment(node);
|
||||
}
|
||||
|
||||
public visitVariableStatement(node: VariableStatementSyntax): void {
|
||||
if (this.checkForDisallowedDeclareModifier(node.modifiers) ||
|
||||
this.checkForDisallowedModifiers(node, node.modifiers) ||
|
||||
this.checkForDisallowedModifiers(node.modifiers) ||
|
||||
this.checkForRequiredDeclareModifier(node, node.variableDeclaration.varKeyword, node.modifiers) ||
|
||||
this.checkModuleElementModifiers(node.modifiers)) {
|
||||
|
||||
@ -1333,10 +1360,10 @@ module TypeScript {
|
||||
this.inAmbientDeclaration = savedInAmbientDeclaration;
|
||||
}
|
||||
|
||||
private checkListSeparators<T extends ISyntaxNodeOrToken>(parent: ISyntaxElement, list: T[], kind: SyntaxKind): boolean {
|
||||
for (var i = 0, n = childCount(list); i < n; i++) {
|
||||
var child = childAt(list, i);
|
||||
if (i % 2 === 1 && child.kind() !== kind) {
|
||||
private checkListSeparators<T extends ISyntaxNodeOrToken>(list: ISeparatedSyntaxList<T>, kind: SyntaxKind): boolean {
|
||||
for (var i = 0, n = separatorCount(list); i < n; i++) {
|
||||
var child = separatorAt(list, i);
|
||||
if (child.kind !== kind) {
|
||||
this.pushDiagnostic(child, DiagnosticCode._0_expected, [SyntaxFacts.getText(kind)]);
|
||||
}
|
||||
}
|
||||
@ -1345,7 +1372,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public visitObjectType(node: ObjectTypeSyntax): void {
|
||||
if (this.checkListSeparators(node, node.typeMembers, SyntaxKind.SemicolonToken)) {
|
||||
if (this.checkListSeparators(node.typeMembers, SyntaxKind.SemicolonToken)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1382,15 +1409,25 @@ module TypeScript {
|
||||
|
||||
public visitVariableDeclarator(node: VariableDeclaratorSyntax): void {
|
||||
if (this.checkVariableDeclaratorInitializer(node) ||
|
||||
this.checkVariableDeclaratorIdentifier(node)) {
|
||||
this.checkVariableDeclaratorIdentifier(node) ||
|
||||
this.checkForTemplatePropertyName(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);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private checkVariableDeclaratorIdentifier(node: VariableDeclaratorSyntax): boolean {
|
||||
if (node.parent.kind() !== SyntaxKind.MemberVariableDeclaration) {
|
||||
if (node.parent.kind !== SyntaxKind.MemberVariableDeclaration) {
|
||||
if (this.checkForDisallowedEvalOrArguments(node, node.propertyName)) {
|
||||
return true;
|
||||
}
|
||||
@ -1423,8 +1460,8 @@ module TypeScript {
|
||||
private checkConstructorModifiers(modifiers: ISyntaxToken[]): boolean {
|
||||
for (var i = 0, n = modifiers.length; i < n; i++) {
|
||||
var child = modifiers[i];
|
||||
if (child.kind() !== SyntaxKind.PublicKeyword) {
|
||||
this.pushDiagnostic(child, DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [SyntaxFacts.getText(child.kind())]);
|
||||
if (child.kind !== SyntaxKind.PublicKeyword) {
|
||||
this.pushDiagnostic(child, DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [SyntaxFacts.getText(child.kind)]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1494,7 +1531,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
private isPreIncrementOrDecrementExpression(node: PrefixUnaryExpressionSyntax) {
|
||||
switch (node.operatorToken.kind()) {
|
||||
switch (node.operatorToken.kind) {
|
||||
case SyntaxKind.MinusMinusToken:
|
||||
case SyntaxKind.PlusPlusToken:
|
||||
return true;
|
||||
@ -1504,7 +1541,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public visitDeleteExpression(node: DeleteExpressionSyntax): void {
|
||||
if (parsedInStrictMode(node) && node.expression.kind() === SyntaxKind.IdentifierName) {
|
||||
if (parsedInStrictMode(node) && node.expression.kind === SyntaxKind.IdentifierName) {
|
||||
this.pushDiagnostic(firstToken(node), DiagnosticCode.delete_cannot_be_called_on_an_identifier_in_strict_mode);
|
||||
return;
|
||||
}
|
||||
@ -1513,7 +1550,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
private checkIllegalAssignment(node: BinaryExpressionSyntax): boolean {
|
||||
if (parsedInStrictMode(node) && SyntaxFacts.isAssignmentOperatorToken(node.operatorToken.kind()) && this.isEvalOrArguments(node.left)) {
|
||||
if (parsedInStrictMode(node) && SyntaxFacts.isAssignmentOperatorToken(node.operatorToken.kind) && this.isEvalOrArguments(node.left)) {
|
||||
this.pushDiagnostic(node.operatorToken, DiagnosticCode.Invalid_use_of_0_in_strict_mode, [this.getEvalOrArguments(node.left)]);
|
||||
return true;
|
||||
}
|
||||
@ -1522,7 +1559,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
private getEvalOrArguments(expr: IExpressionSyntax): string {
|
||||
if (expr.kind() === SyntaxKind.IdentifierName) {
|
||||
if (expr.kind === SyntaxKind.IdentifierName) {
|
||||
var text = tokenValueText(<ISyntaxToken>expr);
|
||||
if (text === "eval" || text === "arguments") {
|
||||
return text;
|
||||
@ -1545,7 +1582,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
private checkConstraintType(node: ConstraintSyntax): boolean {
|
||||
if (!SyntaxFacts.isType(node.typeOrExpression.kind())) {
|
||||
if (!SyntaxFacts.isType(node.typeOrExpression.kind)) {
|
||||
this.pushDiagnostic(node.typeOrExpression, DiagnosticCode.Type_expected);
|
||||
return true;
|
||||
}
|
||||
@ -1602,13 +1639,13 @@ module TypeScript {
|
||||
var moduleElement = node.moduleElements[i];
|
||||
|
||||
var _firstToken = firstToken(moduleElement);
|
||||
if (_firstToken && _firstToken.kind() === SyntaxKind.ExportKeyword) {
|
||||
if (_firstToken && _firstToken.kind === SyntaxKind.ExportKeyword) {
|
||||
return new TextSpan(start(_firstToken), width(_firstToken));
|
||||
}
|
||||
|
||||
if (moduleElement.kind() === SyntaxKind.ImportDeclaration) {
|
||||
if (moduleElement.kind === SyntaxKind.ImportDeclaration) {
|
||||
var importDecl = <ImportDeclarationSyntax>moduleElement;
|
||||
if (importDecl.moduleReference.kind() === SyntaxKind.ExternalModuleReference) {
|
||||
if (importDecl.moduleReference.kind === SyntaxKind.ExternalModuleReference) {
|
||||
var literal = (<TypeScript.ExternalModuleReferenceSyntax>importDecl.moduleReference).stringLiteral;
|
||||
return new TextSpan(start(literal), width(literal));
|
||||
}
|
||||
|
||||
@ -28,10 +28,6 @@ module TypeScript {
|
||||
|
||||
module TypeScript.Syntax {
|
||||
class EmptyTriviaList implements ISyntaxTriviaList {
|
||||
public kind() {
|
||||
return SyntaxKind.TriviaList;
|
||||
}
|
||||
|
||||
public isShared(): boolean {
|
||||
return true;
|
||||
}
|
||||
@ -91,10 +87,6 @@ module TypeScript.Syntax {
|
||||
this.item.parent = this;
|
||||
}
|
||||
|
||||
public kind() {
|
||||
return SyntaxKind.TriviaList;
|
||||
}
|
||||
|
||||
public isShared(): boolean {
|
||||
return false;
|
||||
}
|
||||
@ -155,10 +147,6 @@ module TypeScript.Syntax {
|
||||
});
|
||||
}
|
||||
|
||||
public kind() {
|
||||
return SyntaxKind.TriviaList;
|
||||
}
|
||||
|
||||
public isShared(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
703
src/services/syntax/syntaxUtilities.generated.ts
Normal file
703
src/services/syntax/syntaxUtilities.generated.ts
Normal file
@ -0,0 +1,703 @@
|
||||
module TypeScript {
|
||||
var childCountArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 3, 4, 3, 5, 2, 2, 3, 3, 3, 6, 6, 7, 8, 6, 6, 4, 5, 3, 5, 3, 5, 5, 3, 3, 2, 4, 3, 3, 6, 3, 2, 3, 7, 3, 3, 10, 8, 1, 3, 5, 4, 3, 7, 2, 5, 2, 2, 2, 2, 5, 3, 2, 3, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 0, 2, 2, 2, 3, 4, 3, 3, 3, 2, 2, 4, 3, 2, 6, 2, 2, 2, 2, 3, 3, 6, 2, 2, 4, 1];
|
||||
|
||||
export function childCount(element: ISyntaxElement): number {
|
||||
if (isList(element)) { return (<ISyntaxNodeOrToken[]>element).length; }
|
||||
return childCountArray[element.kind];
|
||||
}
|
||||
|
||||
var childAtArray: ((nodeOrToken: ISyntaxElement, index: number) => ISyntaxElement)[] = [
|
||||
undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined,
|
||||
(node: SourceUnitSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.moduleElements;
|
||||
case 1: return node.endOfFileToken;
|
||||
}
|
||||
},
|
||||
(node: QualifiedNameSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.left;
|
||||
case 1: return node.dotToken;
|
||||
case 2: return node.right;
|
||||
}
|
||||
},
|
||||
(node: ObjectTypeSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.openBraceToken;
|
||||
case 1: return node.typeMembers;
|
||||
case 2: return node.closeBraceToken;
|
||||
}
|
||||
},
|
||||
(node: FunctionTypeSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.typeParameterList;
|
||||
case 1: return node.parameterList;
|
||||
case 2: return node.equalsGreaterThanToken;
|
||||
case 3: return node.type;
|
||||
}
|
||||
},
|
||||
(node: ArrayTypeSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.type;
|
||||
case 1: return node.openBracketToken;
|
||||
case 2: return node.closeBracketToken;
|
||||
}
|
||||
},
|
||||
(node: ConstructorTypeSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.newKeyword;
|
||||
case 1: return node.typeParameterList;
|
||||
case 2: return node.parameterList;
|
||||
case 3: return node.equalsGreaterThanToken;
|
||||
case 4: return node.type;
|
||||
}
|
||||
},
|
||||
(node: GenericTypeSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.name;
|
||||
case 1: return node.typeArgumentList;
|
||||
}
|
||||
},
|
||||
(node: TypeQuerySyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.typeOfKeyword;
|
||||
case 1: return node.name;
|
||||
}
|
||||
},
|
||||
(node: TupleTypeSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.openBracketToken;
|
||||
case 1: return node.types;
|
||||
case 2: return node.closeBracketToken;
|
||||
}
|
||||
},
|
||||
(node: UnionTypeSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.left;
|
||||
case 1: return node.barToken;
|
||||
case 2: return node.right;
|
||||
}
|
||||
},
|
||||
(node: ParenthesizedTypeSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.openParenToken;
|
||||
case 1: return node.type;
|
||||
case 2: return node.closeParenToken;
|
||||
}
|
||||
},
|
||||
(node: InterfaceDeclarationSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.modifiers;
|
||||
case 1: return node.interfaceKeyword;
|
||||
case 2: return node.identifier;
|
||||
case 3: return node.typeParameterList;
|
||||
case 4: return node.heritageClauses;
|
||||
case 5: return node.body;
|
||||
}
|
||||
},
|
||||
(node: FunctionDeclarationSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.modifiers;
|
||||
case 1: return node.functionKeyword;
|
||||
case 2: return node.identifier;
|
||||
case 3: return node.callSignature;
|
||||
case 4: return node.block;
|
||||
case 5: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: ModuleDeclarationSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.modifiers;
|
||||
case 1: return node.moduleKeyword;
|
||||
case 2: return node.name;
|
||||
case 3: return node.stringLiteral;
|
||||
case 4: return node.openBraceToken;
|
||||
case 5: return node.moduleElements;
|
||||
case 6: return node.closeBraceToken;
|
||||
}
|
||||
},
|
||||
(node: ClassDeclarationSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.modifiers;
|
||||
case 1: return node.classKeyword;
|
||||
case 2: return node.identifier;
|
||||
case 3: return node.typeParameterList;
|
||||
case 4: return node.heritageClauses;
|
||||
case 5: return node.openBraceToken;
|
||||
case 6: return node.classElements;
|
||||
case 7: return node.closeBraceToken;
|
||||
}
|
||||
},
|
||||
(node: EnumDeclarationSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.modifiers;
|
||||
case 1: return node.enumKeyword;
|
||||
case 2: return node.identifier;
|
||||
case 3: return node.openBraceToken;
|
||||
case 4: return node.enumElements;
|
||||
case 5: return node.closeBraceToken;
|
||||
}
|
||||
},
|
||||
(node: ImportDeclarationSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.modifiers;
|
||||
case 1: return node.importKeyword;
|
||||
case 2: return node.identifier;
|
||||
case 3: return node.equalsToken;
|
||||
case 4: return node.moduleReference;
|
||||
case 5: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: ExportAssignmentSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.exportKeyword;
|
||||
case 1: return node.equalsToken;
|
||||
case 2: return node.identifier;
|
||||
case 3: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: MemberFunctionDeclarationSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.modifiers;
|
||||
case 1: return node.propertyName;
|
||||
case 2: return node.callSignature;
|
||||
case 3: return node.block;
|
||||
case 4: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: MemberVariableDeclarationSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.modifiers;
|
||||
case 1: return node.variableDeclarator;
|
||||
case 2: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: ConstructorDeclarationSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.modifiers;
|
||||
case 1: return node.constructorKeyword;
|
||||
case 2: return node.callSignature;
|
||||
case 3: return node.block;
|
||||
case 4: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: IndexMemberDeclarationSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.modifiers;
|
||||
case 1: return node.indexSignature;
|
||||
case 2: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: GetAccessorSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.modifiers;
|
||||
case 1: return node.getKeyword;
|
||||
case 2: return node.propertyName;
|
||||
case 3: return node.callSignature;
|
||||
case 4: return node.block;
|
||||
}
|
||||
},
|
||||
(node: SetAccessorSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.modifiers;
|
||||
case 1: return node.setKeyword;
|
||||
case 2: return node.propertyName;
|
||||
case 3: return node.callSignature;
|
||||
case 4: return node.block;
|
||||
}
|
||||
},
|
||||
(node: PropertySignatureSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.propertyName;
|
||||
case 1: return node.questionToken;
|
||||
case 2: return node.typeAnnotation;
|
||||
}
|
||||
},
|
||||
(node: CallSignatureSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.typeParameterList;
|
||||
case 1: return node.parameterList;
|
||||
case 2: return node.typeAnnotation;
|
||||
}
|
||||
},
|
||||
(node: ConstructSignatureSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.newKeyword;
|
||||
case 1: return node.callSignature;
|
||||
}
|
||||
},
|
||||
(node: IndexSignatureSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.openBracketToken;
|
||||
case 1: return node.parameters;
|
||||
case 2: return node.closeBracketToken;
|
||||
case 3: return node.typeAnnotation;
|
||||
}
|
||||
},
|
||||
(node: MethodSignatureSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.propertyName;
|
||||
case 1: return node.questionToken;
|
||||
case 2: return node.callSignature;
|
||||
}
|
||||
},
|
||||
(node: BlockSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.openBraceToken;
|
||||
case 1: return node.statements;
|
||||
case 2: return node.closeBraceToken;
|
||||
}
|
||||
},
|
||||
(node: IfStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.ifKeyword;
|
||||
case 1: return node.openParenToken;
|
||||
case 2: return node.condition;
|
||||
case 3: return node.closeParenToken;
|
||||
case 4: return node.statement;
|
||||
case 5: return node.elseClause;
|
||||
}
|
||||
},
|
||||
(node: VariableStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.modifiers;
|
||||
case 1: return node.variableDeclaration;
|
||||
case 2: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: ExpressionStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.expression;
|
||||
case 1: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: ReturnStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.returnKeyword;
|
||||
case 1: return node.expression;
|
||||
case 2: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: SwitchStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.switchKeyword;
|
||||
case 1: return node.openParenToken;
|
||||
case 2: return node.expression;
|
||||
case 3: return node.closeParenToken;
|
||||
case 4: return node.openBraceToken;
|
||||
case 5: return node.switchClauses;
|
||||
case 6: return node.closeBraceToken;
|
||||
}
|
||||
},
|
||||
(node: BreakStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.breakKeyword;
|
||||
case 1: return node.identifier;
|
||||
case 2: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: ContinueStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.continueKeyword;
|
||||
case 1: return node.identifier;
|
||||
case 2: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: ForStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.forKeyword;
|
||||
case 1: return node.openParenToken;
|
||||
case 2: return node.variableDeclaration;
|
||||
case 3: return node.initializer;
|
||||
case 4: return node.firstSemicolonToken;
|
||||
case 5: return node.condition;
|
||||
case 6: return node.secondSemicolonToken;
|
||||
case 7: return node.incrementor;
|
||||
case 8: return node.closeParenToken;
|
||||
case 9: return node.statement;
|
||||
}
|
||||
},
|
||||
(node: ForInStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.forKeyword;
|
||||
case 1: return node.openParenToken;
|
||||
case 2: return node.variableDeclaration;
|
||||
case 3: return node.left;
|
||||
case 4: return node.inKeyword;
|
||||
case 5: return node.expression;
|
||||
case 6: return node.closeParenToken;
|
||||
case 7: return node.statement;
|
||||
}
|
||||
},
|
||||
(node: EmptyStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: ThrowStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.throwKeyword;
|
||||
case 1: return node.expression;
|
||||
case 2: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: WhileStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.whileKeyword;
|
||||
case 1: return node.openParenToken;
|
||||
case 2: return node.condition;
|
||||
case 3: return node.closeParenToken;
|
||||
case 4: return node.statement;
|
||||
}
|
||||
},
|
||||
(node: TryStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.tryKeyword;
|
||||
case 1: return node.block;
|
||||
case 2: return node.catchClause;
|
||||
case 3: return node.finallyClause;
|
||||
}
|
||||
},
|
||||
(node: LabeledStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.identifier;
|
||||
case 1: return node.colonToken;
|
||||
case 2: return node.statement;
|
||||
}
|
||||
},
|
||||
(node: DoStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.doKeyword;
|
||||
case 1: return node.statement;
|
||||
case 2: return node.whileKeyword;
|
||||
case 3: return node.openParenToken;
|
||||
case 4: return node.condition;
|
||||
case 5: return node.closeParenToken;
|
||||
case 6: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: DebuggerStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.debuggerKeyword;
|
||||
case 1: return node.semicolonToken;
|
||||
}
|
||||
},
|
||||
(node: WithStatementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.withKeyword;
|
||||
case 1: return node.openParenToken;
|
||||
case 2: return node.condition;
|
||||
case 3: return node.closeParenToken;
|
||||
case 4: return node.statement;
|
||||
}
|
||||
},
|
||||
(node: PrefixUnaryExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.operatorToken;
|
||||
case 1: return node.operand;
|
||||
}
|
||||
},
|
||||
(node: DeleteExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.deleteKeyword;
|
||||
case 1: return node.expression;
|
||||
}
|
||||
},
|
||||
(node: TypeOfExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.typeOfKeyword;
|
||||
case 1: return node.expression;
|
||||
}
|
||||
},
|
||||
(node: VoidExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.voidKeyword;
|
||||
case 1: return node.expression;
|
||||
}
|
||||
},
|
||||
(node: ConditionalExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.condition;
|
||||
case 1: return node.questionToken;
|
||||
case 2: return node.whenTrue;
|
||||
case 3: return node.colonToken;
|
||||
case 4: return node.whenFalse;
|
||||
}
|
||||
},
|
||||
(node: BinaryExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.left;
|
||||
case 1: return node.operatorToken;
|
||||
case 2: return node.right;
|
||||
}
|
||||
},
|
||||
(node: PostfixUnaryExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.operand;
|
||||
case 1: return node.operatorToken;
|
||||
}
|
||||
},
|
||||
(node: MemberAccessExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.expression;
|
||||
case 1: return node.dotToken;
|
||||
case 2: return node.name;
|
||||
}
|
||||
},
|
||||
(node: InvocationExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.expression;
|
||||
case 1: return node.argumentList;
|
||||
}
|
||||
},
|
||||
(node: ArrayLiteralExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.openBracketToken;
|
||||
case 1: return node.expressions;
|
||||
case 2: return node.closeBracketToken;
|
||||
}
|
||||
},
|
||||
(node: ObjectLiteralExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.openBraceToken;
|
||||
case 1: return node.propertyAssignments;
|
||||
case 2: return node.closeBraceToken;
|
||||
}
|
||||
},
|
||||
(node: ObjectCreationExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.newKeyword;
|
||||
case 1: return node.expression;
|
||||
case 2: return node.argumentList;
|
||||
}
|
||||
},
|
||||
(node: ParenthesizedExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.openParenToken;
|
||||
case 1: return node.expression;
|
||||
case 2: return node.closeParenToken;
|
||||
}
|
||||
},
|
||||
(node: ParenthesizedArrowFunctionExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.callSignature;
|
||||
case 1: return node.equalsGreaterThanToken;
|
||||
case 2: return node.block;
|
||||
case 3: return node.expression;
|
||||
}
|
||||
},
|
||||
(node: SimpleArrowFunctionExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.parameter;
|
||||
case 1: return node.equalsGreaterThanToken;
|
||||
case 2: return node.block;
|
||||
case 3: return node.expression;
|
||||
}
|
||||
},
|
||||
(node: CastExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.lessThanToken;
|
||||
case 1: return node.type;
|
||||
case 2: return node.greaterThanToken;
|
||||
case 3: return node.expression;
|
||||
}
|
||||
},
|
||||
(node: ElementAccessExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.expression;
|
||||
case 1: return node.openBracketToken;
|
||||
case 2: return node.argumentExpression;
|
||||
case 3: return node.closeBracketToken;
|
||||
}
|
||||
},
|
||||
(node: FunctionExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.functionKeyword;
|
||||
case 1: return node.identifier;
|
||||
case 2: return node.callSignature;
|
||||
case 3: return node.block;
|
||||
}
|
||||
},
|
||||
(node: OmittedExpressionSyntax, index: number): ISyntaxElement => {
|
||||
throw Errors.invalidOperation();
|
||||
},
|
||||
(node: TemplateExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.templateStartToken;
|
||||
case 1: return node.templateClauses;
|
||||
}
|
||||
},
|
||||
(node: TemplateAccessExpressionSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.expression;
|
||||
case 1: return node.templateExpression;
|
||||
}
|
||||
},
|
||||
(node: VariableDeclarationSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.varKeyword;
|
||||
case 1: return node.variableDeclarators;
|
||||
}
|
||||
},
|
||||
(node: VariableDeclaratorSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.propertyName;
|
||||
case 1: return node.typeAnnotation;
|
||||
case 2: return node.equalsValueClause;
|
||||
}
|
||||
},
|
||||
(node: ArgumentListSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.typeArgumentList;
|
||||
case 1: return node.openParenToken;
|
||||
case 2: return node.arguments;
|
||||
case 3: return node.closeParenToken;
|
||||
}
|
||||
},
|
||||
(node: ParameterListSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.openParenToken;
|
||||
case 1: return node.parameters;
|
||||
case 2: return node.closeParenToken;
|
||||
}
|
||||
},
|
||||
(node: TypeArgumentListSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.lessThanToken;
|
||||
case 1: return node.typeArguments;
|
||||
case 2: return node.greaterThanToken;
|
||||
}
|
||||
},
|
||||
(node: TypeParameterListSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.lessThanToken;
|
||||
case 1: return node.typeParameters;
|
||||
case 2: return node.greaterThanToken;
|
||||
}
|
||||
},
|
||||
(node: HeritageClauseSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.extendsOrImplementsKeyword;
|
||||
case 1: return node.typeNames;
|
||||
}
|
||||
},
|
||||
(node: EqualsValueClauseSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.equalsToken;
|
||||
case 1: return node.value;
|
||||
}
|
||||
},
|
||||
(node: CaseSwitchClauseSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.caseKeyword;
|
||||
case 1: return node.expression;
|
||||
case 2: return node.colonToken;
|
||||
case 3: return node.statements;
|
||||
}
|
||||
},
|
||||
(node: DefaultSwitchClauseSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.defaultKeyword;
|
||||
case 1: return node.colonToken;
|
||||
case 2: return node.statements;
|
||||
}
|
||||
},
|
||||
(node: ElseClauseSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.elseKeyword;
|
||||
case 1: return node.statement;
|
||||
}
|
||||
},
|
||||
(node: CatchClauseSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.catchKeyword;
|
||||
case 1: return node.openParenToken;
|
||||
case 2: return node.identifier;
|
||||
case 3: return node.typeAnnotation;
|
||||
case 4: return node.closeParenToken;
|
||||
case 5: return node.block;
|
||||
}
|
||||
},
|
||||
(node: FinallyClauseSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.finallyKeyword;
|
||||
case 1: return node.block;
|
||||
}
|
||||
},
|
||||
(node: TemplateClauseSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.expression;
|
||||
case 1: return node.templateMiddleOrEndToken;
|
||||
}
|
||||
},
|
||||
(node: TypeParameterSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.identifier;
|
||||
case 1: return node.constraint;
|
||||
}
|
||||
},
|
||||
(node: ConstraintSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.extendsKeyword;
|
||||
case 1: return node.typeOrExpression;
|
||||
}
|
||||
},
|
||||
(node: SimplePropertyAssignmentSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.propertyName;
|
||||
case 1: return node.colonToken;
|
||||
case 2: return node.expression;
|
||||
}
|
||||
},
|
||||
(node: FunctionPropertyAssignmentSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.propertyName;
|
||||
case 1: return node.callSignature;
|
||||
case 2: return node.block;
|
||||
}
|
||||
},
|
||||
(node: ParameterSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.dotDotDotToken;
|
||||
case 1: return node.modifiers;
|
||||
case 2: return node.identifier;
|
||||
case 3: return node.questionToken;
|
||||
case 4: return node.typeAnnotation;
|
||||
case 5: return node.equalsValueClause;
|
||||
}
|
||||
},
|
||||
(node: EnumElementSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.propertyName;
|
||||
case 1: return node.equalsValueClause;
|
||||
}
|
||||
},
|
||||
(node: TypeAnnotationSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.colonToken;
|
||||
case 1: return node.type;
|
||||
}
|
||||
},
|
||||
(node: ExternalModuleReferenceSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.requireKeyword;
|
||||
case 1: return node.openParenToken;
|
||||
case 2: return node.stringLiteral;
|
||||
case 3: return node.closeParenToken;
|
||||
}
|
||||
},
|
||||
(node: ModuleNameModuleReferenceSyntax, index: number): ISyntaxElement => {
|
||||
switch (index) {
|
||||
case 0: return node.moduleName;
|
||||
}
|
||||
}
|
||||
];
|
||||
export function childAt(element: ISyntaxElement, index: number): ISyntaxElement {
|
||||
if (isList(element)) { return (<ISyntaxNodeOrToken[]>element)[index]; }
|
||||
return childAtArray[element.kind](element, index);
|
||||
}
|
||||
|
||||
export function getChildAtFunction(element: ISyntaxNodeOrToken): (nodeOrToken: ISyntaxElement, index: number) => ISyntaxElement {
|
||||
return childAtArray[element.kind];
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,7 @@
|
||||
module TypeScript {
|
||||
export class SyntaxUtilities {
|
||||
public static isAnyFunctionExpressionOrDeclaration(ast: ISyntaxElement): boolean {
|
||||
switch (ast.kind()) {
|
||||
switch (ast.kind) {
|
||||
case SyntaxKind.SimpleArrowFunctionExpression:
|
||||
case SyntaxKind.ParenthesizedArrowFunctionExpression:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
@ -34,9 +34,10 @@ module TypeScript {
|
||||
|
||||
public static isLeftHandSizeExpression(element: ISyntaxElement) {
|
||||
if (element) {
|
||||
switch (element.kind()) {
|
||||
switch (element.kind) {
|
||||
case SyntaxKind.MemberAccessExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.TemplateAccessExpression:
|
||||
case SyntaxKind.ObjectCreationExpression:
|
||||
case SyntaxKind.InvocationExpression:
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
@ -59,48 +60,9 @@ module TypeScript {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static isExpression(element: ISyntaxElement) {
|
||||
if (element) {
|
||||
switch (element.kind()) {
|
||||
case SyntaxKind.IdentifierName:
|
||||
case SyntaxKind.RegularExpressionLiteral:
|
||||
case SyntaxKind.NumericLiteral:
|
||||
case SyntaxKind.StringLiteral:
|
||||
case SyntaxKind.FalseKeyword:
|
||||
case SyntaxKind.NullKeyword:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.TrueKeyword:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
|
||||
case SyntaxKind.PrefixUnaryExpression:
|
||||
case SyntaxKind.PostfixUnaryExpression:
|
||||
case SyntaxKind.BinaryExpression:
|
||||
case SyntaxKind.DeleteExpression:
|
||||
case SyntaxKind.TypeOfExpression:
|
||||
case SyntaxKind.VoidExpression:
|
||||
case SyntaxKind.ConditionalExpression:
|
||||
case SyntaxKind.MemberAccessExpression:
|
||||
case SyntaxKind.InvocationExpression:
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
case SyntaxKind.ObjectCreationExpression:
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
case SyntaxKind.ParenthesizedArrowFunctionExpression:
|
||||
case SyntaxKind.SimpleArrowFunctionExpression:
|
||||
case SyntaxKind.CastExpression:
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.OmittedExpression:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static isSwitchClause(element: ISyntaxElement) {
|
||||
if (element) {
|
||||
switch (element.kind()) {
|
||||
switch (element.kind) {
|
||||
case SyntaxKind.CaseSwitchClause:
|
||||
case SyntaxKind.DefaultSwitchClause:
|
||||
return true;
|
||||
@ -112,7 +74,7 @@ module TypeScript {
|
||||
|
||||
public static isTypeMember(element: ISyntaxElement) {
|
||||
if (element) {
|
||||
switch (element.kind()) {
|
||||
switch (element.kind) {
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.IndexSignature:
|
||||
@ -127,7 +89,7 @@ module TypeScript {
|
||||
|
||||
public static isClassElement(element: ISyntaxElement) {
|
||||
if (element) {
|
||||
switch (element.kind()) {
|
||||
switch (element.kind) {
|
||||
case SyntaxKind.ConstructorDeclaration:
|
||||
case SyntaxKind.IndexMemberDeclaration:
|
||||
case SyntaxKind.MemberFunctionDeclaration:
|
||||
@ -144,7 +106,7 @@ module TypeScript {
|
||||
|
||||
public static isModuleElement(element: ISyntaxElement) {
|
||||
if (element) {
|
||||
switch (element.kind()) {
|
||||
switch (element.kind) {
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
case SyntaxKind.ExportAssignment:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
@ -181,7 +143,7 @@ module TypeScript {
|
||||
|
||||
public static isStatement(element: ISyntaxElement) {
|
||||
if (element) {
|
||||
switch (element.kind()) {
|
||||
switch (element.kind) {
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.VariableStatement:
|
||||
case SyntaxKind.Block:
|
||||
@ -211,8 +173,8 @@ module TypeScript {
|
||||
public static isAngleBracket(positionedElement: ISyntaxElement): boolean {
|
||||
var element = positionedElement;
|
||||
var parent = positionedElement.parent;
|
||||
if (parent && (element.kind() === SyntaxKind.LessThanToken || element.kind() === SyntaxKind.GreaterThanToken)) {
|
||||
switch (parent.kind()) {
|
||||
if (parent && (element.kind === SyntaxKind.LessThanToken || element.kind === SyntaxKind.GreaterThanToken)) {
|
||||
switch (parent.kind) {
|
||||
case SyntaxKind.TypeArgumentList:
|
||||
case SyntaxKind.TypeParameterList:
|
||||
case SyntaxKind.CastExpression:
|
||||
@ -226,7 +188,7 @@ module TypeScript {
|
||||
public static getToken(list: ISyntaxToken[], kind: SyntaxKind): ISyntaxToken {
|
||||
for (var i = 0, n = list.length; i < n; i++) {
|
||||
var token = list[i];
|
||||
if (token.kind() === kind) {
|
||||
if (token.kind === kind) {
|
||||
return token;
|
||||
}
|
||||
}
|
||||
@ -243,7 +205,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
public static getExportKeyword(moduleElement: IModuleElementSyntax): ISyntaxToken {
|
||||
switch (moduleElement.kind()) {
|
||||
switch (moduleElement.kind) {
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
@ -263,7 +225,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
var node = positionNode;
|
||||
switch (node.kind()) {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
case SyntaxKind.ClassDeclaration:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
|
||||
@ -3,8 +3,7 @@
|
||||
module TypeScript {
|
||||
export function visitNodeOrToken(visitor: ISyntaxVisitor, element: ISyntaxNodeOrToken): any {
|
||||
if (element === undefined) { return undefined; }
|
||||
if (isToken(element)) { return visitor.visitToken(<ISyntaxToken>element); }
|
||||
switch (element.kind()) {
|
||||
switch (element.kind) {
|
||||
case SyntaxKind.SourceUnit: return visitor.visitSourceUnit(<SourceUnitSyntax>element);
|
||||
case SyntaxKind.QualifiedName: return visitor.visitQualifiedName(<QualifiedNameSyntax>element);
|
||||
case SyntaxKind.ObjectType: return visitor.visitObjectType(<ObjectTypeSyntax>element);
|
||||
@ -71,6 +70,8 @@ module TypeScript {
|
||||
case SyntaxKind.ElementAccessExpression: return visitor.visitElementAccessExpression(<ElementAccessExpressionSyntax>element);
|
||||
case SyntaxKind.FunctionExpression: return visitor.visitFunctionExpression(<FunctionExpressionSyntax>element);
|
||||
case SyntaxKind.OmittedExpression: return visitor.visitOmittedExpression(<OmittedExpressionSyntax>element);
|
||||
case SyntaxKind.TemplateExpression: return visitor.visitTemplateExpression(<TemplateExpressionSyntax>element);
|
||||
case SyntaxKind.TemplateAccessExpression: return visitor.visitTemplateAccessExpression(<TemplateAccessExpressionSyntax>element);
|
||||
case SyntaxKind.VariableDeclaration: return visitor.visitVariableDeclaration(<VariableDeclarationSyntax>element);
|
||||
case SyntaxKind.VariableDeclarator: return visitor.visitVariableDeclarator(<VariableDeclaratorSyntax>element);
|
||||
case SyntaxKind.ArgumentList: return visitor.visitArgumentList(<ArgumentListSyntax>element);
|
||||
@ -84,6 +85,7 @@ module TypeScript {
|
||||
case SyntaxKind.ElseClause: return visitor.visitElseClause(<ElseClauseSyntax>element);
|
||||
case SyntaxKind.CatchClause: return visitor.visitCatchClause(<CatchClauseSyntax>element);
|
||||
case SyntaxKind.FinallyClause: return visitor.visitFinallyClause(<FinallyClauseSyntax>element);
|
||||
case SyntaxKind.TemplateClause: return visitor.visitTemplateClause(<TemplateClauseSyntax>element);
|
||||
case SyntaxKind.TypeParameter: return visitor.visitTypeParameter(<TypeParameterSyntax>element);
|
||||
case SyntaxKind.Constraint: return visitor.visitConstraint(<ConstraintSyntax>element);
|
||||
case SyntaxKind.SimplePropertyAssignment: return visitor.visitSimplePropertyAssignment(<SimplePropertyAssignmentSyntax>element);
|
||||
@ -93,9 +95,8 @@ module TypeScript {
|
||||
case SyntaxKind.TypeAnnotation: return visitor.visitTypeAnnotation(<TypeAnnotationSyntax>element);
|
||||
case SyntaxKind.ExternalModuleReference: return visitor.visitExternalModuleReference(<ExternalModuleReferenceSyntax>element);
|
||||
case SyntaxKind.ModuleNameModuleReference: return visitor.visitModuleNameModuleReference(<ModuleNameModuleReferenceSyntax>element);
|
||||
default: return visitor.visitToken(<ISyntaxToken>element);
|
||||
}
|
||||
|
||||
throw Errors.invalidOperation();
|
||||
}
|
||||
|
||||
export interface ISyntaxVisitor {
|
||||
@ -166,6 +167,8 @@ module TypeScript {
|
||||
visitElementAccessExpression(node: ElementAccessExpressionSyntax): any;
|
||||
visitFunctionExpression(node: FunctionExpressionSyntax): any;
|
||||
visitOmittedExpression(node: OmittedExpressionSyntax): any;
|
||||
visitTemplateExpression(node: TemplateExpressionSyntax): any;
|
||||
visitTemplateAccessExpression(node: TemplateAccessExpressionSyntax): any;
|
||||
visitVariableDeclaration(node: VariableDeclarationSyntax): any;
|
||||
visitVariableDeclarator(node: VariableDeclaratorSyntax): any;
|
||||
visitArgumentList(node: ArgumentListSyntax): any;
|
||||
@ -179,6 +182,7 @@ module TypeScript {
|
||||
visitElseClause(node: ElseClauseSyntax): any;
|
||||
visitCatchClause(node: CatchClauseSyntax): any;
|
||||
visitFinallyClause(node: FinallyClauseSyntax): any;
|
||||
visitTemplateClause(node: TemplateClauseSyntax): any;
|
||||
visitTypeParameter(node: TypeParameterSyntax): any;
|
||||
visitConstraint(node: ConstraintSyntax): any;
|
||||
visitSimplePropertyAssignment(node: SimplePropertyAssignmentSyntax): any;
|
||||
|
||||
@ -15,14 +15,7 @@ module TypeScript {
|
||||
|
||||
public visitList(list: ISyntaxNodeOrToken[]): void {
|
||||
for (var i = 0, n = list.length; i < n; i++) {
|
||||
visitNodeOrToken(this, list[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public visitSeparatedList(list: ISyntaxNodeOrToken[]): void {
|
||||
for (var i = 0, n = childCount(list); i < n; i++) {
|
||||
var item = childAt(list, i);
|
||||
visitNodeOrToken(this, item);
|
||||
visitNodeOrToken(this, list[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +32,7 @@ module TypeScript {
|
||||
|
||||
public visitObjectType(node: ObjectTypeSyntax): void {
|
||||
this.visitToken(node.openBraceToken);
|
||||
this.visitSeparatedList(node.typeMembers);
|
||||
this.visitList(node.typeMembers);
|
||||
this.visitToken(node.closeBraceToken);
|
||||
}
|
||||
|
||||
@ -76,7 +69,7 @@ module TypeScript {
|
||||
|
||||
public visitTupleType(node: TupleTypeSyntax): void {
|
||||
this.visitToken(node.openBracketToken);
|
||||
this.visitSeparatedList(node.types);
|
||||
this.visitList(node.types);
|
||||
this.visitToken(node.closeBracketToken);
|
||||
}
|
||||
|
||||
@ -136,7 +129,7 @@ module TypeScript {
|
||||
this.visitToken(node.enumKeyword);
|
||||
this.visitToken(node.identifier);
|
||||
this.visitToken(node.openBraceToken);
|
||||
this.visitSeparatedList(node.enumElements);
|
||||
this.visitList(node.enumElements);
|
||||
this.visitToken(node.closeBraceToken);
|
||||
}
|
||||
|
||||
@ -219,7 +212,7 @@ module TypeScript {
|
||||
|
||||
public visitIndexSignature(node: IndexSignatureSyntax): void {
|
||||
this.visitToken(node.openBracketToken);
|
||||
this.visitSeparatedList(node.parameters);
|
||||
this.visitList(node.parameters);
|
||||
this.visitToken(node.closeBracketToken);
|
||||
visitNodeOrToken(this, node.typeAnnotation);
|
||||
}
|
||||
@ -414,13 +407,13 @@ module TypeScript {
|
||||
|
||||
public visitArrayLiteralExpression(node: ArrayLiteralExpressionSyntax): void {
|
||||
this.visitToken(node.openBracketToken);
|
||||
this.visitSeparatedList(node.expressions);
|
||||
this.visitList(node.expressions);
|
||||
this.visitToken(node.closeBracketToken);
|
||||
}
|
||||
|
||||
public visitObjectLiteralExpression(node: ObjectLiteralExpressionSyntax): void {
|
||||
this.visitToken(node.openBraceToken);
|
||||
this.visitSeparatedList(node.propertyAssignments);
|
||||
this.visitList(node.propertyAssignments);
|
||||
this.visitToken(node.closeBraceToken);
|
||||
}
|
||||
|
||||
@ -474,9 +467,19 @@ module TypeScript {
|
||||
public visitOmittedExpression(node: OmittedExpressionSyntax): void {
|
||||
}
|
||||
|
||||
public visitTemplateExpression(node: TemplateExpressionSyntax): void {
|
||||
this.visitToken(node.templateStartToken);
|
||||
this.visitList(node.templateClauses);
|
||||
}
|
||||
|
||||
public visitTemplateAccessExpression(node: TemplateAccessExpressionSyntax): void {
|
||||
visitNodeOrToken(this, node.expression);
|
||||
visitNodeOrToken(this, node.templateExpression);
|
||||
}
|
||||
|
||||
public visitVariableDeclaration(node: VariableDeclarationSyntax): void {
|
||||
this.visitToken(node.varKeyword);
|
||||
this.visitSeparatedList(node.variableDeclarators);
|
||||
this.visitList(node.variableDeclarators);
|
||||
}
|
||||
|
||||
public visitVariableDeclarator(node: VariableDeclaratorSyntax): void {
|
||||
@ -488,31 +491,31 @@ module TypeScript {
|
||||
public visitArgumentList(node: ArgumentListSyntax): void {
|
||||
visitNodeOrToken(this, node.typeArgumentList);
|
||||
this.visitToken(node.openParenToken);
|
||||
this.visitSeparatedList(node.arguments);
|
||||
this.visitList(node.arguments);
|
||||
this.visitToken(node.closeParenToken);
|
||||
}
|
||||
|
||||
public visitParameterList(node: ParameterListSyntax): void {
|
||||
this.visitToken(node.openParenToken);
|
||||
this.visitSeparatedList(node.parameters);
|
||||
this.visitList(node.parameters);
|
||||
this.visitToken(node.closeParenToken);
|
||||
}
|
||||
|
||||
public visitTypeArgumentList(node: TypeArgumentListSyntax): void {
|
||||
this.visitToken(node.lessThanToken);
|
||||
this.visitSeparatedList(node.typeArguments);
|
||||
this.visitList(node.typeArguments);
|
||||
this.visitToken(node.greaterThanToken);
|
||||
}
|
||||
|
||||
public visitTypeParameterList(node: TypeParameterListSyntax): void {
|
||||
this.visitToken(node.lessThanToken);
|
||||
this.visitSeparatedList(node.typeParameters);
|
||||
this.visitList(node.typeParameters);
|
||||
this.visitToken(node.greaterThanToken);
|
||||
}
|
||||
|
||||
public visitHeritageClause(node: HeritageClauseSyntax): void {
|
||||
this.visitToken(node.extendsOrImplementsKeyword);
|
||||
this.visitSeparatedList(node.typeNames);
|
||||
this.visitList(node.typeNames);
|
||||
}
|
||||
|
||||
public visitEqualsValueClause(node: EqualsValueClauseSyntax): void {
|
||||
@ -552,6 +555,11 @@ module TypeScript {
|
||||
visitNodeOrToken(this, node.block);
|
||||
}
|
||||
|
||||
public visitTemplateClause(node: TemplateClauseSyntax): void {
|
||||
visitNodeOrToken(this, node.expression);
|
||||
this.visitToken(node.templateMiddleOrEndToken);
|
||||
}
|
||||
|
||||
public visitTypeParameter(node: TypeParameterSyntax): void {
|
||||
this.visitToken(node.identifier);
|
||||
visitNodeOrToken(this, node.constraint);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
module TypeScript {
|
||||
function assertParent(parent: ISyntaxElement, child: ISyntaxElement) {
|
||||
if (child && !TypeScript.isShared(child)) {
|
||||
if (child) {
|
||||
return Debug.assert(parent === child.parent);
|
||||
}
|
||||
}
|
||||
@ -9,10 +9,10 @@ module TypeScript {
|
||||
if (node1 === node2) { return true; }
|
||||
if (!node1 || !node2) { return false; }
|
||||
|
||||
Debug.assert(node1.kind() === TypeScript.SyntaxKind.SourceUnit || node1.parent);
|
||||
Debug.assert(node2.kind() === TypeScript.SyntaxKind.SourceUnit || node2.parent);
|
||||
Debug.assert(node1.kind === TypeScript.SyntaxKind.SourceUnit || node1.parent);
|
||||
Debug.assert(node2.kind === TypeScript.SyntaxKind.SourceUnit || node2.parent);
|
||||
|
||||
if (node1.kind() !== node2.kind()) { return false; }
|
||||
if (node1.kind !== node2.kind) { return false; }
|
||||
if (childCount(node1) !== childCount(node2)) { return false; }
|
||||
|
||||
for (var i = 0, n = childCount(node1); i < n; i++) {
|
||||
@ -41,8 +41,8 @@ module TypeScript {
|
||||
return false;
|
||||
}
|
||||
|
||||
Debug.assert(node1.kind() === TypeScript.SyntaxKind.SourceUnit || node1.parent);
|
||||
Debug.assert(node2.kind() === TypeScript.SyntaxKind.SourceUnit || node2.parent);
|
||||
Debug.assert(node1.kind === TypeScript.SyntaxKind.SourceUnit || node1.parent);
|
||||
Debug.assert(node2.kind === TypeScript.SyntaxKind.SourceUnit || node2.parent);
|
||||
|
||||
if (TypeScript.isToken(node1)) {
|
||||
return TypeScript.isToken(node2) ? tokenStructuralEquals(<TypeScript.ISyntaxToken>node1, <TypeScript.ISyntaxToken>node2, text1, text2) : false;
|
||||
@ -63,7 +63,7 @@ module TypeScript {
|
||||
Debug.assert(token1.parent);
|
||||
Debug.assert(token2.parent);
|
||||
|
||||
return token1.kind() === token2.kind() &&
|
||||
return token1.kind === token2.kind &&
|
||||
TypeScript.width(token1) === TypeScript.width(token2) &&
|
||||
token1.fullWidth() === token2.fullWidth() &&
|
||||
token1.fullStart() === token2.fullStart() &&
|
||||
@ -102,8 +102,8 @@ module TypeScript {
|
||||
}
|
||||
|
||||
function listStructuralEquals<T extends TypeScript.ISyntaxNodeOrToken>(list1: T[], list2: T[], checkParents: boolean, text1: ISimpleText, text2: ISimpleText): boolean {
|
||||
Debug.assert(TypeScript.isShared(list1) || list1.parent);
|
||||
Debug.assert(TypeScript.isShared(list2) || list2.parent);
|
||||
Debug.assert(list1.parent);
|
||||
Debug.assert(list2.parent);
|
||||
|
||||
if (childCount(list1) !== childCount(list2)) {
|
||||
return false;
|
||||
@ -118,32 +118,7 @@ module TypeScript {
|
||||
assertParent(list2, child2);
|
||||
}
|
||||
|
||||
if (!nodeOrTokenStructuralEquals(child1, child2, checkParents, text1, text2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function separatedListStructuralEquals<T extends TypeScript.ISyntaxNodeOrToken>(list1: T[], list2: T[], checkParents: boolean, text1: ISimpleText, text2: ISimpleText): boolean {
|
||||
Debug.assert(TypeScript.isShared(list1) || list1.parent);
|
||||
Debug.assert(TypeScript.isShared(list2) || list2.parent);
|
||||
|
||||
if (childCount(list1) !== childCount(list2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0, n = childCount(list1); i < n; i++) {
|
||||
var element1 = childAt(list1, i);
|
||||
var element2 = childAt(list2, i);
|
||||
|
||||
if (checkParents) {
|
||||
assertParent(list1, element1);
|
||||
assertParent(list2, element2);
|
||||
}
|
||||
|
||||
if (!nodeOrTokenStructuralEquals(element1, element2, checkParents, text1, text2)) {
|
||||
if (!elementStructuralEquals(child1, child2, checkParents, text1, text2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -160,10 +135,10 @@ module TypeScript {
|
||||
return false;
|
||||
}
|
||||
|
||||
Debug.assert(element1.kind() === SyntaxKind.SourceUnit || element1.parent);
|
||||
Debug.assert(element2.kind() === SyntaxKind.SourceUnit || element2.parent);
|
||||
Debug.assert(element1.kind === SyntaxKind.SourceUnit || element1.parent);
|
||||
Debug.assert(element2.kind === SyntaxKind.SourceUnit || element2.parent);
|
||||
|
||||
if (element2.kind() !== element2.kind()) {
|
||||
if (element2.kind !== element2.kind) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -192,9 +167,6 @@ module TypeScript {
|
||||
else if (TypeScript.isList(element1)) {
|
||||
return listStructuralEquals(<TypeScript.ISyntaxNodeOrToken[]>element1, <TypeScript.ISyntaxNodeOrToken[]>element2, checkParents, text1, text2);
|
||||
}
|
||||
else if (TypeScript.isSeparatedList(element1)) {
|
||||
return separatedListStructuralEquals(<TypeScript.ISyntaxNodeOrToken[]>element1, <TypeScript.ISyntaxNodeOrToken[]>element2, checkParents, text1, text2);
|
||||
}
|
||||
|
||||
throw TypeScript.Errors.invalidOperation();
|
||||
}
|
||||
|
||||
4
src/services/syntax/utilities.generated.ts
Normal file
4
src/services/syntax/utilities.generated.ts
Normal file
@ -0,0 +1,4 @@
|
||||
var fixedWidthArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 5, 8, 8, 7, 6, 2, 4, 5, 7, 3, 8, 2, 2, 10, 3, 4, 6, 6, 4, 5, 4, 3, 6, 3, 4, 5, 4, 5, 5, 4, 6, 7, 6, 5, 10, 9, 3, 7, 7, 9, 6, 6, 5, 3, 7, 11, 7, 3, 6, 7, 6, 3, 6, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 2, 2, 2, 1, 2];
|
||||
function fixedWidthTokenLength(kind: SyntaxKind) {
|
||||
return fixedWidthArray[kind];
|
||||
}
|
||||
@ -104,6 +104,7 @@ module TypeScript {
|
||||
asterisk = 42, // *
|
||||
at = 64, // @
|
||||
backslash = 92, // \
|
||||
backtick = 96, // `
|
||||
bar = 124, // |
|
||||
caret = 94, // ^
|
||||
closeBrace = 125, // }
|
||||
|
||||
@ -12,7 +12,10 @@ module TypeScript.SimpleText {
|
||||
}
|
||||
|
||||
public substr(start: number, length: number): string {
|
||||
return this.value.substr(start, length);
|
||||
var val = this.value;
|
||||
return start === 0 && length == val.length
|
||||
? val
|
||||
: val.substr(start, length);
|
||||
}
|
||||
|
||||
public charCodeAt(index: number): number {
|
||||
|
||||
@ -50,12 +50,12 @@ var r3 = null + b;
|
||||
var r4 = null + 1;
|
||||
var r5 = null + c;
|
||||
var r6 = null + 0 /* a */;
|
||||
var r7 = null + E['a'];
|
||||
var r7 = null + 0 /* 'a' */;
|
||||
var r8 = b + null;
|
||||
var r9 = 1 + null;
|
||||
var r10 = c + null;
|
||||
var r11 = 0 /* a */ + null;
|
||||
var r12 = E['a'] + null;
|
||||
var r12 = 0 /* 'a' */ + null;
|
||||
// null + string
|
||||
var r13 = null + d;
|
||||
var r14 = null + '';
|
||||
|
||||
@ -29,4 +29,4 @@ var r4 = b + b;
|
||||
var r5 = 0 + a;
|
||||
var r6 = 0 /* a */ + 0;
|
||||
var r7 = 0 /* a */ + 1 /* b */;
|
||||
var r8 = E['a'] + E['b'];
|
||||
var r8 = 0 /* 'a' */ + 1 /* 'b' */;
|
||||
|
||||
@ -50,12 +50,12 @@ var r3 = undefined + b;
|
||||
var r4 = undefined + 1;
|
||||
var r5 = undefined + c;
|
||||
var r6 = undefined + 0 /* a */;
|
||||
var r7 = undefined + E['a'];
|
||||
var r7 = undefined + 0 /* 'a' */;
|
||||
var r8 = b + undefined;
|
||||
var r9 = 1 + undefined;
|
||||
var r10 = c + undefined;
|
||||
var r11 = 0 /* a */ + undefined;
|
||||
var r12 = E['a'] + undefined;
|
||||
var r12 = 0 /* 'a' */ + undefined;
|
||||
// undefined + string
|
||||
var r13 = undefined + d;
|
||||
var r14 = undefined + '';
|
||||
|
||||
@ -30,11 +30,11 @@ var ENUM1;
|
||||
// enum type var
|
||||
var ResultIsNumber1 = ~ENUM1;
|
||||
// enum type expressions
|
||||
var ResultIsNumber2 = ~ENUM1["A"];
|
||||
var ResultIsNumber3 = ~(0 /* A */ + ENUM1["B"]);
|
||||
var ResultIsNumber2 = ~0 /* "A" */;
|
||||
var ResultIsNumber3 = ~(0 /* A */ + 1 /* "B" */);
|
||||
// multiple ~ operators
|
||||
var ResultIsNumber4 = ~~~(ENUM1["A"] + 1 /* B */);
|
||||
var ResultIsNumber4 = ~~~(0 /* "A" */ + 1 /* B */);
|
||||
// miss assignment operators
|
||||
~ENUM1;
|
||||
~ENUM1["A"];
|
||||
~0 /* A */, ~ENUM1["B"];
|
||||
~0 /* "A" */;
|
||||
~0 /* A */, ~1 /* "B" */;
|
||||
|
||||
28
tests/baselines/reference/constEnumDeclarations.js
Normal file
28
tests/baselines/reference/constEnumDeclarations.js
Normal file
@ -0,0 +1,28 @@
|
||||
//// [constEnumDeclarations.ts]
|
||||
|
||||
const enum E {
|
||||
A = 1,
|
||||
B = 2,
|
||||
C = A | B
|
||||
}
|
||||
|
||||
const enum E2 {
|
||||
A = 1,
|
||||
B,
|
||||
C
|
||||
}
|
||||
|
||||
//// [constEnumDeclarations.js]
|
||||
|
||||
|
||||
//// [constEnumDeclarations.d.ts]
|
||||
declare const enum E {
|
||||
A = 1,
|
||||
B = 2,
|
||||
C = 3,
|
||||
}
|
||||
declare const enum E2 {
|
||||
A = 1,
|
||||
B = 2,
|
||||
C = 3,
|
||||
}
|
||||
30
tests/baselines/reference/constEnumDeclarations.types
Normal file
30
tests/baselines/reference/constEnumDeclarations.types
Normal file
@ -0,0 +1,30 @@
|
||||
=== tests/cases/compiler/constEnumDeclarations.ts ===
|
||||
|
||||
const enum E {
|
||||
>E : E
|
||||
|
||||
A = 1,
|
||||
>A : E
|
||||
|
||||
B = 2,
|
||||
>B : E
|
||||
|
||||
C = A | B
|
||||
>C : E
|
||||
>A | B : number
|
||||
>A : E
|
||||
>B : E
|
||||
}
|
||||
|
||||
const enum E2 {
|
||||
>E2 : E2
|
||||
|
||||
A = 1,
|
||||
>A : E2
|
||||
|
||||
B,
|
||||
>B : E2
|
||||
|
||||
C
|
||||
>C : E2
|
||||
}
|
||||
85
tests/baselines/reference/constEnumErrors.errors.txt
Normal file
85
tests/baselines/reference/constEnumErrors.errors.txt
Normal file
@ -0,0 +1,85 @@
|
||||
tests/cases/compiler/constEnumErrors.ts(1,12): error TS2300: Duplicate identifier 'E'.
|
||||
tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier 'E'.
|
||||
tests/cases/compiler/constEnumErrors.ts(12,9): error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
||||
tests/cases/compiler/constEnumErrors.ts(14,9): error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
||||
tests/cases/compiler/constEnumErrors.ts(15,10): error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
||||
tests/cases/compiler/constEnumErrors.ts(22,13): error TS4085: Index expression arguments in 'const' enums must be of type 'string'.
|
||||
tests/cases/compiler/constEnumErrors.ts(24,13): error TS4085: Index expression arguments in 'const' enums must be of type 'string'.
|
||||
tests/cases/compiler/constEnumErrors.ts(26,9): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
||||
tests/cases/compiler/constEnumErrors.ts(27,10): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
||||
tests/cases/compiler/constEnumErrors.ts(32,5): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
||||
tests/cases/compiler/constEnumErrors.ts(40,9): error TS4086: 'const' enum member initializer was evaluated to a non-finite value.
|
||||
tests/cases/compiler/constEnumErrors.ts(41,9): error TS4086: 'const' enum member initializer was evaluated to a non-finite value.
|
||||
tests/cases/compiler/constEnumErrors.ts(42,9): error TS4087: 'const' enum member initializer was evaluated to disallowed value 'NaN'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constEnumErrors.ts (13 errors) ====
|
||||
const enum E {
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'E'.
|
||||
A
|
||||
}
|
||||
|
||||
module E {
|
||||
~
|
||||
!!! error TS2300: Duplicate identifier 'E'.
|
||||
var x = 1;
|
||||
}
|
||||
|
||||
const enum E1 {
|
||||
// illegal case
|
||||
// forward reference to the element of the same enum
|
||||
X = Y,
|
||||
~
|
||||
!!! error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
||||
// forward reference to the element of the same enum
|
||||
Y = E1.Z,
|
||||
~~~~
|
||||
!!! error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
||||
Y1 = E1["Z"]
|
||||
~~~~~~~
|
||||
!!! error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
||||
}
|
||||
|
||||
const enum E2 {
|
||||
A
|
||||
}
|
||||
|
||||
var y0 = E2[1]
|
||||
~
|
||||
!!! error TS4085: Index expression arguments in 'const' enums must be of type 'string'.
|
||||
var name = "A";
|
||||
var y1 = E2[name];
|
||||
~~~~
|
||||
!!! error TS4085: Index expression arguments in 'const' enums must be of type 'string'.
|
||||
|
||||
var x = E2;
|
||||
~~
|
||||
!!! error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
||||
var y = [E2];
|
||||
~~
|
||||
!!! error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
||||
|
||||
function foo(t: any): void {
|
||||
}
|
||||
|
||||
foo(E2);
|
||||
~~
|
||||
!!! error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
||||
|
||||
const enum NaNOrInfinity {
|
||||
A = 9007199254740992,
|
||||
B = A * A,
|
||||
C = B * B,
|
||||
D = C * C,
|
||||
E = D * D,
|
||||
F = E * E, // overflow
|
||||
~~~~~
|
||||
!!! error TS4086: 'const' enum member initializer was evaluated to a non-finite value.
|
||||
G = 1 / 0, // overflow
|
||||
~~~~~
|
||||
!!! error TS4086: 'const' enum member initializer was evaluated to a non-finite value.
|
||||
H = 0 / 0 // NaN
|
||||
~~~~~
|
||||
!!! error TS4087: 'const' enum member initializer was evaluated to disallowed value 'NaN'.
|
||||
}
|
||||
19
tests/baselines/reference/constEnumExternalModule.js
Normal file
19
tests/baselines/reference/constEnumExternalModule.js
Normal file
@ -0,0 +1,19 @@
|
||||
//// [tests/cases/compiler/constEnumExternalModule.ts] ////
|
||||
|
||||
//// [m1.ts]
|
||||
const enum E {
|
||||
V = 100
|
||||
}
|
||||
|
||||
export = E
|
||||
//// [m2.ts]
|
||||
import A = require('m1')
|
||||
var v = A.V;
|
||||
|
||||
//// [m1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
});
|
||||
//// [m2.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var v = 100 /* V */;
|
||||
});
|
||||
21
tests/baselines/reference/constEnumExternalModule.types
Normal file
21
tests/baselines/reference/constEnumExternalModule.types
Normal file
@ -0,0 +1,21 @@
|
||||
=== tests/cases/compiler/m2.ts ===
|
||||
import A = require('m1')
|
||||
>A : typeof A
|
||||
|
||||
var v = A.V;
|
||||
>v : A
|
||||
>A.V : A
|
||||
>A : typeof A
|
||||
>V : A
|
||||
|
||||
=== tests/cases/compiler/m1.ts ===
|
||||
const enum E {
|
||||
>E : E
|
||||
|
||||
V = 100
|
||||
>V : E
|
||||
}
|
||||
|
||||
export = E
|
||||
>E : E
|
||||
|
||||
223
tests/baselines/reference/constEnums.js
Normal file
223
tests/baselines/reference/constEnums.js
Normal file
@ -0,0 +1,223 @@
|
||||
//// [constEnums.ts]
|
||||
const enum Enum1 {
|
||||
A0 = 100,
|
||||
}
|
||||
|
||||
const enum Enum1 {
|
||||
// correct cases
|
||||
A,
|
||||
B,
|
||||
C = 10,
|
||||
D = A | B,
|
||||
E = A | 1,
|
||||
F = 1 | A,
|
||||
G = (1 & 1),
|
||||
H = ~(A | B),
|
||||
I = A >>> 1,
|
||||
J = 1 & A,
|
||||
K = ~(1 | 5),
|
||||
L = ~D,
|
||||
M = E << B,
|
||||
N = E << 1,
|
||||
O = E >> B,
|
||||
P = E >> 1,
|
||||
Q = -D,
|
||||
R = C & 5,
|
||||
S = 5 & C,
|
||||
T = C | D,
|
||||
U = C | 1,
|
||||
V = 10 | D,
|
||||
W = Enum1.V,
|
||||
|
||||
// correct cases: reference to the enum member from different enum declaration
|
||||
W1 = A0,
|
||||
W2 = Enum1.A0,
|
||||
W3 = Enum1["A0"],
|
||||
W4 = Enum1["W"],
|
||||
}
|
||||
|
||||
|
||||
module A {
|
||||
export module B {
|
||||
export module C {
|
||||
export const enum E {
|
||||
V1 = 1,
|
||||
V2 = A.B.C.E.V1 | 100
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module A {
|
||||
export module B {
|
||||
export module C {
|
||||
export const enum E {
|
||||
V3 = A.B.C.E["V2"] & 200,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module A1 {
|
||||
export module B {
|
||||
export module C {
|
||||
export const enum E {
|
||||
V1 = 10,
|
||||
V2 = 110,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module A2 {
|
||||
export module B {
|
||||
export module C {
|
||||
export const enum E {
|
||||
V1 = 10,
|
||||
V2 = 110,
|
||||
}
|
||||
}
|
||||
// module C will be classified as value
|
||||
export module C {
|
||||
var x = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
import I = A.B.C.E;
|
||||
import I1 = A1.B;
|
||||
import I2 = A2.B;
|
||||
|
||||
function foo0(e: I): void {
|
||||
if (e === I.V1) {
|
||||
}
|
||||
else if (e === I.V2) {
|
||||
}
|
||||
}
|
||||
|
||||
function foo1(e: I1.C.E): void {
|
||||
if (e === I1.C.E.V1) {
|
||||
}
|
||||
else if (e === I1.C.E.V2) {
|
||||
}
|
||||
}
|
||||
|
||||
function foo2(e: I2.C.E): void {
|
||||
if (e === I2.C.E.V1) {
|
||||
}
|
||||
else if (e === I2.C.E.V2) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function foo(x: Enum1) {
|
||||
switch (x) {
|
||||
case Enum1.A:
|
||||
case Enum1.B:
|
||||
case Enum1.C:
|
||||
case Enum1.D:
|
||||
case Enum1.E:
|
||||
case Enum1.F:
|
||||
case Enum1.G:
|
||||
case Enum1.H:
|
||||
case Enum1.I:
|
||||
case Enum1.J:
|
||||
case Enum1.K:
|
||||
case Enum1.L:
|
||||
case Enum1.M:
|
||||
case Enum1.N:
|
||||
case Enum1.O:
|
||||
case Enum1.P:
|
||||
case Enum1.Q:
|
||||
case Enum1.R:
|
||||
case Enum1.S:
|
||||
case Enum1["T"]:
|
||||
case Enum1.U:
|
||||
case Enum1.V:
|
||||
case Enum1.W:
|
||||
case Enum1.W1:
|
||||
case Enum1.W2:
|
||||
case Enum1.W3:
|
||||
case Enum1.W4:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function bar(e: A.B.C.E): number {
|
||||
switch (e) {
|
||||
case A.B.C.E.V1: return 1;
|
||||
case A.B.C.E.V2: return 1;
|
||||
case A.B.C.E.V3: return 1;
|
||||
}
|
||||
}
|
||||
|
||||
//// [constEnums.js]
|
||||
var A2;
|
||||
(function (A2) {
|
||||
var B;
|
||||
(function (B) {
|
||||
// module C will be classified as value
|
||||
var C;
|
||||
(function (C) {
|
||||
var x = 1;
|
||||
})(C = B.C || (B.C = {}));
|
||||
})(B = A2.B || (A2.B = {}));
|
||||
})(A2 || (A2 = {}));
|
||||
var I2 = A2.B;
|
||||
function foo0(e) {
|
||||
if (e === 1 /* V1 */) {
|
||||
}
|
||||
else if (e === 101 /* V2 */) {
|
||||
}
|
||||
}
|
||||
function foo1(e) {
|
||||
if (e === 10 /* V1 */) {
|
||||
}
|
||||
else if (e === 110 /* V2 */) {
|
||||
}
|
||||
}
|
||||
function foo2(e) {
|
||||
if (e === 10 /* V1 */) {
|
||||
}
|
||||
else if (e === 110 /* V2 */) {
|
||||
}
|
||||
}
|
||||
function foo(x) {
|
||||
switch (x) {
|
||||
case 0 /* A */:
|
||||
case 1 /* B */:
|
||||
case 10 /* C */:
|
||||
case 1 /* D */:
|
||||
case 1 /* E */:
|
||||
case 1 /* F */:
|
||||
case 1 /* G */:
|
||||
case -2 /* H */:
|
||||
case 0 /* I */:
|
||||
case 0 /* J */:
|
||||
case -6 /* K */:
|
||||
case -2 /* L */:
|
||||
case 2 /* M */:
|
||||
case 2 /* N */:
|
||||
case 0 /* O */:
|
||||
case 0 /* P */:
|
||||
case -1 /* Q */:
|
||||
case 0 /* R */:
|
||||
case 0 /* S */:
|
||||
case 11 /* "T" */:
|
||||
case 11 /* U */:
|
||||
case 11 /* V */:
|
||||
case 11 /* W */:
|
||||
case 100 /* W1 */:
|
||||
case 100 /* W2 */:
|
||||
case 100 /* W3 */:
|
||||
case 11 /* W4 */:
|
||||
break;
|
||||
}
|
||||
}
|
||||
function bar(e) {
|
||||
switch (e) {
|
||||
case 1 /* V1 */: return 1;
|
||||
case 101 /* V2 */: return 1;
|
||||
case 64 /* V3 */: return 1;
|
||||
}
|
||||
}
|
||||
556
tests/baselines/reference/constEnums.types
Normal file
556
tests/baselines/reference/constEnums.types
Normal file
@ -0,0 +1,556 @@
|
||||
=== tests/cases/compiler/constEnums.ts ===
|
||||
const enum Enum1 {
|
||||
>Enum1 : Enum1
|
||||
|
||||
A0 = 100,
|
||||
>A0 : Enum1
|
||||
}
|
||||
|
||||
const enum Enum1 {
|
||||
>Enum1 : Enum1
|
||||
|
||||
// correct cases
|
||||
A,
|
||||
>A : Enum1
|
||||
|
||||
B,
|
||||
>B : Enum1
|
||||
|
||||
C = 10,
|
||||
>C : Enum1
|
||||
|
||||
D = A | B,
|
||||
>D : Enum1
|
||||
>A | B : number
|
||||
>A : Enum1
|
||||
>B : Enum1
|
||||
|
||||
E = A | 1,
|
||||
>E : Enum1
|
||||
>A | 1 : number
|
||||
>A : Enum1
|
||||
|
||||
F = 1 | A,
|
||||
>F : Enum1
|
||||
>1 | A : number
|
||||
>A : Enum1
|
||||
|
||||
G = (1 & 1),
|
||||
>G : Enum1
|
||||
>(1 & 1) : number
|
||||
>1 & 1 : number
|
||||
|
||||
H = ~(A | B),
|
||||
>H : Enum1
|
||||
>~(A | B) : number
|
||||
>(A | B) : number
|
||||
>A | B : number
|
||||
>A : Enum1
|
||||
>B : Enum1
|
||||
|
||||
I = A >>> 1,
|
||||
>I : Enum1
|
||||
>A >>> 1 : number
|
||||
>A : Enum1
|
||||
|
||||
J = 1 & A,
|
||||
>J : Enum1
|
||||
>1 & A : number
|
||||
>A : Enum1
|
||||
|
||||
K = ~(1 | 5),
|
||||
>K : Enum1
|
||||
>~(1 | 5) : number
|
||||
>(1 | 5) : number
|
||||
>1 | 5 : number
|
||||
|
||||
L = ~D,
|
||||
>L : Enum1
|
||||
>~D : number
|
||||
>D : Enum1
|
||||
|
||||
M = E << B,
|
||||
>M : Enum1
|
||||
>E << B : number
|
||||
>E : Enum1
|
||||
>B : Enum1
|
||||
|
||||
N = E << 1,
|
||||
>N : Enum1
|
||||
>E << 1 : number
|
||||
>E : Enum1
|
||||
|
||||
O = E >> B,
|
||||
>O : Enum1
|
||||
>E >> B : number
|
||||
>E : Enum1
|
||||
>B : Enum1
|
||||
|
||||
P = E >> 1,
|
||||
>P : Enum1
|
||||
>E >> 1 : number
|
||||
>E : Enum1
|
||||
|
||||
Q = -D,
|
||||
>Q : Enum1
|
||||
>-D : number
|
||||
>D : Enum1
|
||||
|
||||
R = C & 5,
|
||||
>R : Enum1
|
||||
>C & 5 : number
|
||||
>C : Enum1
|
||||
|
||||
S = 5 & C,
|
||||
>S : Enum1
|
||||
>5 & C : number
|
||||
>C : Enum1
|
||||
|
||||
T = C | D,
|
||||
>T : Enum1
|
||||
>C | D : number
|
||||
>C : Enum1
|
||||
>D : Enum1
|
||||
|
||||
U = C | 1,
|
||||
>U : Enum1
|
||||
>C | 1 : number
|
||||
>C : Enum1
|
||||
|
||||
V = 10 | D,
|
||||
>V : Enum1
|
||||
>10 | D : number
|
||||
>D : Enum1
|
||||
|
||||
W = Enum1.V,
|
||||
>W : Enum1
|
||||
>Enum1.V : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>V : Enum1
|
||||
|
||||
// correct cases: reference to the enum member from different enum declaration
|
||||
W1 = A0,
|
||||
>W1 : Enum1
|
||||
>A0 : Enum1
|
||||
|
||||
W2 = Enum1.A0,
|
||||
>W2 : Enum1
|
||||
>Enum1.A0 : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>A0 : Enum1
|
||||
|
||||
W3 = Enum1["A0"],
|
||||
>W3 : Enum1
|
||||
>Enum1["A0"] : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
|
||||
W4 = Enum1["W"],
|
||||
>W4 : Enum1
|
||||
>Enum1["W"] : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
}
|
||||
|
||||
|
||||
module A {
|
||||
>A : typeof A
|
||||
|
||||
export module B {
|
||||
>B : typeof B
|
||||
|
||||
export module C {
|
||||
>C : typeof C
|
||||
|
||||
export const enum E {
|
||||
>E : E
|
||||
|
||||
V1 = 1,
|
||||
>V1 : E
|
||||
|
||||
V2 = A.B.C.E.V1 | 100
|
||||
>V2 : E
|
||||
>A.B.C.E.V1 | 100 : number
|
||||
>A.B.C.E.V1 : E
|
||||
>A.B.C.E : typeof E
|
||||
>A.B.C : typeof C
|
||||
>A.B : typeof B
|
||||
>A : typeof A
|
||||
>B : typeof B
|
||||
>C : typeof C
|
||||
>E : typeof E
|
||||
>V1 : E
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module A {
|
||||
>A : typeof A
|
||||
|
||||
export module B {
|
||||
>B : typeof B
|
||||
|
||||
export module C {
|
||||
>C : typeof C
|
||||
|
||||
export const enum E {
|
||||
>E : E
|
||||
|
||||
V3 = A.B.C.E["V2"] & 200,
|
||||
>V3 : E
|
||||
>A.B.C.E["V2"] & 200 : number
|
||||
>A.B.C.E["V2"] : E
|
||||
>A.B.C.E : typeof E
|
||||
>A.B.C : typeof C
|
||||
>A.B : typeof B
|
||||
>A : typeof A
|
||||
>B : typeof B
|
||||
>C : typeof C
|
||||
>E : typeof E
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module A1 {
|
||||
>A1 : typeof A1
|
||||
|
||||
export module B {
|
||||
>B : typeof B
|
||||
|
||||
export module C {
|
||||
>C : typeof C
|
||||
|
||||
export const enum E {
|
||||
>E : E
|
||||
|
||||
V1 = 10,
|
||||
>V1 : E
|
||||
|
||||
V2 = 110,
|
||||
>V2 : E
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module A2 {
|
||||
>A2 : typeof A2
|
||||
|
||||
export module B {
|
||||
>B : typeof B
|
||||
|
||||
export module C {
|
||||
>C : typeof C
|
||||
|
||||
export const enum E {
|
||||
>E : E
|
||||
|
||||
V1 = 10,
|
||||
>V1 : E
|
||||
|
||||
V2 = 110,
|
||||
>V2 : E
|
||||
}
|
||||
}
|
||||
// module C will be classified as value
|
||||
export module C {
|
||||
>C : typeof C
|
||||
|
||||
var x = 1
|
||||
>x : number
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
import I = A.B.C.E;
|
||||
>I : typeof I
|
||||
>A : typeof A
|
||||
>B : typeof A.B
|
||||
>C : typeof A.B.C
|
||||
>E : I
|
||||
|
||||
import I1 = A1.B;
|
||||
>I1 : typeof I1
|
||||
>A1 : typeof A1
|
||||
>B : typeof I1
|
||||
|
||||
import I2 = A2.B;
|
||||
>I2 : typeof I2
|
||||
>A2 : typeof A2
|
||||
>B : typeof I2
|
||||
|
||||
function foo0(e: I): void {
|
||||
>foo0 : (e: I) => void
|
||||
>e : I
|
||||
>I : I
|
||||
|
||||
if (e === I.V1) {
|
||||
>e === I.V1 : boolean
|
||||
>e : I
|
||||
>I.V1 : I
|
||||
>I : typeof I
|
||||
>V1 : I
|
||||
}
|
||||
else if (e === I.V2) {
|
||||
>e === I.V2 : boolean
|
||||
>e : I
|
||||
>I.V2 : I
|
||||
>I : typeof I
|
||||
>V2 : I
|
||||
}
|
||||
}
|
||||
|
||||
function foo1(e: I1.C.E): void {
|
||||
>foo1 : (e: I1.C.E) => void
|
||||
>e : I1.C.E
|
||||
>I1 : unknown
|
||||
>C : unknown
|
||||
>E : I1.C.E
|
||||
|
||||
if (e === I1.C.E.V1) {
|
||||
>e === I1.C.E.V1 : boolean
|
||||
>e : I1.C.E
|
||||
>I1.C.E.V1 : I1.C.E
|
||||
>I1.C.E : typeof I1.C.E
|
||||
>I1.C : typeof I1.C
|
||||
>I1 : typeof I1
|
||||
>C : typeof I1.C
|
||||
>E : typeof I1.C.E
|
||||
>V1 : I1.C.E
|
||||
}
|
||||
else if (e === I1.C.E.V2) {
|
||||
>e === I1.C.E.V2 : boolean
|
||||
>e : I1.C.E
|
||||
>I1.C.E.V2 : I1.C.E
|
||||
>I1.C.E : typeof I1.C.E
|
||||
>I1.C : typeof I1.C
|
||||
>I1 : typeof I1
|
||||
>C : typeof I1.C
|
||||
>E : typeof I1.C.E
|
||||
>V2 : I1.C.E
|
||||
}
|
||||
}
|
||||
|
||||
function foo2(e: I2.C.E): void {
|
||||
>foo2 : (e: I2.C.E) => void
|
||||
>e : I2.C.E
|
||||
>I2 : unknown
|
||||
>C : unknown
|
||||
>E : I2.C.E
|
||||
|
||||
if (e === I2.C.E.V1) {
|
||||
>e === I2.C.E.V1 : boolean
|
||||
>e : I2.C.E
|
||||
>I2.C.E.V1 : I2.C.E
|
||||
>I2.C.E : typeof I2.C.E
|
||||
>I2.C : typeof I2.C
|
||||
>I2 : typeof I2
|
||||
>C : typeof I2.C
|
||||
>E : typeof I2.C.E
|
||||
>V1 : I2.C.E
|
||||
}
|
||||
else if (e === I2.C.E.V2) {
|
||||
>e === I2.C.E.V2 : boolean
|
||||
>e : I2.C.E
|
||||
>I2.C.E.V2 : I2.C.E
|
||||
>I2.C.E : typeof I2.C.E
|
||||
>I2.C : typeof I2.C
|
||||
>I2 : typeof I2
|
||||
>C : typeof I2.C
|
||||
>E : typeof I2.C.E
|
||||
>V2 : I2.C.E
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function foo(x: Enum1) {
|
||||
>foo : (x: Enum1) => void
|
||||
>x : Enum1
|
||||
>Enum1 : Enum1
|
||||
|
||||
switch (x) {
|
||||
>x : Enum1
|
||||
|
||||
case Enum1.A:
|
||||
>Enum1.A : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>A : Enum1
|
||||
|
||||
case Enum1.B:
|
||||
>Enum1.B : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>B : Enum1
|
||||
|
||||
case Enum1.C:
|
||||
>Enum1.C : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>C : Enum1
|
||||
|
||||
case Enum1.D:
|
||||
>Enum1.D : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>D : Enum1
|
||||
|
||||
case Enum1.E:
|
||||
>Enum1.E : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>E : Enum1
|
||||
|
||||
case Enum1.F:
|
||||
>Enum1.F : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>F : Enum1
|
||||
|
||||
case Enum1.G:
|
||||
>Enum1.G : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>G : Enum1
|
||||
|
||||
case Enum1.H:
|
||||
>Enum1.H : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>H : Enum1
|
||||
|
||||
case Enum1.I:
|
||||
>Enum1.I : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>I : Enum1
|
||||
|
||||
case Enum1.J:
|
||||
>Enum1.J : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>J : Enum1
|
||||
|
||||
case Enum1.K:
|
||||
>Enum1.K : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>K : Enum1
|
||||
|
||||
case Enum1.L:
|
||||
>Enum1.L : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>L : Enum1
|
||||
|
||||
case Enum1.M:
|
||||
>Enum1.M : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>M : Enum1
|
||||
|
||||
case Enum1.N:
|
||||
>Enum1.N : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>N : Enum1
|
||||
|
||||
case Enum1.O:
|
||||
>Enum1.O : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>O : Enum1
|
||||
|
||||
case Enum1.P:
|
||||
>Enum1.P : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>P : Enum1
|
||||
|
||||
case Enum1.Q:
|
||||
>Enum1.Q : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>Q : Enum1
|
||||
|
||||
case Enum1.R:
|
||||
>Enum1.R : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>R : Enum1
|
||||
|
||||
case Enum1.S:
|
||||
>Enum1.S : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>S : Enum1
|
||||
|
||||
case Enum1["T"]:
|
||||
>Enum1["T"] : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
|
||||
case Enum1.U:
|
||||
>Enum1.U : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>U : Enum1
|
||||
|
||||
case Enum1.V:
|
||||
>Enum1.V : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>V : Enum1
|
||||
|
||||
case Enum1.W:
|
||||
>Enum1.W : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>W : Enum1
|
||||
|
||||
case Enum1.W1:
|
||||
>Enum1.W1 : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>W1 : Enum1
|
||||
|
||||
case Enum1.W2:
|
||||
>Enum1.W2 : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>W2 : Enum1
|
||||
|
||||
case Enum1.W3:
|
||||
>Enum1.W3 : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>W3 : Enum1
|
||||
|
||||
case Enum1.W4:
|
||||
>Enum1.W4 : Enum1
|
||||
>Enum1 : typeof Enum1
|
||||
>W4 : Enum1
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function bar(e: A.B.C.E): number {
|
||||
>bar : (e: I) => number
|
||||
>e : I
|
||||
>A : unknown
|
||||
>B : unknown
|
||||
>C : unknown
|
||||
>E : I
|
||||
|
||||
switch (e) {
|
||||
>e : I
|
||||
|
||||
case A.B.C.E.V1: return 1;
|
||||
>A.B.C.E.V1 : I
|
||||
>A.B.C.E : typeof I
|
||||
>A.B.C : typeof A.B.C
|
||||
>A.B : typeof A.B
|
||||
>A : typeof A
|
||||
>B : typeof A.B
|
||||
>C : typeof A.B.C
|
||||
>E : typeof I
|
||||
>V1 : I
|
||||
|
||||
case A.B.C.E.V2: return 1;
|
||||
>A.B.C.E.V2 : I
|
||||
>A.B.C.E : typeof I
|
||||
>A.B.C : typeof A.B.C
|
||||
>A.B : typeof A.B
|
||||
>A : typeof A
|
||||
>B : typeof A.B
|
||||
>C : typeof A.B.C
|
||||
>E : typeof I
|
||||
>V2 : I
|
||||
|
||||
case A.B.C.E.V3: return 1;
|
||||
>A.B.C.E.V3 : I
|
||||
>A.B.C.E : typeof I
|
||||
>A.B.C : typeof A.B.C
|
||||
>A.B : typeof A.B
|
||||
>A : typeof A
|
||||
>B : typeof A.B
|
||||
>C : typeof A.B.C
|
||||
>E : typeof I
|
||||
>V3 : I
|
||||
}
|
||||
}
|
||||
@ -22,8 +22,8 @@ var ENUM1;
|
||||
})(ENUM1 || (ENUM1 = {}));
|
||||
;
|
||||
// expression
|
||||
var ResultIsNumber1 = --ENUM1["A"];
|
||||
var ResultIsNumber1 = --0 /* "A" */;
|
||||
var ResultIsNumber2 = 0 /* A */--;
|
||||
// miss assignment operator
|
||||
--ENUM1["A"];
|
||||
--0 /* "A" */;
|
||||
ENUM1[A]--;
|
||||
|
||||
@ -39,11 +39,11 @@ var ENUM1;
|
||||
var ResultIsBoolean1 = delete ENUM;
|
||||
var ResultIsBoolean2 = delete ENUM1;
|
||||
// enum type expressions
|
||||
var ResultIsBoolean3 = delete ENUM1["A"];
|
||||
var ResultIsBoolean4 = delete (ENUM[0] + ENUM1["B"]);
|
||||
var ResultIsBoolean3 = delete 0 /* "A" */;
|
||||
var ResultIsBoolean4 = delete (ENUM[0] + 1 /* "B" */);
|
||||
// multiple delete operators
|
||||
var ResultIsBoolean5 = delete delete ENUM;
|
||||
var ResultIsBoolean6 = delete delete delete (ENUM[0] + ENUM1["B"]);
|
||||
var ResultIsBoolean6 = delete delete delete (ENUM[0] + 1 /* "B" */);
|
||||
// miss assignment operators
|
||||
delete ENUM;
|
||||
delete ENUM1;
|
||||
|
||||
@ -0,0 +1,72 @@
|
||||
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(4,6): error TS2456: Type alias 'T0' circularly references itself.
|
||||
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(6,6): error TS2456: Type alias 'T0_2' circularly references itself.
|
||||
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(11,6): error TS2456: Type alias 'T1' circularly references itself.
|
||||
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(14,6): error TS2456: Type alias 'T2' circularly references itself.
|
||||
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(16,6): error TS2456: Type alias 'T2_1' circularly references itself.
|
||||
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(19,6): error TS2456: Type alias 'T3' circularly references itself.
|
||||
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(22,6): error TS2456: Type alias 'T4' circularly references itself.
|
||||
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(26,6): error TS2456: Type alias 'T5' circularly references itself.
|
||||
tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(30,6): error TS2456: Type alias 'T7' circularly references itself.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts (9 errors) ====
|
||||
// It is an error for the type specified in a type alias to depend on that type alias
|
||||
|
||||
// A type alias directly depends on the type it aliases.
|
||||
type T0 = T0
|
||||
~~
|
||||
!!! error TS2456: Type alias 'T0' circularly references itself.
|
||||
type T0_1 = T0_2
|
||||
type T0_2 = T0_3
|
||||
~~~~
|
||||
!!! error TS2456: Type alias 'T0_2' circularly references itself.
|
||||
type T0_3 = T0_1
|
||||
|
||||
// A type reference directly depends on the referenced type and each of the type arguments, if any.
|
||||
interface I<T> {}
|
||||
type T1 = I<T1>
|
||||
~~
|
||||
!!! error TS2456: Type alias 'T1' circularly references itself.
|
||||
|
||||
// A union type directly depends on each of the constituent types.
|
||||
type T2 = T2 | string
|
||||
~~
|
||||
!!! error TS2456: Type alias 'T2' circularly references itself.
|
||||
class C<T> {}
|
||||
type T2_1 = T2_1[] | number
|
||||
~~~~
|
||||
!!! error TS2456: Type alias 'T2_1' circularly references itself.
|
||||
|
||||
// An array type directly depends on its element type.
|
||||
type T3 = T3[]
|
||||
~~
|
||||
!!! error TS2456: Type alias 'T3' circularly references itself.
|
||||
|
||||
// A tuple type directly depends on each of its element types.
|
||||
type T4 = [number, T4]
|
||||
~~
|
||||
!!! error TS2456: Type alias 'T4' circularly references itself.
|
||||
|
||||
// A type query directly depends on the type of the referenced entity.
|
||||
var x: T5[] = []
|
||||
type T5 = typeof x
|
||||
~~
|
||||
!!! error TS2456: Type alias 'T5' circularly references itself.
|
||||
|
||||
class C1<T> {}
|
||||
type T6 = T7 | number
|
||||
type T7 = typeof yy
|
||||
~~
|
||||
!!! error TS2456: Type alias 'T7' circularly references itself.
|
||||
var yy: [string, T8[]];
|
||||
type T8 = C<T6>
|
||||
|
||||
// legal cases
|
||||
type T9 = () => T9
|
||||
type T10 = { x: T10 } | { new(v: T10): string }
|
||||
type T11 = T12[]
|
||||
type T12 = [T13, string]
|
||||
type T13 = typeof zz
|
||||
var zz: { x: T11 }
|
||||
|
||||
|
||||
@ -0,0 +1,60 @@
|
||||
//// [directDependenceBetweenTypeAliases.ts]
|
||||
// It is an error for the type specified in a type alias to depend on that type alias
|
||||
|
||||
// A type alias directly depends on the type it aliases.
|
||||
type T0 = T0
|
||||
type T0_1 = T0_2
|
||||
type T0_2 = T0_3
|
||||
type T0_3 = T0_1
|
||||
|
||||
// A type reference directly depends on the referenced type and each of the type arguments, if any.
|
||||
interface I<T> {}
|
||||
type T1 = I<T1>
|
||||
|
||||
// A union type directly depends on each of the constituent types.
|
||||
type T2 = T2 | string
|
||||
class C<T> {}
|
||||
type T2_1 = T2_1[] | number
|
||||
|
||||
// An array type directly depends on its element type.
|
||||
type T3 = T3[]
|
||||
|
||||
// A tuple type directly depends on each of its element types.
|
||||
type T4 = [number, T4]
|
||||
|
||||
// A type query directly depends on the type of the referenced entity.
|
||||
var x: T5[] = []
|
||||
type T5 = typeof x
|
||||
|
||||
class C1<T> {}
|
||||
type T6 = T7 | number
|
||||
type T7 = typeof yy
|
||||
var yy: [string, T8[]];
|
||||
type T8 = C<T6>
|
||||
|
||||
// legal cases
|
||||
type T9 = () => T9
|
||||
type T10 = { x: T10 } | { new(v: T10): string }
|
||||
type T11 = T12[]
|
||||
type T12 = [T13, string]
|
||||
type T13 = typeof zz
|
||||
var zz: { x: T11 }
|
||||
|
||||
|
||||
|
||||
//// [directDependenceBetweenTypeAliases.js]
|
||||
// It is an error for the type specified in a type alias to depend on that type alias
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
// A type query directly depends on the type of the referenced entity.
|
||||
var x = [];
|
||||
var C1 = (function () {
|
||||
function C1() {
|
||||
}
|
||||
return C1;
|
||||
})();
|
||||
var yy;
|
||||
var zz;
|
||||
@ -22,8 +22,8 @@ var ENUM1;
|
||||
})(ENUM1 || (ENUM1 = {}));
|
||||
;
|
||||
// expression
|
||||
var ResultIsNumber1 = ++ENUM1["B"];
|
||||
var ResultIsNumber1 = ++1 /* "B" */;
|
||||
var ResultIsNumber2 = 1 /* B */++;
|
||||
// miss assignment operator
|
||||
++ENUM1["B"];
|
||||
++1 /* "B" */;
|
||||
1 /* B */++;
|
||||
|
||||
@ -37,11 +37,11 @@ var ENUM1;
|
||||
// enum type var
|
||||
var ResultIsBoolean1 = !ENUM;
|
||||
// enum type expressions
|
||||
var ResultIsBoolean2 = !ENUM["B"];
|
||||
var ResultIsBoolean3 = !(1 /* B */ + ENUM["C"]);
|
||||
var ResultIsBoolean2 = !1 /* "B" */;
|
||||
var ResultIsBoolean3 = !(1 /* B */ + 2 /* "C" */);
|
||||
// multiple ! operators
|
||||
var ResultIsBoolean4 = !!ENUM;
|
||||
var ResultIsBoolean5 = !!!(ENUM["B"] + 2 /* C */);
|
||||
var ResultIsBoolean5 = !!!(1 /* "B" */ + 2 /* C */);
|
||||
// miss assignment operators
|
||||
!ENUM;
|
||||
!ENUM1;
|
||||
|
||||
@ -33,10 +33,10 @@ var ENUM1;
|
||||
// enum type var
|
||||
var ResultIsNumber1 = -ENUM;
|
||||
// expressions
|
||||
var ResultIsNumber2 = -ENUM1["B"];
|
||||
var ResultIsNumber3 = -(1 /* B */ + ENUM1[""]);
|
||||
var ResultIsNumber2 = -1 /* "B" */;
|
||||
var ResultIsNumber3 = -(1 /* B */ + 2 /* "" */);
|
||||
// miss assignment operators
|
||||
-ENUM;
|
||||
-ENUM1;
|
||||
-ENUM1["B"];
|
||||
-1 /* "B" */;
|
||||
-ENUM, ENUM1;
|
||||
|
||||
@ -61,7 +61,7 @@ var strRepresentation2 = MyEmusEnum[0 /* emu */];
|
||||
// Should be implicit 'any' ; property access fails, no string indexer.
|
||||
var strRepresentation3 = MyEmusEnum["monehh"];
|
||||
// Should be okay; should be a MyEmusEnum
|
||||
var strRepresentation4 = MyEmusEnum["emu"];
|
||||
var strRepresentation4 = 0 /* "emu" */;
|
||||
// Should report an implicit 'any'.
|
||||
var x = {}["hi"];
|
||||
// Should report an implicit 'any'.
|
||||
|
||||
@ -35,8 +35,8 @@ var ENUM1;
|
||||
var ResultIsNumber1 = +ENUM;
|
||||
var ResultIsNumber2 = +ENUM1;
|
||||
// enum type expressions
|
||||
var ResultIsNumber3 = +ENUM1["A"];
|
||||
var ResultIsNumber4 = +(ENUM[0] + ENUM1["B"]);
|
||||
var ResultIsNumber3 = +0 /* "A" */;
|
||||
var ResultIsNumber4 = +(ENUM[0] + 1 /* "B" */);
|
||||
// miss assignment operators
|
||||
+ENUM;
|
||||
+ENUM1;
|
||||
|
||||
11
tests/baselines/reference/preserveConstEnums.js
Normal file
11
tests/baselines/reference/preserveConstEnums.js
Normal file
@ -0,0 +1,11 @@
|
||||
//// [preserveConstEnums.ts]
|
||||
const enum E {
|
||||
Value = 1, Value2 = Value
|
||||
}
|
||||
|
||||
//// [preserveConstEnums.js]
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["Value"] = 1] = "Value";
|
||||
E[E["Value2"] = 1] = "Value2";
|
||||
})(E || (E = {}));
|
||||
9
tests/baselines/reference/preserveConstEnums.types
Normal file
9
tests/baselines/reference/preserveConstEnums.types
Normal file
@ -0,0 +1,9 @@
|
||||
=== tests/cases/compiler/preserveConstEnums.ts ===
|
||||
const enum E {
|
||||
>E : E
|
||||
|
||||
Value = 1, Value2 = Value
|
||||
>Value : E
|
||||
>Value2 : E
|
||||
>Value : E
|
||||
}
|
||||
30
tests/baselines/reference/reservedNamesInAliases.errors.txt
Normal file
30
tests/baselines/reference/reservedNamesInAliases.errors.txt
Normal file
@ -0,0 +1,30 @@
|
||||
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,6): error TS1003: Identifier expected.
|
||||
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,11): error TS1005: ';' expected.
|
||||
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(2,6): error TS2457: Type alias name cannot be 'any'
|
||||
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(3,6): error TS2457: Type alias name cannot be 'number'
|
||||
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(4,6): error TS2457: Type alias name cannot be 'boolean'
|
||||
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(5,6): error TS2457: Type alias name cannot be 'string'
|
||||
tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error TS2304: Cannot find name 'I'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts (7 errors) ====
|
||||
interface I {}
|
||||
type any = I;
|
||||
~~~
|
||||
!!! error TS2457: Type alias name cannot be 'any'
|
||||
type number = I;
|
||||
~~~~~~
|
||||
!!! error TS2457: Type alias name cannot be 'number'
|
||||
type boolean = I;
|
||||
~~~~~~~
|
||||
!!! error TS2457: Type alias name cannot be 'boolean'
|
||||
type string = I;
|
||||
~~~~~~
|
||||
!!! error TS2457: Type alias name cannot be 'string'
|
||||
type void = I;
|
||||
~~~~
|
||||
!!! error TS1003: Identifier expected.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
~
|
||||
!!! error TS2304: Cannot find name 'I'.
|
||||
@ -136,22 +136,19 @@ function f() {
|
||||
z = 10;
|
||||
}
|
||||
switch (obj.z) {
|
||||
case 0:
|
||||
{
|
||||
x++;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
x--;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
x *= 2;
|
||||
x = 50;
|
||||
break;
|
||||
}
|
||||
case 0: {
|
||||
x++;
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
x--;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
x *= 2;
|
||||
x = 50;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (x < 10) {
|
||||
x++;
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
//// [sourceMapValidationStatements.js.map]
|
||||
{"version":3,"file":"sourceMapValidationStatements.js","sourceRoot":"","sources":["sourceMapValidationStatements.ts"],"names":["f"],"mappings":"AAAA,SAAS,CAAC;IACNA,IAAIA,CAACA,CAACA;IACNA,IAAIA,CAACA,GAAGA,CAACA,CAACA;IACVA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,EAAEA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;QAC1BA,CAACA,IAAIA,CAACA,CAACA;QACPA,CAACA,IAAIA,CAACA,CAACA;IACXA,CAACA;IACDA,EAAEA,CAACA,CAACA,CAACA,GAAGA,EAAEA,CAACA,CAACA,CAACA;QACTA,CAACA,IAAIA,CAACA,CAACA;IACXA,CAACA;IAACA,IAAIA,CAACA,CAACA;QACJA,CAACA,IAAIA,EAAEA,CAACA;QACRA,CAACA,EAAEA,CAACA;IACRA,CAACA;IACDA,IAAIA,CAACA,GAAGA;QACJA,CAACA;QACDA,CAACA;QACDA,CAACA;KACJA,CAACA;IACFA,IAAIA,GAAGA,GAAGA;QACNA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,OAAOA;KACbA,CAACA;IACFA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA;QACdA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA;QACbA,IAAIA,CAACA,GAAGA,EAAEA,CAACA;IACfA,CAACA;IACDA,IAAAA,CAACA;QACGA,GAAGA,CAACA,CAACA,GAAGA,MAAMA,CAACA;IACnBA,CAAEA;IAAAA,KAAKA,CAACA,CAACA,CAACA,CAACA,CAATA,CAACA;QACCA,EAAEA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,EAAEA,CAACA,CAACA,CAACA;YACbA,GAAGA,CAACA,CAACA,GAAGA,EAAEA,CAACA;QACfA,CAACA;QAACA,IAAIA,CAACA,CAACA;YACJA,GAAGA,CAACA,CAACA,GAAGA,KAAKA,CAACA;QAClBA,CAACA;IACLA,CAACA;IACDA,IAAAA,CAACA;QACGA,MAAMA,IAAIA,KAAKA,EAAEA,CAACA;IACtBA,CAAEA;IAAAA,KAAKA,CAACA,CAACA,EAAEA,CAACA,CAAVA,CAACA;QACCA,IAAIA,CAACA,GAAGA,EAAEA,CAACA;IACfA,CAACA;YAACA,CAACA;QACCA,CAACA,GAAGA,EAAEA,CAACA;IACXA,CAACA;IACDA,MAAMA,GAAGA,EAAEA,CAACA;QACRA,CAACA,GAAGA,CAACA,CAACA;QACNA,CAACA,GAAGA,EAAEA,CAACA;IACXA,CAACA;IACDA,MAAMA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA;QACZA,KAAKA,CAACA;YAAEA,CAACA;gBACLA,CAACA,EAAEA,CAACA;gBACJA,KAAKA,CAACA;YAEVA,CAACA;QACDA,KAAKA,CAACA;YAAEA,CAACA;gBACLA,CAACA,EAAEA,CAACA;gBACJA,KAAKA,CAACA;YAEVA,CAACA;QACDA;YAASA,CAACA;gBACNA,CAACA,IAAIA,CAACA,CAACA;gBACPA,CAACA,GAAGA,EAAEA,CAACA;gBACPA,KAAKA,CAACA;YAEVA,CAACA;IACLA,CAACA;IACDA,OAAOA,CAACA,GAAGA,EAAEA,EAAEA,CAACA;QACZA,CAACA,EAAEA,CAACA;IACRA,CAACA;IACDA,GAAGA,CAACA;QACAA,CAACA,EAAEA,CAACA;IACRA,CAACA,QAAQA,CAACA,GAAGA,CAACA,EAACA;IACfA,CAACA,GAAGA,CAACA,CAACA;IACNA,IAAIA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,CAACA;IACjCA,CAACA,CAACA,IAAIA,CAACA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,CAACA;IACzBA,CAACA,KAAKA,CAACA,CAACA;IACRA,CAACA,GAAGA,CAACA,GAAGA,EAAEA,CAACA;IACXA,IAAIA,CAACA,GAAGA,CAACA,CAACA;IACVA,MAAMA,CAACA;AACXA,CAACA;AACD,IAAI,CAAC,GAAG;IACJ,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAC,CAAC;AACF,CAAC,EAAE,CAAC"}
|
||||
{"version":3,"file":"sourceMapValidationStatements.js","sourceRoot":"","sources":["sourceMapValidationStatements.ts"],"names":["f"],"mappings":"AAAA,SAAS,CAAC;IACNA,IAAIA,CAACA,CAACA;IACNA,IAAIA,CAACA,GAAGA,CAACA,CAACA;IACVA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,EAAEA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;QAC1BA,CAACA,IAAIA,CAACA,CAACA;QACPA,CAACA,IAAIA,CAACA,CAACA;IACXA,CAACA;IACDA,EAAEA,CAACA,CAACA,CAACA,GAAGA,EAAEA,CAACA,CAACA,CAACA;QACTA,CAACA,IAAIA,CAACA,CAACA;IACXA,CAACA;IAACA,IAAIA,CAACA,CAACA;QACJA,CAACA,IAAIA,EAAEA,CAACA;QACRA,CAACA,EAAEA,CAACA;IACRA,CAACA;IACDA,IAAIA,CAACA,GAAGA;QACJA,CAACA;QACDA,CAACA;QACDA,CAACA;KACJA,CAACA;IACFA,IAAIA,GAAGA,GAAGA;QACNA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,OAAOA;KACbA,CAACA;IACFA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA;QACdA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA;QACbA,IAAIA,CAACA,GAAGA,EAAEA,CAACA;IACfA,CAACA;IACDA,IAAAA,CAACA;QACGA,GAAGA,CAACA,CAACA,GAAGA,MAAMA,CAACA;IACnBA,CAAEA;IAAAA,KAAKA,CAACA,CAACA,CAACA,CAACA,CAATA,CAACA;QACCA,EAAEA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,EAAEA,CAACA,CAACA,CAACA;YACbA,GAAGA,CAACA,CAACA,GAAGA,EAAEA,CAACA;QACfA,CAACA;QAACA,IAAIA,CAACA,CAACA;YACJA,GAAGA,CAACA,CAACA,GAAGA,KAAKA,CAACA;QAClBA,CAACA;IACLA,CAACA;IACDA,IAAAA,CAACA;QACGA,MAAMA,IAAIA,KAAKA,EAAEA,CAACA;IACtBA,CAAEA;IAAAA,KAAKA,CAACA,CAACA,EAAEA,CAACA,CAAVA,CAACA;QACCA,IAAIA,CAACA,GAAGA,EAAEA,CAACA;IACfA,CAACA;YAACA,CAACA;QACCA,CAACA,GAAGA,EAAEA,CAACA;IACXA,CAACA;IACDA,MAAMA,GAAGA,EAAEA,CAACA;QACRA,CAACA,GAAGA,CAACA,CAACA;QACNA,CAACA,GAAGA,EAAEA,CAACA;IACXA,CAACA;IACDA,MAAMA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA;QACZA,KAAKA,CAACA,EAAEA,CAACA;YACLA,CAACA,EAAEA,CAACA;YACJA,KAAKA,CAACA;QAEVA,CAACA;QACDA,KAAKA,CAACA,EAAEA,CAACA;YACLA,CAACA,EAAEA,CAACA;YACJA,KAAKA,CAACA;QAEVA,CAACA;QACDA,SAASA,CAACA;YACNA,CAACA,IAAIA,CAACA,CAACA;YACPA,CAACA,GAAGA,EAAEA,CAACA;YACPA,KAAKA,CAACA;QAEVA,CAACA;IACLA,CAACA;IACDA,OAAOA,CAACA,GAAGA,EAAEA,EAAEA,CAACA;QACZA,CAACA,EAAEA,CAACA;IACRA,CAACA;IACDA,GAAGA,CAACA;QACAA,CAACA,EAAEA,CAACA;IACRA,CAACA,QAAQA,CAACA,GAAGA,CAACA,EAACA;IACfA,CAACA,GAAGA,CAACA,CAACA;IACNA,IAAIA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,CAACA;IACjCA,CAACA,CAACA,IAAIA,CAACA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,CAACA;IACzBA,CAACA,KAAKA,CAACA,CAACA;IACRA,CAACA,GAAGA,CAACA,GAAGA,EAAEA,CAACA;IACXA,IAAIA,CAACA,GAAGA,CAACA,CAACA;IACVA,MAAMA,CAACA;AACXA,CAACA;AACD,IAAI,CAAC,GAAG;IACJ,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAC,CAAC;AACF,CAAC,EAAE,CAAC"}
|
||||
@ -936,200 +936,191 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
9 >Emitted(52, 20) Source(47, 20) + SourceIndex(0) name (f)
|
||||
10>Emitted(52, 21) Source(47, 21) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> case 0:
|
||||
>>> case 0: {
|
||||
1 >^^^^^^^^
|
||||
2 > ^^^^^
|
||||
3 > ^
|
||||
4 > ^^
|
||||
5 > ^
|
||||
1 >
|
||||
>
|
||||
2 > case
|
||||
3 > 0
|
||||
4 > :
|
||||
5 > {
|
||||
1 >Emitted(53, 9) Source(48, 9) + SourceIndex(0) name (f)
|
||||
2 >Emitted(53, 14) Source(48, 14) + SourceIndex(0) name (f)
|
||||
3 >Emitted(53, 15) Source(48, 15) + SourceIndex(0) name (f)
|
||||
4 >Emitted(53, 17) Source(48, 17) + SourceIndex(0) name (f)
|
||||
5 >Emitted(53, 18) Source(48, 18) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> {
|
||||
>>> x++;
|
||||
1 >^^^^^^^^^^^^
|
||||
2 > ^
|
||||
3 > ^^^^^^^^->
|
||||
1 >:
|
||||
2 > {
|
||||
1 >Emitted(54, 13) Source(48, 17) + SourceIndex(0) name (f)
|
||||
2 >Emitted(54, 14) Source(48, 18) + SourceIndex(0) name (f)
|
||||
3 > ^^
|
||||
4 > ^
|
||||
5 > ^^^->
|
||||
1 >
|
||||
>
|
||||
2 > x
|
||||
3 > ++
|
||||
4 > ;
|
||||
1 >Emitted(54, 13) Source(49, 13) + SourceIndex(0) name (f)
|
||||
2 >Emitted(54, 14) Source(49, 14) + SourceIndex(0) name (f)
|
||||
3 >Emitted(54, 16) Source(49, 16) + SourceIndex(0) name (f)
|
||||
4 >Emitted(54, 17) Source(49, 17) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> x++;
|
||||
1->^^^^^^^^^^^^^^^^
|
||||
2 > ^
|
||||
3 > ^^
|
||||
4 > ^
|
||||
5 > ^^^->
|
||||
>>> break;
|
||||
1->^^^^^^^^^^^^
|
||||
2 > ^^^^^
|
||||
3 > ^
|
||||
1->
|
||||
>
|
||||
2 > x
|
||||
3 > ++
|
||||
4 > ;
|
||||
1->Emitted(55, 17) Source(49, 13) + SourceIndex(0) name (f)
|
||||
2 >Emitted(55, 18) Source(49, 14) + SourceIndex(0) name (f)
|
||||
3 >Emitted(55, 20) Source(49, 16) + SourceIndex(0) name (f)
|
||||
4 >Emitted(55, 21) Source(49, 17) + SourceIndex(0) name (f)
|
||||
2 > break
|
||||
3 > ;
|
||||
1->Emitted(55, 13) Source(50, 13) + SourceIndex(0) name (f)
|
||||
2 >Emitted(55, 18) Source(50, 18) + SourceIndex(0) name (f)
|
||||
3 >Emitted(55, 19) Source(50, 19) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> break;
|
||||
1->^^^^^^^^^^^^^^^^
|
||||
2 > ^^^^^
|
||||
3 > ^
|
||||
1->
|
||||
>
|
||||
2 > break
|
||||
3 > ;
|
||||
1->Emitted(56, 17) Source(50, 13) + SourceIndex(0) name (f)
|
||||
2 >Emitted(56, 22) Source(50, 18) + SourceIndex(0) name (f)
|
||||
3 >Emitted(56, 23) Source(50, 19) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^^^^^^^^^
|
||||
2 > ^
|
||||
3 > ^^^->
|
||||
>>> }
|
||||
1 >^^^^^^^^
|
||||
2 > ^
|
||||
3 > ^^^^^^^^^->
|
||||
1 >
|
||||
>
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(57, 13) Source(52, 9) + SourceIndex(0) name (f)
|
||||
2 >Emitted(57, 14) Source(52, 10) + SourceIndex(0) name (f)
|
||||
2 > }
|
||||
1 >Emitted(56, 9) Source(52, 9) + SourceIndex(0) name (f)
|
||||
2 >Emitted(56, 10) Source(52, 10) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> case 1:
|
||||
>>> case 1: {
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^
|
||||
3 > ^
|
||||
4 > ^^
|
||||
5 > ^
|
||||
1->
|
||||
>
|
||||
2 > case
|
||||
3 > 1
|
||||
1->Emitted(58, 9) Source(53, 9) + SourceIndex(0) name (f)
|
||||
2 >Emitted(58, 14) Source(53, 14) + SourceIndex(0) name (f)
|
||||
3 >Emitted(58, 15) Source(53, 15) + SourceIndex(0) name (f)
|
||||
4 > :
|
||||
5 > {
|
||||
1->Emitted(57, 9) Source(53, 9) + SourceIndex(0) name (f)
|
||||
2 >Emitted(57, 14) Source(53, 14) + SourceIndex(0) name (f)
|
||||
3 >Emitted(57, 15) Source(53, 15) + SourceIndex(0) name (f)
|
||||
4 >Emitted(57, 17) Source(53, 17) + SourceIndex(0) name (f)
|
||||
5 >Emitted(57, 18) Source(53, 18) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> {
|
||||
>>> x--;
|
||||
1 >^^^^^^^^^^^^
|
||||
2 > ^
|
||||
3 > ^^^^^^^^->
|
||||
1 >:
|
||||
2 > {
|
||||
1 >Emitted(59, 13) Source(53, 17) + SourceIndex(0) name (f)
|
||||
2 >Emitted(59, 14) Source(53, 18) + SourceIndex(0) name (f)
|
||||
3 > ^^
|
||||
4 > ^
|
||||
5 > ^^^->
|
||||
1 >
|
||||
>
|
||||
2 > x
|
||||
3 > --
|
||||
4 > ;
|
||||
1 >Emitted(58, 13) Source(54, 13) + SourceIndex(0) name (f)
|
||||
2 >Emitted(58, 14) Source(54, 14) + SourceIndex(0) name (f)
|
||||
3 >Emitted(58, 16) Source(54, 16) + SourceIndex(0) name (f)
|
||||
4 >Emitted(58, 17) Source(54, 17) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> x--;
|
||||
1->^^^^^^^^^^^^^^^^
|
||||
2 > ^
|
||||
3 > ^^
|
||||
4 > ^
|
||||
5 > ^^^->
|
||||
>>> break;
|
||||
1->^^^^^^^^^^^^
|
||||
2 > ^^^^^
|
||||
3 > ^
|
||||
1->
|
||||
>
|
||||
2 > x
|
||||
3 > --
|
||||
4 > ;
|
||||
1->Emitted(60, 17) Source(54, 13) + SourceIndex(0) name (f)
|
||||
2 >Emitted(60, 18) Source(54, 14) + SourceIndex(0) name (f)
|
||||
3 >Emitted(60, 20) Source(54, 16) + SourceIndex(0) name (f)
|
||||
4 >Emitted(60, 21) Source(54, 17) + SourceIndex(0) name (f)
|
||||
2 > break
|
||||
3 > ;
|
||||
1->Emitted(59, 13) Source(55, 13) + SourceIndex(0) name (f)
|
||||
2 >Emitted(59, 18) Source(55, 18) + SourceIndex(0) name (f)
|
||||
3 >Emitted(59, 19) Source(55, 19) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> break;
|
||||
1->^^^^^^^^^^^^^^^^
|
||||
2 > ^^^^^
|
||||
3 > ^
|
||||
1->
|
||||
>
|
||||
2 > break
|
||||
3 > ;
|
||||
1->Emitted(61, 17) Source(55, 13) + SourceIndex(0) name (f)
|
||||
2 >Emitted(61, 22) Source(55, 18) + SourceIndex(0) name (f)
|
||||
3 >Emitted(61, 23) Source(55, 19) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^^^^^^^^^
|
||||
2 > ^
|
||||
3 > ^^^^->
|
||||
>>> }
|
||||
1 >^^^^^^^^
|
||||
2 > ^
|
||||
3 > ^^^^^^^^^^->
|
||||
1 >
|
||||
>
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(62, 13) Source(57, 9) + SourceIndex(0) name (f)
|
||||
2 >Emitted(62, 14) Source(57, 10) + SourceIndex(0) name (f)
|
||||
2 > }
|
||||
1 >Emitted(60, 9) Source(57, 9) + SourceIndex(0) name (f)
|
||||
2 >Emitted(60, 10) Source(57, 10) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> default:
|
||||
>>> default: {
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^^->
|
||||
2 > ^^^^^^^^^
|
||||
3 > ^
|
||||
4 > ^^->
|
||||
1->
|
||||
>
|
||||
1->Emitted(63, 9) Source(58, 9) + SourceIndex(0) name (f)
|
||||
2 > default:
|
||||
3 > {
|
||||
1->Emitted(61, 9) Source(58, 9) + SourceIndex(0) name (f)
|
||||
2 >Emitted(61, 18) Source(58, 18) + SourceIndex(0) name (f)
|
||||
3 >Emitted(61, 19) Source(58, 19) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> {
|
||||
>>> x *= 2;
|
||||
1->^^^^^^^^^^^^
|
||||
2 > ^
|
||||
3 > ^^^^^^^^^^^->
|
||||
1->default:
|
||||
2 > {
|
||||
1->Emitted(64, 13) Source(58, 18) + SourceIndex(0) name (f)
|
||||
2 >Emitted(64, 14) Source(58, 19) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> x *= 2;
|
||||
1->^^^^^^^^^^^^^^^^
|
||||
2 > ^
|
||||
3 > ^^^^
|
||||
4 > ^
|
||||
5 > ^
|
||||
6 > ^->
|
||||
3 > ^^^^
|
||||
4 > ^
|
||||
5 > ^
|
||||
6 > ^->
|
||||
1->
|
||||
>
|
||||
2 > x
|
||||
3 > *=
|
||||
4 > 2
|
||||
5 > ;
|
||||
1->Emitted(65, 17) Source(59, 13) + SourceIndex(0) name (f)
|
||||
2 >Emitted(65, 18) Source(59, 14) + SourceIndex(0) name (f)
|
||||
3 >Emitted(65, 22) Source(59, 18) + SourceIndex(0) name (f)
|
||||
4 >Emitted(65, 23) Source(59, 19) + SourceIndex(0) name (f)
|
||||
5 >Emitted(65, 24) Source(59, 20) + SourceIndex(0) name (f)
|
||||
2 > x
|
||||
3 > *=
|
||||
4 > 2
|
||||
5 > ;
|
||||
1->Emitted(62, 13) Source(59, 13) + SourceIndex(0) name (f)
|
||||
2 >Emitted(62, 14) Source(59, 14) + SourceIndex(0) name (f)
|
||||
3 >Emitted(62, 18) Source(59, 18) + SourceIndex(0) name (f)
|
||||
4 >Emitted(62, 19) Source(59, 19) + SourceIndex(0) name (f)
|
||||
5 >Emitted(62, 20) Source(59, 20) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> x = 50;
|
||||
1->^^^^^^^^^^^^^^^^
|
||||
2 > ^
|
||||
3 > ^^^
|
||||
4 > ^^
|
||||
5 > ^
|
||||
>>> x = 50;
|
||||
1->^^^^^^^^^^^^
|
||||
2 > ^
|
||||
3 > ^^^
|
||||
4 > ^^
|
||||
5 > ^
|
||||
1->
|
||||
>
|
||||
2 > x
|
||||
3 > =
|
||||
4 > 50
|
||||
5 > ;
|
||||
1->Emitted(66, 17) Source(60, 13) + SourceIndex(0) name (f)
|
||||
2 >Emitted(66, 18) Source(60, 14) + SourceIndex(0) name (f)
|
||||
3 >Emitted(66, 21) Source(60, 17) + SourceIndex(0) name (f)
|
||||
4 >Emitted(66, 23) Source(60, 19) + SourceIndex(0) name (f)
|
||||
5 >Emitted(66, 24) Source(60, 20) + SourceIndex(0) name (f)
|
||||
2 > x
|
||||
3 > =
|
||||
4 > 50
|
||||
5 > ;
|
||||
1->Emitted(63, 13) Source(60, 13) + SourceIndex(0) name (f)
|
||||
2 >Emitted(63, 14) Source(60, 14) + SourceIndex(0) name (f)
|
||||
3 >Emitted(63, 17) Source(60, 17) + SourceIndex(0) name (f)
|
||||
4 >Emitted(63, 19) Source(60, 19) + SourceIndex(0) name (f)
|
||||
5 >Emitted(63, 20) Source(60, 20) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> break;
|
||||
1 >^^^^^^^^^^^^^^^^
|
||||
2 > ^^^^^
|
||||
3 > ^
|
||||
>>> break;
|
||||
1 >^^^^^^^^^^^^
|
||||
2 > ^^^^^
|
||||
3 > ^
|
||||
1 >
|
||||
>
|
||||
2 > break
|
||||
3 > ;
|
||||
1 >Emitted(67, 17) Source(61, 13) + SourceIndex(0) name (f)
|
||||
2 >Emitted(67, 22) Source(61, 18) + SourceIndex(0) name (f)
|
||||
3 >Emitted(67, 23) Source(61, 19) + SourceIndex(0) name (f)
|
||||
2 > break
|
||||
3 > ;
|
||||
1 >Emitted(64, 13) Source(61, 13) + SourceIndex(0) name (f)
|
||||
2 >Emitted(64, 18) Source(61, 18) + SourceIndex(0) name (f)
|
||||
3 >Emitted(64, 19) Source(61, 19) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^^^^^^^^^
|
||||
2 > ^
|
||||
>>> }
|
||||
1 >^^^^^^^^
|
||||
2 > ^
|
||||
1 >
|
||||
>
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(68, 13) Source(63, 9) + SourceIndex(0) name (f)
|
||||
2 >Emitted(68, 14) Source(63, 10) + SourceIndex(0) name (f)
|
||||
2 > }
|
||||
1 >Emitted(65, 9) Source(63, 9) + SourceIndex(0) name (f)
|
||||
2 >Emitted(65, 10) Source(63, 10) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^
|
||||
@ -1138,8 +1129,8 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(69, 5) Source(64, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(69, 6) Source(64, 6) + SourceIndex(0) name (f)
|
||||
1 >Emitted(66, 5) Source(64, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(66, 6) Source(64, 6) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> while (x < 10) {
|
||||
1->^^^^
|
||||
@ -1157,13 +1148,13 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
5 > 10
|
||||
6 > )
|
||||
7 > {
|
||||
1->Emitted(70, 5) Source(65, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(70, 12) Source(65, 12) + SourceIndex(0) name (f)
|
||||
3 >Emitted(70, 13) Source(65, 13) + SourceIndex(0) name (f)
|
||||
4 >Emitted(70, 16) Source(65, 16) + SourceIndex(0) name (f)
|
||||
5 >Emitted(70, 18) Source(65, 18) + SourceIndex(0) name (f)
|
||||
6 >Emitted(70, 20) Source(65, 20) + SourceIndex(0) name (f)
|
||||
7 >Emitted(70, 21) Source(65, 21) + SourceIndex(0) name (f)
|
||||
1->Emitted(67, 5) Source(65, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(67, 12) Source(65, 12) + SourceIndex(0) name (f)
|
||||
3 >Emitted(67, 13) Source(65, 13) + SourceIndex(0) name (f)
|
||||
4 >Emitted(67, 16) Source(65, 16) + SourceIndex(0) name (f)
|
||||
5 >Emitted(67, 18) Source(65, 18) + SourceIndex(0) name (f)
|
||||
6 >Emitted(67, 20) Source(65, 20) + SourceIndex(0) name (f)
|
||||
7 >Emitted(67, 21) Source(65, 21) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> x++;
|
||||
1 >^^^^^^^^
|
||||
@ -1175,10 +1166,10 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
2 > x
|
||||
3 > ++
|
||||
4 > ;
|
||||
1 >Emitted(71, 9) Source(66, 9) + SourceIndex(0) name (f)
|
||||
2 >Emitted(71, 10) Source(66, 10) + SourceIndex(0) name (f)
|
||||
3 >Emitted(71, 12) Source(66, 12) + SourceIndex(0) name (f)
|
||||
4 >Emitted(71, 13) Source(66, 13) + SourceIndex(0) name (f)
|
||||
1 >Emitted(68, 9) Source(66, 9) + SourceIndex(0) name (f)
|
||||
2 >Emitted(68, 10) Source(66, 10) + SourceIndex(0) name (f)
|
||||
3 >Emitted(68, 12) Source(66, 12) + SourceIndex(0) name (f)
|
||||
4 >Emitted(68, 13) Source(66, 13) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> }
|
||||
1 >^^^^
|
||||
@ -1187,8 +1178,8 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(72, 5) Source(67, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(72, 6) Source(67, 6) + SourceIndex(0) name (f)
|
||||
1 >Emitted(69, 5) Source(67, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(69, 6) Source(67, 6) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> do {
|
||||
1->^^^^
|
||||
@ -1199,9 +1190,9 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
>
|
||||
2 > do
|
||||
3 > {
|
||||
1->Emitted(73, 5) Source(68, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(73, 8) Source(68, 8) + SourceIndex(0) name (f)
|
||||
3 >Emitted(73, 9) Source(68, 9) + SourceIndex(0) name (f)
|
||||
1->Emitted(70, 5) Source(68, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(70, 8) Source(68, 8) + SourceIndex(0) name (f)
|
||||
3 >Emitted(70, 9) Source(68, 9) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> x--;
|
||||
1->^^^^^^^^
|
||||
@ -1214,10 +1205,10 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
2 > x
|
||||
3 > --
|
||||
4 > ;
|
||||
1->Emitted(74, 9) Source(69, 9) + SourceIndex(0) name (f)
|
||||
2 >Emitted(74, 10) Source(69, 10) + SourceIndex(0) name (f)
|
||||
3 >Emitted(74, 12) Source(69, 12) + SourceIndex(0) name (f)
|
||||
4 >Emitted(74, 13) Source(69, 13) + SourceIndex(0) name (f)
|
||||
1->Emitted(71, 9) Source(69, 9) + SourceIndex(0) name (f)
|
||||
2 >Emitted(71, 10) Source(69, 10) + SourceIndex(0) name (f)
|
||||
3 >Emitted(71, 12) Source(69, 12) + SourceIndex(0) name (f)
|
||||
4 >Emitted(71, 13) Source(69, 13) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> } while (x > 4);
|
||||
1->^^^^
|
||||
@ -1235,13 +1226,13 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
5 > >
|
||||
6 > 4
|
||||
7 > )
|
||||
1->Emitted(75, 5) Source(70, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(75, 6) Source(70, 6) + SourceIndex(0) name (f)
|
||||
3 >Emitted(75, 14) Source(70, 14) + SourceIndex(0) name (f)
|
||||
4 >Emitted(75, 15) Source(70, 15) + SourceIndex(0) name (f)
|
||||
5 >Emitted(75, 18) Source(70, 18) + SourceIndex(0) name (f)
|
||||
6 >Emitted(75, 19) Source(70, 19) + SourceIndex(0) name (f)
|
||||
7 >Emitted(75, 21) Source(70, 20) + SourceIndex(0) name (f)
|
||||
1->Emitted(72, 5) Source(70, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(72, 6) Source(70, 6) + SourceIndex(0) name (f)
|
||||
3 >Emitted(72, 14) Source(70, 14) + SourceIndex(0) name (f)
|
||||
4 >Emitted(72, 15) Source(70, 15) + SourceIndex(0) name (f)
|
||||
5 >Emitted(72, 18) Source(70, 18) + SourceIndex(0) name (f)
|
||||
6 >Emitted(72, 19) Source(70, 19) + SourceIndex(0) name (f)
|
||||
7 >Emitted(72, 21) Source(70, 20) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> x = y;
|
||||
1 >^^^^
|
||||
@ -1256,11 +1247,11 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
3 > =
|
||||
4 > y
|
||||
5 > ;
|
||||
1 >Emitted(76, 5) Source(71, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(76, 6) Source(71, 6) + SourceIndex(0) name (f)
|
||||
3 >Emitted(76, 9) Source(71, 9) + SourceIndex(0) name (f)
|
||||
4 >Emitted(76, 10) Source(71, 10) + SourceIndex(0) name (f)
|
||||
5 >Emitted(76, 11) Source(71, 11) + SourceIndex(0) name (f)
|
||||
1 >Emitted(73, 5) Source(71, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(73, 6) Source(71, 6) + SourceIndex(0) name (f)
|
||||
3 >Emitted(73, 9) Source(71, 9) + SourceIndex(0) name (f)
|
||||
4 >Emitted(73, 10) Source(71, 10) + SourceIndex(0) name (f)
|
||||
5 >Emitted(73, 11) Source(71, 11) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> var z = (x == 1) ? x + 1 : x - 1;
|
||||
1->^^^^
|
||||
@ -1300,24 +1291,24 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
16> -
|
||||
17> 1
|
||||
18> ;
|
||||
1->Emitted(77, 5) Source(72, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(77, 9) Source(72, 9) + SourceIndex(0) name (f)
|
||||
3 >Emitted(77, 10) Source(72, 10) + SourceIndex(0) name (f)
|
||||
4 >Emitted(77, 13) Source(72, 13) + SourceIndex(0) name (f)
|
||||
5 >Emitted(77, 14) Source(72, 14) + SourceIndex(0) name (f)
|
||||
6 >Emitted(77, 15) Source(72, 15) + SourceIndex(0) name (f)
|
||||
7 >Emitted(77, 19) Source(72, 19) + SourceIndex(0) name (f)
|
||||
8 >Emitted(77, 20) Source(72, 20) + SourceIndex(0) name (f)
|
||||
9 >Emitted(77, 21) Source(72, 21) + SourceIndex(0) name (f)
|
||||
10>Emitted(77, 24) Source(72, 24) + SourceIndex(0) name (f)
|
||||
11>Emitted(77, 25) Source(72, 25) + SourceIndex(0) name (f)
|
||||
12>Emitted(77, 28) Source(72, 28) + SourceIndex(0) name (f)
|
||||
13>Emitted(77, 29) Source(72, 29) + SourceIndex(0) name (f)
|
||||
14>Emitted(77, 32) Source(72, 32) + SourceIndex(0) name (f)
|
||||
15>Emitted(77, 33) Source(72, 33) + SourceIndex(0) name (f)
|
||||
16>Emitted(77, 36) Source(72, 36) + SourceIndex(0) name (f)
|
||||
17>Emitted(77, 37) Source(72, 37) + SourceIndex(0) name (f)
|
||||
18>Emitted(77, 38) Source(72, 38) + SourceIndex(0) name (f)
|
||||
1->Emitted(74, 5) Source(72, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(74, 9) Source(72, 9) + SourceIndex(0) name (f)
|
||||
3 >Emitted(74, 10) Source(72, 10) + SourceIndex(0) name (f)
|
||||
4 >Emitted(74, 13) Source(72, 13) + SourceIndex(0) name (f)
|
||||
5 >Emitted(74, 14) Source(72, 14) + SourceIndex(0) name (f)
|
||||
6 >Emitted(74, 15) Source(72, 15) + SourceIndex(0) name (f)
|
||||
7 >Emitted(74, 19) Source(72, 19) + SourceIndex(0) name (f)
|
||||
8 >Emitted(74, 20) Source(72, 20) + SourceIndex(0) name (f)
|
||||
9 >Emitted(74, 21) Source(72, 21) + SourceIndex(0) name (f)
|
||||
10>Emitted(74, 24) Source(72, 24) + SourceIndex(0) name (f)
|
||||
11>Emitted(74, 25) Source(72, 25) + SourceIndex(0) name (f)
|
||||
12>Emitted(74, 28) Source(72, 28) + SourceIndex(0) name (f)
|
||||
13>Emitted(74, 29) Source(72, 29) + SourceIndex(0) name (f)
|
||||
14>Emitted(74, 32) Source(72, 32) + SourceIndex(0) name (f)
|
||||
15>Emitted(74, 33) Source(72, 33) + SourceIndex(0) name (f)
|
||||
16>Emitted(74, 36) Source(72, 36) + SourceIndex(0) name (f)
|
||||
17>Emitted(74, 37) Source(72, 37) + SourceIndex(0) name (f)
|
||||
18>Emitted(74, 38) Source(72, 38) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> (x == 1) ? x + 1 : x - 1;
|
||||
1 >^^^^
|
||||
@ -1351,21 +1342,21 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
13> -
|
||||
14> 1
|
||||
15> ;
|
||||
1 >Emitted(78, 5) Source(73, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(78, 6) Source(73, 6) + SourceIndex(0) name (f)
|
||||
3 >Emitted(78, 7) Source(73, 7) + SourceIndex(0) name (f)
|
||||
4 >Emitted(78, 11) Source(73, 11) + SourceIndex(0) name (f)
|
||||
5 >Emitted(78, 12) Source(73, 12) + SourceIndex(0) name (f)
|
||||
6 >Emitted(78, 13) Source(73, 13) + SourceIndex(0) name (f)
|
||||
7 >Emitted(78, 16) Source(73, 16) + SourceIndex(0) name (f)
|
||||
8 >Emitted(78, 17) Source(73, 17) + SourceIndex(0) name (f)
|
||||
9 >Emitted(78, 20) Source(73, 20) + SourceIndex(0) name (f)
|
||||
10>Emitted(78, 21) Source(73, 21) + SourceIndex(0) name (f)
|
||||
11>Emitted(78, 24) Source(73, 24) + SourceIndex(0) name (f)
|
||||
12>Emitted(78, 25) Source(73, 25) + SourceIndex(0) name (f)
|
||||
13>Emitted(78, 28) Source(73, 28) + SourceIndex(0) name (f)
|
||||
14>Emitted(78, 29) Source(73, 29) + SourceIndex(0) name (f)
|
||||
15>Emitted(78, 30) Source(73, 30) + SourceIndex(0) name (f)
|
||||
1 >Emitted(75, 5) Source(73, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(75, 6) Source(73, 6) + SourceIndex(0) name (f)
|
||||
3 >Emitted(75, 7) Source(73, 7) + SourceIndex(0) name (f)
|
||||
4 >Emitted(75, 11) Source(73, 11) + SourceIndex(0) name (f)
|
||||
5 >Emitted(75, 12) Source(73, 12) + SourceIndex(0) name (f)
|
||||
6 >Emitted(75, 13) Source(73, 13) + SourceIndex(0) name (f)
|
||||
7 >Emitted(75, 16) Source(73, 16) + SourceIndex(0) name (f)
|
||||
8 >Emitted(75, 17) Source(73, 17) + SourceIndex(0) name (f)
|
||||
9 >Emitted(75, 20) Source(73, 20) + SourceIndex(0) name (f)
|
||||
10>Emitted(75, 21) Source(73, 21) + SourceIndex(0) name (f)
|
||||
11>Emitted(75, 24) Source(73, 24) + SourceIndex(0) name (f)
|
||||
12>Emitted(75, 25) Source(73, 25) + SourceIndex(0) name (f)
|
||||
13>Emitted(75, 28) Source(73, 28) + SourceIndex(0) name (f)
|
||||
14>Emitted(75, 29) Source(73, 29) + SourceIndex(0) name (f)
|
||||
15>Emitted(75, 30) Source(73, 30) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> x === 1;
|
||||
1 >^^^^
|
||||
@ -1380,11 +1371,11 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
3 > ===
|
||||
4 > 1
|
||||
5 > ;
|
||||
1 >Emitted(79, 5) Source(74, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(79, 6) Source(74, 6) + SourceIndex(0) name (f)
|
||||
3 >Emitted(79, 11) Source(74, 11) + SourceIndex(0) name (f)
|
||||
4 >Emitted(79, 12) Source(74, 12) + SourceIndex(0) name (f)
|
||||
5 >Emitted(79, 13) Source(74, 13) + SourceIndex(0) name (f)
|
||||
1 >Emitted(76, 5) Source(74, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(76, 6) Source(74, 6) + SourceIndex(0) name (f)
|
||||
3 >Emitted(76, 11) Source(74, 11) + SourceIndex(0) name (f)
|
||||
4 >Emitted(76, 12) Source(74, 12) + SourceIndex(0) name (f)
|
||||
5 >Emitted(76, 13) Source(74, 13) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> x = z = 40;
|
||||
1->^^^^
|
||||
@ -1402,13 +1393,13 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
5 > =
|
||||
6 > 40
|
||||
7 > ;
|
||||
1->Emitted(80, 5) Source(75, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(80, 6) Source(75, 6) + SourceIndex(0) name (f)
|
||||
3 >Emitted(80, 9) Source(75, 9) + SourceIndex(0) name (f)
|
||||
4 >Emitted(80, 10) Source(75, 10) + SourceIndex(0) name (f)
|
||||
5 >Emitted(80, 13) Source(75, 13) + SourceIndex(0) name (f)
|
||||
6 >Emitted(80, 15) Source(75, 15) + SourceIndex(0) name (f)
|
||||
7 >Emitted(80, 16) Source(75, 16) + SourceIndex(0) name (f)
|
||||
1->Emitted(77, 5) Source(75, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(77, 6) Source(75, 6) + SourceIndex(0) name (f)
|
||||
3 >Emitted(77, 9) Source(75, 9) + SourceIndex(0) name (f)
|
||||
4 >Emitted(77, 10) Source(75, 10) + SourceIndex(0) name (f)
|
||||
5 >Emitted(77, 13) Source(75, 13) + SourceIndex(0) name (f)
|
||||
6 >Emitted(77, 15) Source(75, 15) + SourceIndex(0) name (f)
|
||||
7 >Emitted(77, 16) Source(75, 16) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> eval("y");
|
||||
1 >^^^^
|
||||
@ -1424,12 +1415,12 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
4 > "y"
|
||||
5 > )
|
||||
6 > ;
|
||||
1 >Emitted(81, 5) Source(76, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(81, 9) Source(76, 9) + SourceIndex(0) name (f)
|
||||
3 >Emitted(81, 10) Source(76, 10) + SourceIndex(0) name (f)
|
||||
4 >Emitted(81, 13) Source(76, 13) + SourceIndex(0) name (f)
|
||||
5 >Emitted(81, 14) Source(76, 14) + SourceIndex(0) name (f)
|
||||
6 >Emitted(81, 15) Source(76, 15) + SourceIndex(0) name (f)
|
||||
1 >Emitted(78, 5) Source(76, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(78, 9) Source(76, 9) + SourceIndex(0) name (f)
|
||||
3 >Emitted(78, 10) Source(76, 10) + SourceIndex(0) name (f)
|
||||
4 >Emitted(78, 13) Source(76, 13) + SourceIndex(0) name (f)
|
||||
5 >Emitted(78, 14) Source(76, 14) + SourceIndex(0) name (f)
|
||||
6 >Emitted(78, 15) Source(76, 15) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>> return;
|
||||
1 >^^^^
|
||||
@ -1439,9 +1430,9 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
>
|
||||
2 > return
|
||||
3 > ;
|
||||
1 >Emitted(82, 5) Source(77, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(82, 11) Source(77, 11) + SourceIndex(0) name (f)
|
||||
3 >Emitted(82, 12) Source(77, 12) + SourceIndex(0) name (f)
|
||||
1 >Emitted(79, 5) Source(77, 5) + SourceIndex(0) name (f)
|
||||
2 >Emitted(79, 11) Source(77, 11) + SourceIndex(0) name (f)
|
||||
3 >Emitted(79, 12) Source(77, 12) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>>}
|
||||
1 >
|
||||
@ -1450,8 +1441,8 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
1 >
|
||||
>
|
||||
2 >}
|
||||
1 >Emitted(83, 1) Source(78, 1) + SourceIndex(0) name (f)
|
||||
2 >Emitted(83, 2) Source(78, 2) + SourceIndex(0) name (f)
|
||||
1 >Emitted(80, 1) Source(78, 1) + SourceIndex(0) name (f)
|
||||
2 >Emitted(80, 2) Source(78, 2) + SourceIndex(0) name (f)
|
||||
---
|
||||
>>>var b = function () {
|
||||
1->
|
||||
@ -1464,10 +1455,10 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
2 >var
|
||||
3 > b
|
||||
4 > =
|
||||
1->Emitted(84, 1) Source(79, 1) + SourceIndex(0)
|
||||
2 >Emitted(84, 5) Source(79, 5) + SourceIndex(0)
|
||||
3 >Emitted(84, 6) Source(79, 6) + SourceIndex(0)
|
||||
4 >Emitted(84, 9) Source(79, 9) + SourceIndex(0)
|
||||
1->Emitted(81, 1) Source(79, 1) + SourceIndex(0)
|
||||
2 >Emitted(81, 5) Source(79, 5) + SourceIndex(0)
|
||||
3 >Emitted(81, 6) Source(79, 6) + SourceIndex(0)
|
||||
4 >Emitted(81, 9) Source(79, 9) + SourceIndex(0)
|
||||
---
|
||||
>>> var x = 10;
|
||||
1->^^^^
|
||||
@ -1483,12 +1474,12 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
4 > =
|
||||
5 > 10
|
||||
6 > ;
|
||||
1->Emitted(85, 5) Source(80, 5) + SourceIndex(0)
|
||||
2 >Emitted(85, 9) Source(80, 9) + SourceIndex(0)
|
||||
3 >Emitted(85, 10) Source(80, 10) + SourceIndex(0)
|
||||
4 >Emitted(85, 13) Source(80, 13) + SourceIndex(0)
|
||||
5 >Emitted(85, 15) Source(80, 15) + SourceIndex(0)
|
||||
6 >Emitted(85, 16) Source(80, 16) + SourceIndex(0)
|
||||
1->Emitted(82, 5) Source(80, 5) + SourceIndex(0)
|
||||
2 >Emitted(82, 9) Source(80, 9) + SourceIndex(0)
|
||||
3 >Emitted(82, 10) Source(80, 10) + SourceIndex(0)
|
||||
4 >Emitted(82, 13) Source(80, 13) + SourceIndex(0)
|
||||
5 >Emitted(82, 15) Source(80, 15) + SourceIndex(0)
|
||||
6 >Emitted(82, 16) Source(80, 16) + SourceIndex(0)
|
||||
---
|
||||
>>> x = x + 1;
|
||||
1 >^^^^
|
||||
@ -1506,13 +1497,13 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
5 > +
|
||||
6 > 1
|
||||
7 > ;
|
||||
1 >Emitted(86, 5) Source(81, 5) + SourceIndex(0)
|
||||
2 >Emitted(86, 6) Source(81, 6) + SourceIndex(0)
|
||||
3 >Emitted(86, 9) Source(81, 9) + SourceIndex(0)
|
||||
4 >Emitted(86, 10) Source(81, 10) + SourceIndex(0)
|
||||
5 >Emitted(86, 13) Source(81, 13) + SourceIndex(0)
|
||||
6 >Emitted(86, 14) Source(81, 14) + SourceIndex(0)
|
||||
7 >Emitted(86, 15) Source(81, 15) + SourceIndex(0)
|
||||
1 >Emitted(83, 5) Source(81, 5) + SourceIndex(0)
|
||||
2 >Emitted(83, 6) Source(81, 6) + SourceIndex(0)
|
||||
3 >Emitted(83, 9) Source(81, 9) + SourceIndex(0)
|
||||
4 >Emitted(83, 10) Source(81, 10) + SourceIndex(0)
|
||||
5 >Emitted(83, 13) Source(81, 13) + SourceIndex(0)
|
||||
6 >Emitted(83, 14) Source(81, 14) + SourceIndex(0)
|
||||
7 >Emitted(83, 15) Source(81, 15) + SourceIndex(0)
|
||||
---
|
||||
>>>};
|
||||
1 >
|
||||
@ -1523,9 +1514,9 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
>
|
||||
2 >}
|
||||
3 > ;
|
||||
1 >Emitted(87, 1) Source(82, 1) + SourceIndex(0)
|
||||
2 >Emitted(87, 2) Source(82, 2) + SourceIndex(0)
|
||||
3 >Emitted(87, 3) Source(82, 3) + SourceIndex(0)
|
||||
1 >Emitted(84, 1) Source(82, 1) + SourceIndex(0)
|
||||
2 >Emitted(84, 2) Source(82, 2) + SourceIndex(0)
|
||||
3 >Emitted(84, 3) Source(82, 3) + SourceIndex(0)
|
||||
---
|
||||
>>>f();
|
||||
1->
|
||||
@ -1538,9 +1529,9 @@ sourceFile:sourceMapValidationStatements.ts
|
||||
2 >f
|
||||
3 > ()
|
||||
4 > ;
|
||||
1->Emitted(88, 1) Source(83, 1) + SourceIndex(0)
|
||||
2 >Emitted(88, 2) Source(83, 2) + SourceIndex(0)
|
||||
3 >Emitted(88, 4) Source(83, 4) + SourceIndex(0)
|
||||
4 >Emitted(88, 5) Source(83, 5) + SourceIndex(0)
|
||||
1->Emitted(85, 1) Source(83, 1) + SourceIndex(0)
|
||||
2 >Emitted(85, 2) Source(83, 2) + SourceIndex(0)
|
||||
3 >Emitted(85, 4) Source(83, 4) + SourceIndex(0)
|
||||
4 >Emitted(85, 5) Source(83, 5) + SourceIndex(0)
|
||||
---
|
||||
>>>//# sourceMappingURL=sourceMapValidationStatements.js.map
|
||||
@ -13,6 +13,5 @@ var Foo = (function () {
|
||||
return Foo;
|
||||
})();
|
||||
switch (0) {
|
||||
case Foo:
|
||||
break;
|
||||
case Foo: break;
|
||||
}
|
||||
|
||||
@ -25,23 +25,15 @@ var Foo = (function () {
|
||||
return Foo;
|
||||
})();
|
||||
switch (0) {
|
||||
case Foo:
|
||||
break;
|
||||
case "sss":
|
||||
break;
|
||||
case 123:
|
||||
break;
|
||||
case true:
|
||||
break;
|
||||
case Foo: break;
|
||||
case "sss": break;
|
||||
case 123: break;
|
||||
case true: break;
|
||||
}
|
||||
var s = 0;
|
||||
switch (s) {
|
||||
case Foo:
|
||||
break;
|
||||
case "sss":
|
||||
break;
|
||||
case 123:
|
||||
break;
|
||||
case true:
|
||||
break;
|
||||
case Foo: break;
|
||||
case "sss": break;
|
||||
case 123: break;
|
||||
case true: break;
|
||||
}
|
||||
|
||||
@ -26,10 +26,9 @@ function R1(index) {
|
||||
var a = 'a';
|
||||
return a;
|
||||
case 3:
|
||||
case 4:
|
||||
{
|
||||
return 'b';
|
||||
}
|
||||
case 4: {
|
||||
return 'b';
|
||||
}
|
||||
case 5:
|
||||
default:
|
||||
return 'c';
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(12,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(16,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(20,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(12,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(16,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(20,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
@ -32,55 +32,55 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped
|
||||
|
||||
f `abc`
|
||||
~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc${1}def${2}ghi`;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc`.member
|
||||
~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc${1}def${2}ghi`.member;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc`["member"];
|
||||
~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc${1}def${2}ghi`["member"];
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc`[0].member `abc${1}def${2}ghi`;
|
||||
~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts(13,21): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts(13,21): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts (1 errors) ====
|
||||
@ -16,6 +16,6 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMember
|
||||
|
||||
var x = new new new f `abc${ 0 }def`.member("hello")(42) === true;
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(16,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(17,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(18,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(20,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(16,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(17,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(18,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(20,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(12,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(14,9): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
@ -32,24 +32,24 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio
|
||||
|
||||
var u = foo ``; // number
|
||||
~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var v = foo `${1}`; // string
|
||||
~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var w = foo `${1}${2}`; // boolean
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var x = foo `${1}${true}`; // boolean (with error)
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
var y = foo `${1}${"2"}`; // {}
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var z = foo `${1}${2}${3}`; // any (with error)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(3,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(5,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(7,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(9,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(11,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(13,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(15,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(17,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(3,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(5,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(7,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(9,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(11,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(13,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(15,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(17,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts (12 errors) ====
|
||||
@ -17,47 +17,47 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts
|
||||
|
||||
f `abc`
|
||||
~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc${1}def${2}ghi`;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f.g.h `abc`
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f.g.h `abc${1}def${2}ghi`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc`.member
|
||||
~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc${1}def${2}ghi`.member;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc`["member"];
|
||||
~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc${1}def${2}ghi`["member"];
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc`["member"].someOtherTag `abc${1}def${2}ghi`;
|
||||
~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f.thisIsNotATag(`abc`);
|
||||
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(12,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(14,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(16,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(18,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(20,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(22,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(12,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(14,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(16,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(18,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(20,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(22,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts (10 errors) ====
|
||||
@ -24,39 +24,39 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,1
|
||||
|
||||
f `abc`
|
||||
~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc${1}def${2}ghi`;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc`.member
|
||||
~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc${1}def${2}ghi`.member;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc`["member"];
|
||||
~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc${1}def${2}ghi`["member"];
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc`[0].member `abc${1}def${2}ghi`;
|
||||
~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
f.thisIsNotATag(`abc`);
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,9): error TS1005: ';' expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,21): error TS1005: ';' expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error TS1005: ';' expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,24): error TS1005: ';' expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,1): error TS2304: Cannot find name 'declare'.
|
||||
tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,9): error TS2304: Cannot find name 'module'.
|
||||
@ -15,7 +15,7 @@ tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error
|
||||
~~~~~~
|
||||
!!! error TS1005: ';' expected.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
~~~~~~~
|
||||
@ -28,7 +28,7 @@ tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error
|
||||
~~~~~~
|
||||
!!! error TS1005: ';' expected.
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS1005: ';' expected.
|
||||
~~~~~~~
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user