mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into semanticBindingPropNames
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
declare var require: any;
|
||||
let fs = require('fs');
|
||||
let async = require('async');
|
||||
let glob = require('glob');
|
||||
|
||||
fs.readFile('src/compiler/diagnosticMessages.json', 'utf-8', (err, data) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
let messages = JSON.parse(data);
|
||||
let keys = Object.keys(messages);
|
||||
console.log('Loaded ' + keys.length + ' errors');
|
||||
|
||||
for (let k of keys) {
|
||||
messages[k]['seen'] = false;
|
||||
}
|
||||
|
||||
let errRegex = /\(\d+,\d+\): error TS([^:]+):/g;
|
||||
|
||||
let baseDir = 'tests/baselines/reference/';
|
||||
fs.readdir(baseDir, (err, files) => {
|
||||
files = files.filter(f => f.indexOf('.errors.txt') > 0);
|
||||
let tasks: Array<(callback: () => void) => void> = [];
|
||||
files.forEach(f => tasks.push(done => {
|
||||
fs.readFile(baseDir + f, 'utf-8', (err, baseline) => {
|
||||
if (err) throw err;
|
||||
|
||||
let g: string[];
|
||||
while (g = errRegex.exec(baseline)) {
|
||||
var errCode = +g[1];
|
||||
let msg = keys.filter(k => messages[k].code === errCode)[0];
|
||||
messages[msg]['seen'] = true;
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
}));
|
||||
|
||||
async.parallelLimit(tasks, 25, done => {
|
||||
console.log('== List of errors not present in baselines ==');
|
||||
let count = 0;
|
||||
for (let k of keys) {
|
||||
if (messages[k]['seen'] !== true) {
|
||||
console.log(k);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
console.log(count + ' of ' + keys.length + ' errors are not in baselines');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
fs.readFile('src/compiler/diagnosticInformationMap.generated.ts', 'utf-8', (err, data) => {
|
||||
let errorRegexp = /\s(\w+): \{ code/g;
|
||||
let errorNames: string[] = [];
|
||||
let errMatch: string[];
|
||||
while (errMatch = errorRegexp.exec(data)) {
|
||||
errorNames.push(errMatch[1]);
|
||||
}
|
||||
|
||||
let allSrc: string = '';
|
||||
glob('./src/**/*.ts', {}, (err, files) => {
|
||||
console.log('Reading ' + files.length + ' source files');
|
||||
for(let file of files) {
|
||||
if (file.indexOf('diagnosticInformationMap.generated.ts') > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let src = fs.readFileSync(file, 'utf-8');
|
||||
allSrc = allSrc + src;
|
||||
}
|
||||
|
||||
console.log('Consumed ' + allSrc.length + ' characters of source');
|
||||
|
||||
let count = 0;
|
||||
console.log('== List of errors not used in source ==')
|
||||
for(let errName of errorNames) {
|
||||
if (allSrc.indexOf(errName) < 0) {
|
||||
console.log(errName);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
console.log(count + ' of ' + errorNames.length + ' errors are not used in source');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,22 +20,16 @@ namespace ts {
|
||||
An_index_signature_must_have_a_type_annotation: { code: 1021, category: DiagnosticCategory.Error, key: "An index signature must have a type annotation." },
|
||||
An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." },
|
||||
An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." },
|
||||
A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." },
|
||||
An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." },
|
||||
A_class_can_only_extend_a_single_class: { code: 1026, category: DiagnosticCategory.Error, key: "A class can only extend a single class." },
|
||||
A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: DiagnosticCategory.Error, key: "A class declaration can only have one 'implements' clause." },
|
||||
Accessibility_modifier_already_seen: { code: 1028, category: DiagnosticCategory.Error, key: "Accessibility modifier already seen." },
|
||||
_0_modifier_must_precede_1_modifier: { code: 1029, category: DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." },
|
||||
_0_modifier_already_seen: { code: 1030, category: DiagnosticCategory.Error, key: "'{0}' modifier already seen." },
|
||||
_0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." },
|
||||
An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: DiagnosticCategory.Error, key: "An interface declaration cannot have an 'implements' clause." },
|
||||
super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." },
|
||||
Only_ambient_modules_can_use_quoted_names: { code: 1035, category: DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." },
|
||||
Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." },
|
||||
A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." },
|
||||
Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." },
|
||||
_0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." },
|
||||
A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." },
|
||||
A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." },
|
||||
A_rest_parameter_cannot_be_optional: { code: 1047, category: DiagnosticCategory.Error, key: "A rest parameter cannot be optional." },
|
||||
A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." },
|
||||
@@ -94,7 +88,6 @@ namespace ts {
|
||||
case_or_default_expected: { code: 1130, category: DiagnosticCategory.Error, key: "'case' or 'default' expected." },
|
||||
Property_or_signature_expected: { code: 1131, category: DiagnosticCategory.Error, key: "Property or signature expected." },
|
||||
Enum_member_expected: { code: 1132, category: DiagnosticCategory.Error, key: "Enum member expected." },
|
||||
Type_reference_expected: { code: 1133, category: DiagnosticCategory.Error, key: "Type reference expected." },
|
||||
Variable_declaration_expected: { code: 1134, category: DiagnosticCategory.Error, key: "Variable declaration expected." },
|
||||
Argument_expression_expected: { code: 1135, category: DiagnosticCategory.Error, key: "Argument expression expected." },
|
||||
Property_assignment_expected: { code: 1136, category: DiagnosticCategory.Error, key: "Property assignment expected." },
|
||||
@@ -111,9 +104,6 @@ namespace ts {
|
||||
Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." },
|
||||
File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" },
|
||||
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead." },
|
||||
var_let_or_const_expected: { code: 1152, category: DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." },
|
||||
let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." },
|
||||
const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." },
|
||||
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." },
|
||||
@@ -124,7 +114,6 @@ namespace ts {
|
||||
Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." },
|
||||
A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." },
|
||||
A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." },
|
||||
Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." },
|
||||
A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." },
|
||||
A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." },
|
||||
A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." },
|
||||
@@ -140,7 +129,6 @@ namespace ts {
|
||||
Property_destructuring_pattern_expected: { code: 1180, category: DiagnosticCategory.Error, key: "Property destructuring pattern expected." },
|
||||
Array_element_destructuring_pattern_expected: { code: 1181, category: DiagnosticCategory.Error, key: "Array element destructuring pattern expected." },
|
||||
A_destructuring_declaration_must_have_an_initializer: { code: 1182, category: DiagnosticCategory.Error, key: "A destructuring declaration must have an initializer." },
|
||||
Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts." },
|
||||
An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, category: DiagnosticCategory.Error, key: "An implementation cannot be declared in ambient contexts." },
|
||||
Modifiers_cannot_appear_here: { code: 1184, category: DiagnosticCategory.Error, key: "Modifiers cannot appear here." },
|
||||
Merge_conflict_marker_encountered: { code: 1185, category: DiagnosticCategory.Error, key: "Merge conflict marker encountered." },
|
||||
@@ -205,7 +193,6 @@ namespace ts {
|
||||
Module_0_has_no_exported_member_1: { code: 2305, category: DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." },
|
||||
File_0_is_not_a_module: { code: 2306, category: DiagnosticCategory.Error, key: "File '{0}' is not a module." },
|
||||
Cannot_find_module_0: { code: 2307, category: DiagnosticCategory.Error, key: "Cannot find module '{0}'." },
|
||||
A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." },
|
||||
An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." },
|
||||
Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." },
|
||||
A_class_may_only_extend_another_class: { code: 2311, category: DiagnosticCategory.Error, key: "A class may only extend another class." },
|
||||
@@ -531,7 +518,6 @@ namespace ts {
|
||||
File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' has unsupported extension. The only supported extensions are {1}." },
|
||||
Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." },
|
||||
Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." },
|
||||
Preserve_new_lines_when_emitting_code: { code: 6057, category: DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." },
|
||||
Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." },
|
||||
File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." },
|
||||
Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." },
|
||||
|
||||
@@ -67,22 +67,6 @@
|
||||
"category": "Error",
|
||||
"code": 1023
|
||||
},
|
||||
"A class or interface declaration can only have one 'extends' clause.": {
|
||||
"category": "Error",
|
||||
"code": 1024
|
||||
},
|
||||
"An 'extends' clause must precede an 'implements' clause.": {
|
||||
"category": "Error",
|
||||
"code": 1025
|
||||
},
|
||||
"A class can only extend a single class.": {
|
||||
"category": "Error",
|
||||
"code": 1026
|
||||
},
|
||||
"A class declaration can only have one 'implements' clause.": {
|
||||
"category": "Error",
|
||||
"code": 1027
|
||||
},
|
||||
"Accessibility modifier already seen.": {
|
||||
"category": "Error",
|
||||
"code": 1028
|
||||
@@ -99,10 +83,6 @@
|
||||
"category": "Error",
|
||||
"code": 1031
|
||||
},
|
||||
"An interface declaration cannot have an 'implements' clause.": {
|
||||
"category": "Error",
|
||||
"code": 1032
|
||||
},
|
||||
"'super' must be followed by an argument list or member access.": {
|
||||
"category": "Error",
|
||||
"code": 1034
|
||||
@@ -127,10 +107,6 @@
|
||||
"category": "Error",
|
||||
"code": 1044
|
||||
},
|
||||
"A 'declare' modifier cannot be used with an interface declaration.": {
|
||||
"category": "Error",
|
||||
"code": 1045
|
||||
},
|
||||
"A 'declare' modifier is required for a top level declaration in a .d.ts file.": {
|
||||
"category": "Error",
|
||||
"code": 1046
|
||||
@@ -363,10 +339,6 @@
|
||||
"category": "Error",
|
||||
"code": 1132
|
||||
},
|
||||
"Type reference expected.": {
|
||||
"category": "Error",
|
||||
"code": 1133
|
||||
},
|
||||
"Variable declaration expected.": {
|
||||
"category": "Error",
|
||||
"code": 1134
|
||||
@@ -431,18 +403,6 @@
|
||||
"category": "Error",
|
||||
"code": 1150
|
||||
},
|
||||
"'var', 'let' or 'const' expected.": {
|
||||
"category": "Error",
|
||||
"code": 1152
|
||||
},
|
||||
"'let' declarations are only available when targeting ECMAScript 6 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1153
|
||||
},
|
||||
"'const' declarations are only available when targeting ECMAScript 6 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1154
|
||||
},
|
||||
"'const' declarations must be initialized": {
|
||||
"category": "Error",
|
||||
"code": 1155
|
||||
@@ -483,10 +443,6 @@
|
||||
"category": "Error",
|
||||
"code": 1166
|
||||
},
|
||||
"Computed property names are only available when targeting ECMAScript 6 and higher.": {
|
||||
"category": "Error",
|
||||
"code": 1167
|
||||
},
|
||||
"A computed property name in a method overload must directly refer to a built-in symbol.": {
|
||||
"category": "Error",
|
||||
"code": 1168
|
||||
@@ -547,10 +503,6 @@
|
||||
"category": "Error",
|
||||
"code": 1182
|
||||
},
|
||||
"Destructuring declarations are not allowed in ambient contexts.": {
|
||||
"category": "Error",
|
||||
"code": 1183
|
||||
},
|
||||
"An implementation cannot be declared in ambient contexts.": {
|
||||
"category": "Error",
|
||||
"code": 1184
|
||||
@@ -810,10 +762,6 @@
|
||||
"category": "Error",
|
||||
"code": 2307
|
||||
},
|
||||
"A module cannot have more than one export assignment.": {
|
||||
"category": "Error",
|
||||
"code": 2308
|
||||
},
|
||||
"An export assignment cannot be used in a module with other exported elements.": {
|
||||
"category": "Error",
|
||||
"code": 2309
|
||||
@@ -2116,10 +2064,6 @@
|
||||
"category": "Message",
|
||||
"code": 6056
|
||||
},
|
||||
"Preserve new-lines when emitting code.": {
|
||||
"category": "Message",
|
||||
"code": 6057
|
||||
},
|
||||
"Specifies the root directory of input files. Use to control the output directory structure with --outDir.": {
|
||||
"category": "Message",
|
||||
"code": 6058
|
||||
|
||||
+2
-1
@@ -191,7 +191,8 @@ namespace ts {
|
||||
return sys.exit(ExitStatus.Success);
|
||||
}
|
||||
|
||||
if (commandLine.options.watch) {
|
||||
// Firefox has Object.prototype.watch
|
||||
if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) {
|
||||
if (!sys.watchFile) {
|
||||
reportDiagnostic(createCompilerDiagnostic(Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
|
||||
return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped);
|
||||
|
||||
@@ -743,7 +743,7 @@ module FourSlash {
|
||||
var reference = references[i];
|
||||
if (reference && reference.fileName === fileName && reference.textSpan.start === start && ts.textSpanEnd(reference.textSpan) === end) {
|
||||
if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) {
|
||||
this.raiseError('verifyReferencesAtPositionListContains failed - item isWriteAccess value doe not match, actual: ' + reference.isWriteAccess + ', expected: ' + isWriteAccess + '.');
|
||||
this.raiseError('verifyReferencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ' + reference.isWriteAccess + ', expected: ' + isWriteAccess + '.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -884,8 +884,16 @@ module FourSlash {
|
||||
this.activeFile.fileName, this.currentCaretPosition, findInStrings, findInComments);
|
||||
|
||||
var ranges = this.getRanges();
|
||||
|
||||
if (!references) {
|
||||
if (ranges.length !== 0) {
|
||||
this.raiseError(`Expected ${ranges.length} rename locations; got none.`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (ranges.length !== references.length) {
|
||||
this.raiseError(this.assertionMessage("Rename locations", references.length, ranges.length));
|
||||
this.raiseError("Rename location count does not match result.\n\nExpected: " + JSON.stringify(ranges) + "\n\nActual:" + JSON.stringify(references));
|
||||
}
|
||||
|
||||
ranges = ranges.sort((r1, r2) => r1.start - r2.start);
|
||||
@@ -898,9 +906,7 @@ module FourSlash {
|
||||
if (reference.textSpan.start !== range.start ||
|
||||
ts.textSpanEnd(reference.textSpan) !== range.end) {
|
||||
|
||||
this.raiseError(this.assertionMessage("Rename location",
|
||||
"[" + reference.textSpan.start + "," + ts.textSpanEnd(reference.textSpan) + ")",
|
||||
"[" + range.start + "," + range.end + ")"));
|
||||
this.raiseError("Rename location results do not match.\n\nExpected: " + JSON.stringify(ranges) + "\n\nActual:" + JSON.stringify(references));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ namespace ts.formatting {
|
||||
this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
|
||||
// Add a space around certain TypeScript keywords
|
||||
this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
|
||||
// Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" {
|
||||
|
||||
+54
-85
@@ -1797,7 +1797,7 @@ namespace ts {
|
||||
let outputText: string;
|
||||
|
||||
// Create a compilerHost object to allow the compiler to read and write files
|
||||
var compilerHost: CompilerHost = {
|
||||
let compilerHost: CompilerHost = {
|
||||
getSourceFile: (fileName, target) => fileName === inputFileName ? sourceFile : undefined,
|
||||
writeFile: (name, text, writeByteOrderMark) => {
|
||||
Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name);
|
||||
@@ -1810,7 +1810,7 @@ namespace ts {
|
||||
getNewLine: () => newLine
|
||||
};
|
||||
|
||||
var program = createProgram([inputFileName], options, compilerHost);
|
||||
let program = createProgram([inputFileName], options, compilerHost);
|
||||
|
||||
addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile));
|
||||
addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics());
|
||||
@@ -3084,7 +3084,7 @@ namespace ts {
|
||||
* accurately aggregate locals from the closest containing scope.
|
||||
*/
|
||||
function getScopeNode(initialToken: Node, position: number, sourceFile: SourceFile) {
|
||||
var scope = initialToken;
|
||||
let scope = initialToken;
|
||||
while (scope && !positionBelongsToNode(scope, position, sourceFile)) {
|
||||
scope = scope.parent;
|
||||
}
|
||||
@@ -3485,10 +3485,10 @@ namespace ts {
|
||||
|
||||
function getCompletionEntriesFromSymbols(symbols: Symbol[]): CompletionEntry[] {
|
||||
let start = new Date().getTime();
|
||||
var entries: CompletionEntry[] = [];
|
||||
let entries: CompletionEntry[] = [];
|
||||
|
||||
if (symbols) {
|
||||
var nameToSymbol: Map<Symbol> = {};
|
||||
let nameToSymbol: Map<Symbol> = {};
|
||||
for (let symbol of symbols) {
|
||||
let entry = createCompletionEntry(symbol, location);
|
||||
if (entry) {
|
||||
@@ -3522,13 +3522,13 @@ namespace ts {
|
||||
let symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false) === entryName ? s : undefined);
|
||||
|
||||
if (symbol) {
|
||||
let displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, location, SemanticMeaning.All);
|
||||
let { displayParts, documentation, symbolKind } = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, location, SemanticMeaning.All);
|
||||
return {
|
||||
name: entryName,
|
||||
kind: displayPartsDocumentationsAndSymbolKind.symbolKind,
|
||||
kindModifiers: getSymbolModifiers(symbol),
|
||||
displayParts: displayPartsDocumentationsAndSymbolKind.displayParts,
|
||||
documentation: displayPartsDocumentationsAndSymbolKind.documentation
|
||||
kind: symbolKind,
|
||||
displayParts,
|
||||
documentation
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4203,7 +4203,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
if (type.flags & TypeFlags.Union) {
|
||||
var result: DefinitionInfo[] = [];
|
||||
let result: DefinitionInfo[] = [];
|
||||
forEach((<UnionType>type).types, t => {
|
||||
if (t.symbol) {
|
||||
addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node));
|
||||
@@ -4265,7 +4265,7 @@ namespace ts {
|
||||
isLiteralNameOfPropertyDeclarationOrIndexAccess(node) ||
|
||||
isNameOfExternalModuleImportOrDeclaration(node)) {
|
||||
|
||||
let referencedSymbols = getReferencedSymbolsForNodes(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false);
|
||||
let referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings:*/ false, /*findInComments:*/ false);
|
||||
return convertReferencedSymbols(referencedSymbols);
|
||||
}
|
||||
|
||||
@@ -4303,7 +4303,7 @@ namespace ts {
|
||||
function getSyntacticDocumentHighlights(node: Node): DocumentHighlights[] {
|
||||
let fileName = sourceFile.fileName;
|
||||
|
||||
var highlightSpans = getHighlightSpans(node);
|
||||
let highlightSpans = getHighlightSpans(node);
|
||||
if (!highlightSpans || highlightSpans.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -4881,17 +4881,17 @@ namespace ts {
|
||||
}
|
||||
|
||||
function findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] {
|
||||
var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments);
|
||||
let referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments);
|
||||
return convertReferences(referencedSymbols);
|
||||
}
|
||||
|
||||
function getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
|
||||
var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false);
|
||||
let referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false);
|
||||
return convertReferences(referencedSymbols);
|
||||
}
|
||||
|
||||
function findReferences(fileName: string, position: number): ReferencedSymbol[]{
|
||||
var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false);
|
||||
let referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false);
|
||||
|
||||
// Only include referenced symbols that have a valid definition.
|
||||
return filter(referencedSymbols, rs => !!rs.definition);
|
||||
@@ -4917,10 +4917,10 @@ namespace ts {
|
||||
}
|
||||
|
||||
Debug.assert(node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.NumericLiteral || node.kind === SyntaxKind.StringLiteral);
|
||||
return getReferencedSymbolsForNodes(node, program.getSourceFiles(), findInStrings, findInComments);
|
||||
return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments);
|
||||
}
|
||||
|
||||
function getReferencedSymbolsForNodes(node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] {
|
||||
function getReferencedSymbolsForNode(node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] {
|
||||
let typeChecker = program.getTypeChecker();
|
||||
|
||||
// Labels
|
||||
@@ -4955,7 +4955,7 @@ namespace ts {
|
||||
|
||||
let declarations = symbol.declarations;
|
||||
|
||||
// The symbol was an internal symbol and does not have a declaration e.g.undefined symbol
|
||||
// The symbol was an internal symbol and does not have a declaration e.g. undefined symbol
|
||||
if (!declarations || !declarations.length) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -4965,8 +4965,9 @@ namespace ts {
|
||||
// Compute the meaning from the location and the symbol it references
|
||||
let searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations);
|
||||
|
||||
// Get the text to search for, we need to normalize it as external module names will have quote
|
||||
let declaredName = getDeclaredName(symbol, node);
|
||||
// Get the text to search for.
|
||||
// Note: if this is an external module symbol, the name doesn't include quotes.
|
||||
let declaredName = getDeclaredName(typeChecker, symbol, node);
|
||||
|
||||
// Try to get the smallest valid scope that we can limit our search to;
|
||||
// otherwise we'll need to search globally (i.e. include each file).
|
||||
@@ -5013,76 +5014,43 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function isImportOrExportSpecifierName(location: Node): boolean {
|
||||
return location.parent &&
|
||||
(location.parent.kind === SyntaxKind.ImportSpecifier || location.parent.kind === SyntaxKind.ExportSpecifier) &&
|
||||
(<ImportOrExportSpecifier>location.parent).propertyName === location;
|
||||
}
|
||||
|
||||
function isImportOrExportSpecifierImportSymbol(symbol: Symbol) {
|
||||
return (symbol.flags & SymbolFlags.Alias) && forEach(symbol.declarations, declaration => {
|
||||
return declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ExportSpecifier;
|
||||
});
|
||||
}
|
||||
|
||||
function getDeclaredName(symbol: Symbol, location: Node) {
|
||||
// Special case for function expressions, whose names are solely local to their bodies.
|
||||
let functionExpression = forEach(symbol.declarations, d => d.kind === SyntaxKind.FunctionExpression ? <FunctionExpression>d : undefined);
|
||||
|
||||
// When a name gets interned into a SourceFile's 'identifiers' Map,
|
||||
// its name is escaped and stored in the same way its symbol name/identifier
|
||||
// name should be stored. Function expressions, however, are a special case,
|
||||
// because despite sometimes having a name, the binder unconditionally binds them
|
||||
// to a symbol with the name "__function".
|
||||
let name: string;
|
||||
if (functionExpression && functionExpression.name) {
|
||||
name = functionExpression.name.text;
|
||||
}
|
||||
|
||||
// If this is an export or import specifier it could have been renamed using the as syntax.
|
||||
// if so we want to search for whatever under the cursor, the symbol is pointing to the alias (name)
|
||||
// so check for the propertyName.
|
||||
if (isImportOrExportSpecifierName(location)) {
|
||||
return location.getText();
|
||||
}
|
||||
|
||||
name = typeChecker.symbolToString(symbol);
|
||||
|
||||
return stripQuotes(name);
|
||||
}
|
||||
|
||||
function getInternedName(symbol: Symbol, location: Node, declarations: Declaration[]): string {
|
||||
// If this is an export or import specifier it could have been renamed using the as syntax.
|
||||
// if so we want to search for whatever under the cursor, the symbol is pointing to the alias (name)
|
||||
// so check for the propertyName.
|
||||
// If this is an export or import specifier it could have been renamed using the 'as' syntax.
|
||||
// If so we want to search for whatever under the cursor.
|
||||
if (isImportOrExportSpecifierName(location)) {
|
||||
return location.getText();
|
||||
}
|
||||
|
||||
// Special case for function expressions, whose names are solely local to their bodies.
|
||||
let functionExpression = forEach(declarations, d => d.kind === SyntaxKind.FunctionExpression ? <FunctionExpression>d : undefined);
|
||||
// Try to get the local symbol if we're dealing with an 'export default'
|
||||
// since that symbol has the "true" name.
|
||||
let localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol);
|
||||
symbol = localExportDefaultSymbol || symbol;
|
||||
|
||||
// When a name gets interned into a SourceFile's 'identifiers' Map,
|
||||
// its name is escaped and stored in the same way its symbol name/identifier
|
||||
// name should be stored. Function expressions, however, are a special case,
|
||||
// because despite sometimes having a name, the binder unconditionally binds them
|
||||
// to a symbol with the name "__function".
|
||||
let name = functionExpression && functionExpression.name
|
||||
? functionExpression.name.text
|
||||
: symbol.name;
|
||||
|
||||
return stripQuotes(name);
|
||||
}
|
||||
|
||||
function stripQuotes(name: string) {
|
||||
let length = name.length;
|
||||
if (length >= 2 && name.charCodeAt(0) === CharacterCodes.doubleQuote && name.charCodeAt(length - 1) === CharacterCodes.doubleQuote) {
|
||||
return name.substring(1, length - 1);
|
||||
};
|
||||
return name;
|
||||
return stripQuotes(symbol.name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the smallest scope in which a symbol may have named references.
|
||||
* Note that not every construct has been accounted for. This function can
|
||||
* probably be improved.
|
||||
*
|
||||
* @returns undefined if the scope cannot be determined, implying that
|
||||
* a reference to a symbol can occur anywhere.
|
||||
*/
|
||||
function getSymbolScope(symbol: Symbol): Node {
|
||||
// If this is the symbol of a function expression, then named references
|
||||
// are limited to its own scope.
|
||||
let valueDeclaration = symbol.valueDeclaration;
|
||||
if (valueDeclaration && valueDeclaration.kind === SyntaxKind.FunctionExpression) {
|
||||
return valueDeclaration;
|
||||
}
|
||||
|
||||
// If this is private property or method, the scope is the containing class
|
||||
if (symbol.flags & (SymbolFlags.Property | SymbolFlags.Method)) {
|
||||
let privateDeclaration = forEach(symbol.getDeclarations(), d => (d.flags & NodeFlags.Private) ? d : undefined);
|
||||
@@ -5190,7 +5158,7 @@ namespace ts {
|
||||
}
|
||||
});
|
||||
|
||||
var definition: DefinitionInfo = {
|
||||
let definition: DefinitionInfo = {
|
||||
containerKind: "",
|
||||
containerName: "",
|
||||
fileName: targetLabel.getSourceFile().fileName,
|
||||
@@ -5286,10 +5254,10 @@ namespace ts {
|
||||
if (referenceSymbol) {
|
||||
let referenceSymbolDeclaration = referenceSymbol.valueDeclaration;
|
||||
let shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration);
|
||||
var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation);
|
||||
let relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation);
|
||||
|
||||
if (relatedSymbol) {
|
||||
var referencedSymbol = getReferencedSymbol(relatedSymbol);
|
||||
let referencedSymbol = getReferencedSymbol(relatedSymbol);
|
||||
referencedSymbol.references.push(getReferenceEntryFromNode(referenceLocation));
|
||||
}
|
||||
/* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment
|
||||
@@ -5299,7 +5267,7 @@ namespace ts {
|
||||
* position of property accessing, the referenceEntry of such position will be handled in the first case.
|
||||
*/
|
||||
else if (!(referenceSymbol.flags & SymbolFlags.Transient) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) {
|
||||
var referencedSymbol = getReferencedSymbol(shorthandValueSymbol);
|
||||
let referencedSymbol = getReferencedSymbol(shorthandValueSymbol);
|
||||
referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name));
|
||||
}
|
||||
}
|
||||
@@ -5309,8 +5277,8 @@ namespace ts {
|
||||
return;
|
||||
|
||||
function getReferencedSymbol(symbol: Symbol): ReferencedSymbol {
|
||||
var symbolId = getSymbolId(symbol);
|
||||
var index = symbolToIndex[symbolId];
|
||||
let symbolId = getSymbolId(symbol);
|
||||
let index = symbolToIndex[symbolId];
|
||||
if (index === undefined) {
|
||||
index = result.length;
|
||||
symbolToIndex[symbolId] = index;
|
||||
@@ -5397,7 +5365,7 @@ namespace ts {
|
||||
}
|
||||
});
|
||||
|
||||
var definition = getDefinition(searchSpaceNode.symbol);
|
||||
let definition = getDefinition(searchSpaceNode.symbol);
|
||||
return [{ definition, references }];
|
||||
}
|
||||
|
||||
@@ -5592,7 +5560,7 @@ namespace ts {
|
||||
// If the reference symbol is an alias, check if what it is aliasing is one of the search
|
||||
// symbols.
|
||||
if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) {
|
||||
var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol);
|
||||
let aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol);
|
||||
if (searchSymbols.indexOf(aliasedSymbol) >= 0) {
|
||||
return aliasedSymbol;
|
||||
}
|
||||
@@ -6724,12 +6692,13 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
let displayName = getDeclaredName(typeChecker, symbol, node);
|
||||
let kind = getSymbolKind(symbol, node);
|
||||
if (kind) {
|
||||
return {
|
||||
canRename: true,
|
||||
localizedErrorMessage: undefined,
|
||||
displayName: symbol.name,
|
||||
displayName,
|
||||
fullDisplayName: typeChecker.getFullyQualifiedName(symbol),
|
||||
kind: kind,
|
||||
kindModifiers: getSymbolModifiers(symbol),
|
||||
@@ -6908,7 +6877,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function convertClassifications(classifications: Classifications, text: string): ClassificationResult {
|
||||
var entries: ClassificationInfo[] = [];
|
||||
let entries: ClassificationInfo[] = [];
|
||||
let dense = classifications.spans;
|
||||
let lastEnd = 0;
|
||||
|
||||
|
||||
@@ -652,4 +652,34 @@ namespace ts {
|
||||
typechecker.getSymbolDisplayBuilder().buildSignatureDisplay(signature, writer, enclosingDeclaration, flags);
|
||||
});
|
||||
}
|
||||
|
||||
export function getDeclaredName(typeChecker: TypeChecker, symbol: Symbol, location: Node): string {
|
||||
// If this is an export or import specifier it could have been renamed using the 'as' syntax.
|
||||
// If so we want to search for whatever is under the cursor.
|
||||
if (isImportOrExportSpecifierName(location)) {
|
||||
return location.getText();
|
||||
}
|
||||
|
||||
// Try to get the local symbol if we're dealing with an 'export default'
|
||||
// since that symbol has the "true" name.
|
||||
let localExportDefaultSymbol = getLocalSymbolForExportDefault(symbol);
|
||||
|
||||
let name = typeChecker.symbolToString(localExportDefaultSymbol || symbol);
|
||||
|
||||
return stripQuotes(name);
|
||||
}
|
||||
|
||||
export function isImportOrExportSpecifierName(location: Node): boolean {
|
||||
return location.parent &&
|
||||
(location.parent.kind === SyntaxKind.ImportSpecifier || location.parent.kind === SyntaxKind.ExportSpecifier) &&
|
||||
(<ImportOrExportSpecifier>location.parent).propertyName === location;
|
||||
}
|
||||
|
||||
export function stripQuotes(name: string) {
|
||||
let length = name.length;
|
||||
if (length >= 2 && name.charCodeAt(0) === CharacterCodes.doubleQuote && name.charCodeAt(length - 1) === CharacterCodes.doubleQuote) {
|
||||
return name.substring(1, length - 1);
|
||||
};
|
||||
return name;
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
tests/cases/compiler/numLit.ts(3,3): error TS1005: ';' expected.
|
||||
tests/cases/compiler/numLit.ts(9,15): error TS1005: ',' expected.
|
||||
tests/cases/compiler/numLit.ts(9,23): error TS1005: '=' expected.
|
||||
tests/cases/compiler/numLit.ts(9,24): error TS1109: Expression expected.
|
||||
tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(3,3): error TS1005: ';' expected.
|
||||
tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,15): error TS1005: ',' expected.
|
||||
tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,23): error TS1005: '=' expected.
|
||||
tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,24): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/numLit.ts (4 errors) ====
|
||||
==== tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts (4 errors) ====
|
||||
1..toString();
|
||||
1.0.toString();
|
||||
1.toString();
|
||||
@@ -15,7 +15,7 @@ tests/cases/compiler/numLit.ts(9,24): error TS1109: Expression expected.
|
||||
// Preserve whitespace where important for JS compatibility
|
||||
var i: number = 1;
|
||||
var test1 = i.toString();
|
||||
var test2 = 2.toString(); // emitted as 2 .toString()
|
||||
var test2 = 2.toString();
|
||||
~~~~~~~~
|
||||
!!! error TS1005: ',' expected.
|
||||
~
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
//// [numLit.ts]
|
||||
//// [numericLiteralsWithTrailingDecimalPoints01.ts]
|
||||
1..toString();
|
||||
1.0.toString();
|
||||
1.toString();
|
||||
@@ -7,7 +7,7 @@
|
||||
// Preserve whitespace where important for JS compatibility
|
||||
var i: number = 1;
|
||||
var test1 = i.toString();
|
||||
var test2 = 2.toString(); // emitted as 2 .toString()
|
||||
var test2 = 2.toString();
|
||||
var test3 = 3 .toString();
|
||||
var test4 = 3 .toString();
|
||||
var test5 = 3 .toString();
|
||||
@@ -18,7 +18,7 @@ var test8 = new Number(4).toString();
|
||||
var test9 = 3. + 3.
|
||||
|
||||
|
||||
//// [numLit.js]
|
||||
//// [numericLiteralsWithTrailingDecimalPoints01.js]
|
||||
1..toString();
|
||||
1.0.toString();
|
||||
1.;
|
||||
@@ -27,7 +27,7 @@ toString();
|
||||
// Preserve whitespace where important for JS compatibility
|
||||
var i = 1;
|
||||
var test1 = i.toString();
|
||||
var test2 = 2., toString = (); // emitted as 2 .toString()
|
||||
var test2 = 2., toString = ();
|
||||
var test3 = 3 .toString();
|
||||
var test4 = 3 .toString();
|
||||
var test5 = 3 .toString();
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
// Preserve whitespace where important for JS compatibility
|
||||
var i: number = 1;
|
||||
var test1 = i.toString();
|
||||
var test2 = 2.toString(); // emitted as 2 .toString()
|
||||
var test2 = 2.toString();
|
||||
var test3 = 3 .toString();
|
||||
var test4 = 3 .toString();
|
||||
var test5 = 3 .toString();
|
||||
@@ -0,0 +1,18 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////export default class [|DefaultExportedClass|] {
|
||||
////}
|
||||
////
|
||||
////var x: [|DefaultExportedClass|];
|
||||
////
|
||||
////var y = new [|DefaultExportedClass|];
|
||||
|
||||
let ranges = test.ranges()
|
||||
for (let range of ranges) {
|
||||
goTo.position(range.start);
|
||||
|
||||
verify.referencesCountIs(ranges.length);
|
||||
for (let expectedReference of ranges) {
|
||||
verify.referencesAtPositionContains(expectedReference);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////export default function [|DefaultExportedFunction|]() {
|
||||
//// return [|DefaultExportedFunction|]
|
||||
////}
|
||||
////
|
||||
////var x: typeof [|DefaultExportedFunction|];
|
||||
////
|
||||
////var y = [|DefaultExportedFunction|]();
|
||||
|
||||
let ranges = test.ranges()
|
||||
for (let range of ranges) {
|
||||
goTo.position(range.start);
|
||||
|
||||
verify.referencesCountIs(ranges.length);
|
||||
for (let expectedReference of ranges) {
|
||||
verify.referencesAtPositionContains(expectedReference);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////function [|f|]() {
|
||||
//// return 100;
|
||||
////}
|
||||
////
|
||||
////export default [|f|];
|
||||
////
|
||||
////var x: typeof [|f|];
|
||||
////
|
||||
////var y = [|f|]();
|
||||
////
|
||||
////namespace [|f|] {
|
||||
//// var local = 100;
|
||||
////}
|
||||
|
||||
let ranges = test.ranges()
|
||||
for (let range of ranges) {
|
||||
goTo.position(range.start);
|
||||
|
||||
verify.referencesCountIs(ranges.length);
|
||||
for (let expectedReference of ranges) {
|
||||
verify.referencesAtPositionContains(expectedReference);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////function f() {
|
||||
//// return 100;
|
||||
////}
|
||||
////
|
||||
////export default [|f|];
|
||||
////
|
||||
////var x: typeof f;
|
||||
////
|
||||
////var y = f();
|
||||
////
|
||||
////namespace /**/[|f|] {
|
||||
////}
|
||||
|
||||
// The function 'f' and the namespace 'f' don't get merged,
|
||||
// but the 'export default' site, includes both meanings.
|
||||
|
||||
// Here we are testing whether the 'export default'
|
||||
// site is included in the references to the namespace.
|
||||
|
||||
goTo.marker();
|
||||
let ranges = test.ranges();
|
||||
verify.referencesCountIs(ranges.length);
|
||||
|
||||
for (let expectedReference of ranges) {
|
||||
verify.referencesAtPositionContains(expectedReference);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////function /**/[|f|]() {
|
||||
//// return 100;
|
||||
////}
|
||||
////
|
||||
////export default [|f|];
|
||||
////
|
||||
////var x: typeof [|f|];
|
||||
////
|
||||
////var y = [|f|]();
|
||||
////
|
||||
////namespace f {
|
||||
////}
|
||||
|
||||
// The function 'f' and the namespace 'f' don't get merged,
|
||||
// but the 'export default' site, includes both meanings.
|
||||
|
||||
// Here we are testing whether the 'export default' site
|
||||
// and all value-uses of 'f' are included in the references to the function.
|
||||
|
||||
goTo.marker();
|
||||
let ranges = test.ranges();
|
||||
verify.referencesCountIs(ranges.length);
|
||||
|
||||
for (let expectedReference of ranges) {
|
||||
verify.referencesAtPositionContains(expectedReference);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////function [|f|]() {
|
||||
//// return 100;
|
||||
////}
|
||||
////
|
||||
////export default /**/[|f|];
|
||||
////
|
||||
////var x: typeof [|f|];
|
||||
////
|
||||
////var y = [|f|]();
|
||||
////
|
||||
////namespace [|f|] {
|
||||
////}
|
||||
|
||||
// The function 'f' and the namespace 'f' don't get merged,
|
||||
// but the 'export default' site, includes both meanings.
|
||||
|
||||
// Here we are testing whether the 'export default' site
|
||||
// and all value-uses of 'f' are included in the references to the function.
|
||||
|
||||
goTo.marker();
|
||||
let ranges = test.ranges();
|
||||
verify.referencesCountIs(ranges.length);
|
||||
|
||||
for (let expectedReference of ranges) {
|
||||
verify.referencesAtPositionContains(expectedReference);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////export default function DefaultExportedFunction() {
|
||||
//// return DefaultExportedFunction
|
||||
////}
|
||||
////
|
||||
////var x: typeof DefaultExportedFunction;
|
||||
////
|
||||
////var y = DefaultExportedFunction();
|
||||
////
|
||||
////namespace /**/DefaultExportedFunction {
|
||||
////}
|
||||
|
||||
// The namespace and function do not merge,
|
||||
// so the namespace should be all alone.
|
||||
|
||||
goTo.marker();
|
||||
verify.referencesCountIs(1);
|
||||
@@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////export default class DefaultExportedClass {
|
||||
////}
|
||||
////
|
||||
////var x: DefaultExportedClass;
|
||||
////
|
||||
////var y = new DefaultExportedClass;
|
||||
////
|
||||
////namespace /**/DefaultExportedClass {
|
||||
////}
|
||||
|
||||
// The namespace and class do not merge,
|
||||
// so the namespace should be all alone.
|
||||
|
||||
goTo.marker();
|
||||
verify.referencesCountIs(1);
|
||||
@@ -0,0 +1,21 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: file1.ts
|
||||
////var foo = function [|foo|](a = [|foo|](), b = () => [|foo|]) {
|
||||
//// [|foo|]([|foo|], [|foo|]);
|
||||
////}
|
||||
|
||||
// @Filename: file2.ts
|
||||
/////// <reference path="file1.ts" />
|
||||
////foo();
|
||||
|
||||
|
||||
let ranges = test.ranges()
|
||||
for (let range of ranges) {
|
||||
goTo.position(range.start);
|
||||
|
||||
verify.referencesCountIs(ranges.length);
|
||||
for (let expectedReference of ranges) {
|
||||
verify.referencesAtPositionContains(expectedReference);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////module Foo {
|
||||
/////*1*/ export default class Test { }
|
||||
////}
|
||||
/////*2*/export default function bar() { }
|
||||
|
||||
format.document();
|
||||
goTo.marker("1");
|
||||
verify.currentLineContentIs(" export default class Test { }")
|
||||
goTo.marker("2");
|
||||
verify.currentLineContentIs("export default function bar() { }")
|
||||
@@ -0,0 +1,18 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////export default class /*1*/[|DefaultExportedClass|] {
|
||||
////}
|
||||
/////*
|
||||
//// * Commenting [|DefaultExportedClass|]
|
||||
//// */
|
||||
////
|
||||
////var x: /*2*/[|DefaultExportedClass|];
|
||||
////
|
||||
////var y = new /*3*/[|DefaultExportedClass|];
|
||||
|
||||
let markers = test.markers()
|
||||
for (let marker of markers) {
|
||||
goTo.position(marker.position);
|
||||
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////export default function /*1*/[|DefaultExportedFunction|]() {
|
||||
//// return /*2*/[|DefaultExportedFunction|]
|
||||
////}
|
||||
/////**
|
||||
//// * Commenting [|DefaultExportedFunction|]
|
||||
//// */
|
||||
////
|
||||
////var x: typeof /*3*/[|DefaultExportedFunction|];
|
||||
////
|
||||
////var y = /*4*/[|DefaultExportedFunction|]();
|
||||
|
||||
let markers = test.markers()
|
||||
for (let marker of markers) {
|
||||
goTo.position(marker.position);
|
||||
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////function /*1*/[|f|]() {
|
||||
//// return 100;
|
||||
////}
|
||||
////
|
||||
////export default /*2*/[|f|];
|
||||
////
|
||||
////var x: typeof /*3*/[|f|];
|
||||
////
|
||||
////var y = /*4*/[|f|]();
|
||||
////
|
||||
/////**
|
||||
//// * Commenting [|f|]
|
||||
//// */
|
||||
////namespace /*5*/[|f|] {
|
||||
//// var local = 100;
|
||||
////}
|
||||
|
||||
let markers = test.markers()
|
||||
for (let marker of markers) {
|
||||
goTo.position(marker.position);
|
||||
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ true);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: foo.ts
|
||||
////export default class /**/[|DefaultExportedClass|] {
|
||||
////}
|
||||
/////*
|
||||
//// * Commenting DefaultExportedClass
|
||||
//// */
|
||||
////
|
||||
////var x: DefaultExportedClass;
|
||||
////
|
||||
////var y = new DefaultExportedClass;
|
||||
|
||||
goTo.marker();
|
||||
verify.renameInfoSucceeded("DefaultExportedClass", '"tests/cases/fourslash/foo".DefaultExportedClass');
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: foo.ts
|
||||
////export default class DefaultExportedClass {
|
||||
////}
|
||||
/////*
|
||||
//// * Commenting DefaultExportedClass
|
||||
//// */
|
||||
////
|
||||
////var x: /**/[|DefaultExportedClass|];
|
||||
////
|
||||
////var y = new DefaultExportedClass;
|
||||
|
||||
goTo.marker();
|
||||
verify.renameInfoSucceeded("DefaultExportedClass", '"tests/cases/fourslash/foo".DefaultExportedClass');
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: foo.ts
|
||||
////export default class DefaultExportedClass {
|
||||
////}
|
||||
/////*
|
||||
//// * Commenting DefaultExportedClass
|
||||
//// */
|
||||
////
|
||||
////var x: DefaultExportedClass;
|
||||
////
|
||||
////var y = new /**/[|DefaultExportedClass|];
|
||||
|
||||
goTo.marker();
|
||||
verify.renameInfoSucceeded("DefaultExportedClass", '"tests/cases/fourslash/foo".DefaultExportedClass');
|
||||
@@ -0,0 +1,16 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: foo.ts
|
||||
////export default function /**/[|DefaultExportedFunction|]() {
|
||||
//// return DefaultExportedFunction
|
||||
////}
|
||||
/////**
|
||||
//// * Commenting DefaultExportedFunction
|
||||
//// */
|
||||
////
|
||||
////var x: typeof DefaultExportedFunction;
|
||||
////
|
||||
////var y = DefaultExportedFunction();
|
||||
|
||||
goTo.marker();
|
||||
verify.renameInfoSucceeded("DefaultExportedFunction", '"tests/cases/fourslash/foo".DefaultExportedFunction');
|
||||
@@ -0,0 +1,16 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: foo.ts
|
||||
////export default function DefaultExportedFunction() {
|
||||
//// return /**/[|DefaultExportedFunction|]
|
||||
////}
|
||||
/////**
|
||||
//// * Commenting DefaultExportedFunction
|
||||
//// */
|
||||
////
|
||||
////var x: typeof DefaultExportedFunction;
|
||||
////
|
||||
////var y = DefaultExportedFunction();
|
||||
|
||||
goTo.marker();
|
||||
verify.renameInfoSucceeded("DefaultExportedFunction", '"tests/cases/fourslash/foo".DefaultExportedFunction');
|
||||
@@ -0,0 +1,22 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @Filename: foo.ts
|
||||
////function /**/[|f|]() {
|
||||
//// return 100;
|
||||
////}
|
||||
////
|
||||
////export default f;
|
||||
////
|
||||
////var x: typeof f;
|
||||
////
|
||||
////var y = f();
|
||||
////
|
||||
/////**
|
||||
//// * Commenting f
|
||||
//// */
|
||||
////namespace f {
|
||||
//// var local = 100;
|
||||
////}
|
||||
|
||||
goTo.marker();
|
||||
verify.renameInfoSucceeded("f", "f");
|
||||
@@ -0,0 +1,8 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////var x = function /**/[|f|](g: any, h: any) {
|
||||
//// f(f, g);
|
||||
////}
|
||||
|
||||
goTo.marker();
|
||||
verify.renameInfoSucceeded("f");
|
||||
@@ -0,0 +1,34 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////class Foo {
|
||||
////}
|
||||
////
|
||||
////var x = class /**/Foo {
|
||||
//// doIt() {
|
||||
//// return Foo;
|
||||
//// }
|
||||
////
|
||||
//// static doItStatically() {
|
||||
//// return Foo;
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////var y = class {
|
||||
//// getSomeName() {
|
||||
//// return Foo
|
||||
//// }
|
||||
////}
|
||||
|
||||
|
||||
// TODO (yuit): Fix up this test when class expressions are supported.
|
||||
// Just uncomment the below, remove the marker, and add the
|
||||
// appropriate ranges in the test itself.
|
||||
goTo.marker();
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
|
||||
////let ranges = test.ranges()
|
||||
////for (let range of ranges) {
|
||||
//// goTo.position(range.start);
|
||||
////
|
||||
//// verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
////}
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////var x = function [|f|](g: any, h: any) {
|
||||
//// [|f|]([|f|], g);
|
||||
////}
|
||||
|
||||
let ranges = test.ranges()
|
||||
for (let range of ranges) {
|
||||
goTo.position(range.start);
|
||||
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////function f() {
|
||||
////
|
||||
////}
|
||||
////var x = function [|f|](g: any, h: any) {
|
||||
////
|
||||
//// let helper = function f(): any { f(); }
|
||||
////
|
||||
//// let foo = () => [|f|]([|f|], g);
|
||||
////}
|
||||
|
||||
let ranges = test.ranges()
|
||||
for (let range of ranges) {
|
||||
goTo.position(range.start);
|
||||
|
||||
verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false);
|
||||
}
|
||||
Reference in New Issue
Block a user