Merge remote-tracking branch 'origin/master' into import_completions_pr

This commit is contained in:
Richard Knoll
2016-09-06 11:04:39 -07:00
119 changed files with 7092 additions and 1576 deletions
+1
View File
@@ -102,6 +102,7 @@ var servicesSources = [
"services.ts",
"shims.ts",
"signatureHelp.ts",
"types.ts",
"utilities.ts",
"formatting/formatting.ts",
"formatting/formattingContext.ts",
+6 -5
View File
@@ -146,6 +146,7 @@ namespace ts {
const anySignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
const unknownSignature = createSignature(undefined, undefined, undefined, emptyArray, unknownType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
const resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false);
const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true);
@@ -5381,7 +5382,7 @@ namespace ts {
while (i > 0) {
i--;
if (isSubtypeOfAny(types[i], types)) {
types.splice(i, 1);
orderedRemoveItemAt(types, i);
}
}
}
@@ -8761,7 +8762,7 @@ namespace ts {
// The location isn't a reference to the given symbol, meaning we're being asked
// a hypothetical question of what type the symbol would have if there was a reference
// to it at the given location. Since we have no control flow information for the
// hypotherical reference (control flow information is created and attached by the
// hypothetical reference (control flow information is created and attached by the
// binder), we simply return the declared type of the symbol.
return getTypeOfSymbol(symbol);
}
@@ -12232,10 +12233,10 @@ namespace ts {
// or that a different candidatesOutArray was passed in. Therefore, we need to redo the work
// to correctly fill the candidatesOutArray.
const cached = links.resolvedSignature;
if (cached && cached !== anySignature && !candidatesOutArray) {
if (cached && cached !== resolvingSignature && !candidatesOutArray) {
return cached;
}
links.resolvedSignature = anySignature;
links.resolvedSignature = resolvingSignature;
const result = resolveSignature(node, candidatesOutArray);
// If signature resolution originated in control flow type analysis (for example to compute the
// assigned type in a flow assignment) we don't cache the result as it may be based on temporary
@@ -12247,7 +12248,7 @@ namespace ts {
function getResolvedOrAnySignature(node: CallLikeExpression) {
// If we're already in the process of resolving the given signature, don't resolve again as
// that could cause infinite recursion. Instead, return anySignature.
return getNodeLinks(node).resolvedSignature === anySignature ? anySignature : getResolvedSignature(node);
return getNodeLinks(node).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(node);
}
function getInferredClassType(symbol: Symbol) {
+59 -10
View File
@@ -566,6 +566,36 @@ namespace ts {
return result;
}
/**
* Adds the value to an array of values associated with the key, and returns the array.
* Creates the array if it does not already exist.
*/
export function multiMapAdd<V>(map: Map<V[]>, key: string, value: V): V[] {
const values = map[key];
if (values) {
values.push(value);
return values;
}
else {
return map[key] = [value];
}
}
/**
* Removes a value from an array of values associated with the key.
* Does not preserve the order of those values.
* Does nothing if `key` is not in `map`, or `value` is not in `map[key]`.
*/
export function multiMapRemove<V>(map: Map<V[]>, key: string, value: V): void {
const values = map[key];
if (values) {
unorderedRemoveItem(values, value);
if (!values.length) {
delete map[key];
}
}
}
/**
* Tests whether a value is an array.
*/
@@ -1500,20 +1530,39 @@ namespace ts {
}
}
export function copyListRemovingItem<T>(item: T, list: T[]) {
const copiedList: T[] = [];
for (const e of list) {
if (e !== item) {
copiedList.push(e);
}
/** Remove an item from an array, moving everything to its right one space left. */
export function orderedRemoveItemAt<T>(array: T[], index: number): void {
// This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`.
for (let i = index; i < array.length - 1; i++) {
array[i] = array[i + 1];
}
return copiedList;
array.pop();
}
export function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string {
return useCaseSensitivefileNames
export function unorderedRemoveItemAt<T>(array: T[], index: number): void {
// Fill in the "hole" left at `index`.
array[index] = array[array.length - 1];
array.pop();
}
/** Remove the *first* occurrence of `item` from the array. */
export function unorderedRemoveItem<T>(array: T[], item: T): void {
unorderedRemoveFirstItemWhere(array, element => element === item);
}
/** Remove the *first* element satisfying `predicate`. */
function unorderedRemoveFirstItemWhere<T>(array: T[], predicate: (element: T) => boolean): void {
for (let i = 0; i < array.length; i++) {
if (predicate(array[i])) {
unorderedRemoveItemAt(array, i);
break;
}
}
}
export function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): (fileName: string) => string {
return useCaseSensitiveFileNames
? ((fileName) => fileName)
: ((fileName) => fileName.toLowerCase());
}
}
+1 -1
View File
@@ -6851,7 +6851,7 @@ const _super = (function (geti, seti) {
// export { x, y }
for (const specifier of (<ExportDeclaration>node).exportClause.elements) {
const name = (specifier.propertyName || specifier.name).text;
(exportSpecifiers[name] || (exportSpecifiers[name] = [])).push(specifier);
multiMapAdd(exportSpecifiers, name, specifier);
}
}
break;
+34 -7
View File
@@ -8,8 +8,6 @@ namespace ts {
const emptyArray: any[] = [];
const defaultTypeRoots = ["node_modules/@types"];
export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName = "tsconfig.json"): string {
while (true) {
const fileName = combinePaths(searchPath, configName);
@@ -168,22 +166,51 @@ namespace ts {
const typeReferenceExtensions = [".d.ts"];
export function getEffectiveTypeRoots(options: CompilerOptions, currentDirectory: string) {
export function getEffectiveTypeRoots(options: CompilerOptions, host: { directoryExists?: (directoryName: string) => boolean, getCurrentDirectory?: () => string }): string[] | undefined {
if (options.typeRoots) {
return options.typeRoots;
}
let currentDirectory: string;
if (options.configFilePath) {
currentDirectory = getDirectoryPath(options.configFilePath);
}
if (!currentDirectory) {
return undefined;
else if (host.getCurrentDirectory) {
currentDirectory = host.getCurrentDirectory();
}
return map(defaultTypeRoots, d => combinePaths(currentDirectory, d));
return currentDirectory && getDefaultTypeRoots(currentDirectory, host);
}
/**
* Returns the path to every node_modules/@types directory from some ancestor directory.
* Returns undefined if there are none.
*/
function getDefaultTypeRoots(currentDirectory: string, host: { directoryExists?: (directoryName: string) => boolean }): string[] | undefined {
if (!host.directoryExists) {
return [combinePaths(currentDirectory, nodeModulesAtTypes)];
// And if it doesn't exist, tough.
}
let typeRoots: string[];
while (true) {
const atTypes = combinePaths(currentDirectory, nodeModulesAtTypes);
if (host.directoryExists(atTypes)) {
(typeRoots || (typeRoots = [])).push(atTypes);
}
const parent = getDirectoryPath(currentDirectory);
if (parent === currentDirectory) {
break;
}
currentDirectory = parent;
}
return typeRoots;
}
const nodeModulesAtTypes = combinePaths("node_modules", "@types");
/**
* @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
+2 -11
View File
@@ -267,7 +267,7 @@ namespace ts {
}
function addFileWatcherCallback(filePath: string, callback: FileWatcherCallback): void {
(fileWatcherCallbacks[filePath] || (fileWatcherCallbacks[filePath] = [])).push(callback);
multiMapAdd(fileWatcherCallbacks, filePath, callback);
}
function addFile(fileName: string, callback: FileWatcherCallback): WatchedFile {
@@ -283,16 +283,7 @@ namespace ts {
}
function removeFileWatcherCallback(filePath: string, callback: FileWatcherCallback) {
const callbacks = fileWatcherCallbacks[filePath];
if (callbacks) {
const newCallbacks = copyListRemovingItem(callback, callbacks);
if (newCallbacks.length === 0) {
delete fileWatcherCallbacks[filePath];
}
else {
fileWatcherCallbacks[filePath] = newCallbacks;
}
}
multiMapRemove(fileWatcherCallbacks, filePath, callback);
}
function fileEventHandler(eventName: string, relativeFileName: string, baseDirPath: string) {
+1 -4
View File
@@ -489,10 +489,7 @@ namespace ts {
sourceFile.fileWatcher.close();
sourceFile.fileWatcher = undefined;
if (removed) {
const index = rootFileNames.indexOf(sourceFile.fileName);
if (index >= 0) {
rootFileNames.splice(index, 1);
}
unorderedRemoveItem(rootFileNames, sourceFile.fileName);
}
startTimerForRecompilation();
}
+22 -3
View File
@@ -1035,6 +1035,18 @@ namespace ts {
return undefined;
}
export function isCallLikeExpression(node: Node): node is CallLikeExpression {
switch (node.kind) {
case SyntaxKind.CallExpression:
case SyntaxKind.NewExpression:
case SyntaxKind.TaggedTemplateExpression:
case SyntaxKind.Decorator:
return true;
default:
return false;
}
}
export function getInvokedExpression(node: CallLikeExpression): Expression {
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
return (<TaggedTemplateExpression>node).tag;
@@ -2659,10 +2671,17 @@ namespace ts {
return token >= SyntaxKind.FirstAssignment && token <= SyntaxKind.LastAssignment;
}
export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean {
return node.kind === SyntaxKind.ExpressionWithTypeArguments &&
/** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */
export function tryGetClassExtendingExpressionWithTypeArguments(node: Node): ClassLikeDeclaration | undefined {
if (node.kind === SyntaxKind.ExpressionWithTypeArguments &&
(<HeritageClause>node.parent).token === SyntaxKind.ExtendsKeyword &&
isClassLike(node.parent.parent);
isClassLike(node.parent.parent)) {
return node.parent.parent;
}
}
export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean {
return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined;
}
export function isEntityNameExpression(node: Expression): node is EntityNameExpression {
+93 -65
View File
@@ -543,6 +543,67 @@ namespace FourSlash {
}
}
public verifyGoToDefinitionIs(endMarker: string | string[]) {
this.verifyGoToDefinitionWorker(endMarker instanceof Array ? endMarker : [endMarker]);
}
public verifyGoToDefinition(arg0: any, endMarkerNames?: string | string[]) {
if (endMarkerNames) {
this.verifyGoToDefinitionPlain(arg0, endMarkerNames);
}
else if (arg0 instanceof Array) {
const pairs: [string | string[], string | string[]][] = arg0;
for (const [start, end] of pairs) {
this.verifyGoToDefinitionPlain(start, end);
}
}
else {
const obj: { [startMarkerName: string]: string | string[] } = arg0;
for (const startMarkerName in obj) {
if (ts.hasProperty(obj, startMarkerName)) {
this.verifyGoToDefinitionPlain(startMarkerName, obj[startMarkerName]);
}
}
}
}
private verifyGoToDefinitionPlain(startMarkerNames: string | string[], endMarkerNames: string | string[]) {
if (startMarkerNames instanceof Array) {
for (const start of startMarkerNames) {
this.verifyGoToDefinitionSingle(start, endMarkerNames);
}
}
else {
this.verifyGoToDefinitionSingle(startMarkerNames, endMarkerNames);
}
}
public verifyGoToDefinitionForMarkers(markerNames: string[]) {
for (const markerName of markerNames) {
this.verifyGoToDefinitionSingle(`${markerName}Reference`, `${markerName}Definition`);
}
}
private verifyGoToDefinitionSingle(startMarkerName: string, endMarkerNames: string | string[]) {
this.goToMarker(startMarkerName);
this.verifyGoToDefinitionWorker(endMarkerNames instanceof Array ? endMarkerNames : [endMarkerNames]);
}
private verifyGoToDefinitionWorker(endMarkers: string[]) {
const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition) || [];
if (endMarkers.length !== definitions.length) {
this.raiseError(`goToDefinitions failed - expected to find ${endMarkers.length} definitions but got ${definitions.length}`);
}
for (let i = 0; i < endMarkers.length; i++) {
const marker = this.getMarkerByName(endMarkers[i]), definition = definitions[i];
if (marker.fileName !== definition.fileName || marker.position !== definition.textSpan.start) {
this.raiseError(`goToDefinition failed for definition ${i}: expected ${marker.fileName} at ${marker.position}, got ${definition.fileName} at ${definition.textSpan.start}`);
}
}
}
public verifyGetEmitOutputForCurrentFile(expected: string): void {
const emit = this.languageService.getEmitOutput(this.activeFile.fileName);
if (emit.outputFiles.length !== 1) {
@@ -1590,25 +1651,10 @@ namespace FourSlash {
this.goToPosition(len);
}
public goToDefinition(definitionIndex: number) {
const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
if (!definitions || !definitions.length) {
this.raiseError("goToDefinition failed - expected to at least one definition location but got 0");
}
if (definitionIndex >= definitions.length) {
this.raiseError(`goToDefinition failed - definitionIndex value (${definitionIndex}) exceeds definition list size (${definitions.length})`);
}
const definition = definitions[definitionIndex];
this.openFile(definition.fileName);
this.currentCaretPosition = definition.textSpan.start;
}
public goToTypeDefinition(definitionIndex: number) {
const definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
if (!definitions || !definitions.length) {
this.raiseError("goToTypeDefinition failed - expected to at least one definition location but got 0");
this.raiseError("goToTypeDefinition failed - expected to find at least one definition location but got 0");
}
if (definitionIndex >= definitions.length) {
@@ -1620,28 +1666,6 @@ namespace FourSlash {
this.currentCaretPosition = definition.textSpan.start;
}
public verifyDefinitionLocationExists(negative: boolean) {
const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
const foundDefinitions = definitions && definitions.length;
if (foundDefinitions && negative) {
this.raiseError(`goToDefinition - expected to 0 definition locations but got ${definitions.length}`);
}
else if (!foundDefinitions && !negative) {
this.raiseError("goToDefinition - expected to at least one definition location but got 0");
}
}
public verifyDefinitionsCount(negative: boolean, expectedCount: number) {
const assertFn = negative ? assert.notEqual : assert.equal;
const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
const actualCount = definitions && definitions.length || 0;
assertFn(actualCount, expectedCount, this.messageAtLastKnownMarker("Definitions Count"));
}
public verifyTypeDefinitionsCount(negative: boolean, expectedCount: number) {
const assertFn = negative ? assert.notEqual : assert.equal;
@@ -1651,18 +1675,12 @@ namespace FourSlash {
assertFn(actualCount, expectedCount, this.messageAtLastKnownMarker("Type definitions Count"));
}
public verifyDefinitionsName(negative: boolean, expectedName: string, expectedContainerName: string) {
public verifyGoToDefinitionName(expectedName: string, expectedContainerName: string) {
const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
const actualDefinitionName = definitions && definitions.length ? definitions[0].name : "";
const actualDefinitionContainerName = definitions && definitions.length ? definitions[0].containerName : "";
if (negative) {
assert.notEqual(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Name"));
assert.notEqual(actualDefinitionContainerName, expectedContainerName, this.messageAtLastKnownMarker("Definition Info Container Name"));
}
else {
assert.equal(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Name"));
assert.equal(actualDefinitionContainerName, expectedContainerName, this.messageAtLastKnownMarker("Definition Info Container Name"));
}
assert.equal(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Name"));
assert.equal(actualDefinitionContainerName, expectedContainerName, this.messageAtLastKnownMarker("Definition Info Container Name"));
}
public getMarkers(): Marker[] {
@@ -1670,6 +1688,10 @@ namespace FourSlash {
return this.testData.markers.slice(0);
}
public getMarkerNames(): string[] {
return Object.keys(this.testData.markerPositions);
}
public getRanges(): Range[] {
return this.testData.ranges;
}
@@ -1678,8 +1700,7 @@ namespace FourSlash {
const result = ts.createMap<Range[]>();
for (const range of this.getRanges()) {
const text = this.rangeText(range);
const ranges = result[text] || (result[text] = []);
ranges.push(range);
ts.multiMapAdd(result, text, range);
}
return result;
}
@@ -2796,6 +2817,10 @@ namespace FourSlashInterface {
return this.state.getMarkers();
}
public markerNames(): string[] {
return this.state.getMarkerNames();
}
public marker(name?: string): FourSlash.Marker {
return this.state.getMarkerByName(name);
}
@@ -2831,10 +2856,6 @@ namespace FourSlashInterface {
this.state.goToEOF();
}
public definition(definitionIndex = 0) {
this.state.goToDefinition(definitionIndex);
}
public type(definitionIndex = 0) {
this.state.goToTypeDefinition(definitionIndex);
}
@@ -2939,22 +2960,10 @@ namespace FourSlashInterface {
this.state.verifyQuickInfoExists(this.negative);
}
public definitionCountIs(expectedCount: number) {
this.state.verifyDefinitionsCount(this.negative, expectedCount);
}
public typeDefinitionCountIs(expectedCount: number) {
this.state.verifyTypeDefinitionsCount(this.negative, expectedCount);
}
public definitionLocationExists() {
this.state.verifyDefinitionLocationExists(this.negative);
}
public verifyDefinitionsName(name: string, containerName: string) {
this.state.verifyDefinitionsName(this.negative, name, containerName);
}
public isValidBraceCompletionAtPosition(openingBrace: string) {
this.state.verifyBraceCompletionAtPosition(this.negative, openingBrace);
}
@@ -2998,6 +3007,25 @@ namespace FourSlashInterface {
this.state.verifyCurrentFileContent(text);
}
public goToDefinitionIs(endMarkers: string | string[]) {
this.state.verifyGoToDefinitionIs(endMarkers);
}
public goToDefinition(startMarkerName: string | string[], endMarkerName: string | string[]): void;
public goToDefinition(startsAndEnds: [string | string[], string | string[]][]): void;
public goToDefinition(startsAndEnds: { [startMarkerName: string]: string | string[] }): void;
public goToDefinition(arg0: any, endMarkerName?: string | string[]) {
this.state.verifyGoToDefinition(arg0, endMarkerName);
}
public goToDefinitionForMarkers(...markerNames: string[]) {
this.state.verifyGoToDefinitionForMarkers(markerNames);
}
public goToDefinitionName(name: string, containerName: string) {
this.state.verifyGoToDefinitionName(name, containerName);
}
public verifyGetEmitOutputForCurrentFile(expected: string): void {
this.state.verifyGetEmitOutputForCurrentFile(expected);
}
+1 -1
View File
@@ -1788,7 +1788,7 @@ namespace Harness {
tsConfig.options.configFilePath = data.name;
// delete entry from the list
testUnitData.splice(i, 1);
ts.orderedRemoveItemAt(testUnitData, i);
break;
}
+6 -25
View File
@@ -198,22 +198,12 @@ namespace ts {
watchDirectory(directoryName: string, callback: DirectoryWatcherCallback, recursive: boolean): DirectoryWatcher {
const path = this.toPath(directoryName);
const callbacks = this.watchedDirectories[path] || (this.watchedDirectories[path] = []);
callbacks.push({ cb: callback, recursive });
const cbWithRecursive = { cb: callback, recursive };
multiMapAdd(this.watchedDirectories, path, cbWithRecursive);
return {
referenceCount: 0,
directoryName,
close: () => {
for (let i = 0; i < callbacks.length; i++) {
if (callbacks[i].cb === callback) {
callbacks.splice(i, 1);
break;
}
}
if (!callbacks.length) {
delete this.watchedDirectories[path];
}
}
close: () => multiMapRemove(this.watchedDirectories, path, cbWithRecursive)
};
}
@@ -239,17 +229,8 @@ namespace ts {
watchFile(fileName: string, callback: FileWatcherCallback) {
const path = this.toPath(fileName);
const callbacks = this.watchedFiles[path] || (this.watchedFiles[path] = []);
callbacks.push(callback);
return {
close: () => {
const i = callbacks.indexOf(callback);
callbacks.splice(i, 1);
if (!callbacks.length) {
delete this.watchedFiles[path];
}
}
};
multiMapAdd(this.watchedFiles, path, callback);
return { close: () => multiMapRemove(this.watchedFiles, path, callback) };
}
// TOOD: record and invoke callbacks to simulate timer events
@@ -259,7 +240,7 @@ namespace ts {
};
readonly clearTimeout = (timeoutId: any): void => {
if (typeof timeoutId === "number") {
this.callbackQueue.splice(timeoutId, 1);
orderedRemoveItemAt(this.callbackQueue, timeoutId);
}
};
+6 -16
View File
@@ -275,7 +275,7 @@ namespace ts.server {
removeRoot(info: ScriptInfo) {
if (this.filenameToScript.contains(info.path)) {
this.filenameToScript.remove(info.path);
this.roots = copyListRemovingItem(info, this.roots);
unorderedRemoveItem(this.roots, info);
this.resolvedModuleNames.remove(info.path);
this.resolvedTypeReferenceDirectives.remove(info.path);
}
@@ -588,16 +588,6 @@ namespace ts.server {
project?: Project;
}
function copyListRemovingItem<T>(item: T, list: T[]) {
const copiedList: T[] = [];
for (let i = 0, len = list.length; i < len; i++) {
if (list[i] != item) {
copiedList.push(list[i]);
}
}
return copiedList;
}
/**
* This helper funciton processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project.
*/
@@ -883,7 +873,7 @@ namespace ts.server {
project.directoryWatcher.close();
forEachProperty(project.directoriesWatchedForWildcards, watcher => { watcher.close(); });
delete project.directoriesWatchedForWildcards;
this.configuredProjects = copyListRemovingItem(project, this.configuredProjects);
unorderedRemoveItem(this.configuredProjects, project);
}
else {
for (const directory of project.directoriesWatchedForTsconfig) {
@@ -895,7 +885,7 @@ namespace ts.server {
delete project.projectService.directoryWatchersForTsconfig[directory];
}
}
this.inferredProjects = copyListRemovingItem(project, this.inferredProjects);
unorderedRemoveItem(this.inferredProjects, project);
}
const fileNames = project.getFileNames();
@@ -1020,7 +1010,7 @@ namespace ts.server {
}
}
else {
this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced);
unorderedRemoveItem(this.openFilesReferenced, info);
}
info.close();
}
@@ -1527,13 +1517,13 @@ namespace ts.server {
// openFileRoots or openFileReferenced.
if (info.isOpen) {
if (this.openFileRoots.indexOf(info) >= 0) {
this.openFileRoots = copyListRemovingItem(info, this.openFileRoots);
unorderedRemoveItem(this.openFileRoots, info);
if (info.defaultProject && !info.defaultProject.isConfiguredProject()) {
this.removeProject(info.defaultProject);
}
}
if (this.openFilesReferenced.indexOf(info) >= 0) {
this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced);
unorderedRemoveItem(this.openFilesReferenced, info);
}
this.openFileRootsConfigured.push(info);
info.defaultProject = project;
+2 -2
View File
@@ -204,7 +204,7 @@ namespace ts.server {
// average async stat takes about 30 microseconds
// set chunk size to do 30 files in < 1 millisecond
function createPollingWatchedFileSet(interval = 2500, chunkSize = 30) {
let watchedFiles: WatchedFile[] = [];
const watchedFiles: WatchedFile[] = [];
let nextFileToCheck = 0;
let watchTimer: any;
@@ -267,7 +267,7 @@ namespace ts.server {
}
function removeFile(file: WatchedFile) {
watchedFiles = copyListRemovingItem(file, watchedFiles);
unorderedRemoveItem(watchedFiles, file);
}
return {
+1
View File
@@ -466,6 +466,7 @@ namespace ts.NavigationBar {
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.VariableDeclaration:
return hasSomeImportantChild(item);
case SyntaxKind.ArrowFunction:
+163 -850
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -35,6 +35,7 @@
"services.ts",
"shims.ts",
"signatureHelp.ts",
"types.ts",
"utilities.ts",
"jsTyping.ts",
"formatting/formatting.ts",
+829
View File
@@ -0,0 +1,829 @@
namespace ts {
export interface Node {
getSourceFile(): SourceFile;
getChildCount(sourceFile?: SourceFile): number;
getChildAt(index: number, sourceFile?: SourceFile): Node;
getChildren(sourceFile?: SourceFile): Node[];
getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number;
getFullStart(): number;
getEnd(): number;
getWidth(sourceFile?: SourceFile): number;
getFullWidth(): number;
getLeadingTriviaWidth(sourceFile?: SourceFile): number;
getFullText(sourceFile?: SourceFile): string;
getText(sourceFile?: SourceFile): string;
getFirstToken(sourceFile?: SourceFile): Node;
getLastToken(sourceFile?: SourceFile): Node;
}
export interface Symbol {
getFlags(): SymbolFlags;
getName(): string;
getDeclarations(): Declaration[];
getDocumentationComment(): SymbolDisplayPart[];
}
export interface Type {
getFlags(): TypeFlags;
getSymbol(): Symbol;
getProperties(): Symbol[];
getProperty(propertyName: string): Symbol;
getApparentProperties(): Symbol[];
getCallSignatures(): Signature[];
getConstructSignatures(): Signature[];
getStringIndexType(): Type;
getNumberIndexType(): Type;
getBaseTypes(): ObjectType[];
getNonNullableType(): Type;
}
export interface Signature {
getDeclaration(): SignatureDeclaration;
getTypeParameters(): Type[];
getParameters(): Symbol[];
getReturnType(): Type;
getDocumentationComment(): SymbolDisplayPart[];
}
export interface SourceFile {
/* @internal */ version: string;
/* @internal */ scriptSnapshot: IScriptSnapshot;
/* @internal */ nameTable: Map<number>;
/* @internal */ getNamedDeclarations(): Map<Declaration[]>;
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
getLineStarts(): number[];
getPositionOfLineAndCharacter(line: number, character: number): number;
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
}
/**
* Represents an immutable snapshot of a script at a specified time.Once acquired, the
* snapshot is observably immutable. i.e. the same calls with the same parameters will return
* the same values.
*/
export interface IScriptSnapshot {
/** Gets a portion of the script snapshot specified by [start, end). */
getText(start: number, end: number): string;
/** Gets the length of this script snapshot. */
getLength(): number;
/**
* Gets the TextChangeRange that describe how the text changed between this text and
* an older version. This information is used by the incremental parser to determine
* what sections of the script need to be re-parsed. 'undefined' can be returned if the
* change range cannot be determined. However, in that case, incremental parsing will
* not happen and the entire document will be re - parsed.
*/
getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange | undefined;
/** Releases all resources held by this script snapshot */
dispose?(): void;
}
export namespace ScriptSnapshot {
class StringScriptSnapshot implements IScriptSnapshot {
constructor(private text: string) {
}
public getText(start: number, end: number): string {
return this.text.substring(start, end);
}
public getLength(): number {
return this.text.length;
}
public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange {
// Text-based snapshots do not support incremental parsing. Return undefined
// to signal that to the caller.
return undefined;
}
}
export function fromString(text: string): IScriptSnapshot {
return new StringScriptSnapshot(text);
}
}
export interface PreProcessedFileInfo {
referencedFiles: FileReference[];
typeReferenceDirectives: FileReference[];
importedFiles: FileReference[];
ambientExternalModules: string[];
isLibFile: boolean;
}
export interface HostCancellationToken {
isCancellationRequested(): boolean;
}
//
// Public interface of the host of a language service instance.
//
export interface LanguageServiceHost {
getCompilationSettings(): CompilerOptions;
getNewLine?(): string;
getProjectVersion?(): string;
getScriptFileNames(): string[];
getScriptKind?(fileName: string): ScriptKind;
getScriptVersion(fileName: string): string;
getScriptSnapshot(fileName: string): IScriptSnapshot | undefined;
getLocalizedDiagnosticMessages?(): any;
getCancellationToken?(): HostCancellationToken;
getCurrentDirectory(): string;
getDefaultLibFileName(options: CompilerOptions): string;
log?(s: string): void;
trace?(s: string): void;
error?(s: string): void;
useCaseSensitiveFileNames?(): boolean;
/*
* LS host can optionally implement these methods to support completions for module specifiers.
* Without these methods, only completions for ambient modules will be provided.
*/
readDirectory?(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[];
readFile?(path: string, encoding?: string): string;
fileExists?(path: string): boolean;
/*
* LS host can optionally implement this method if it wants to be completely in charge of module name resolution.
* if implementation is omitted then language service will use built-in module resolution logic and get answers to
* host specific questions using 'getScriptSnapshot'.
*/
resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[];
directoryExists?(directoryName: string): boolean;
/*
* getDirectories is also required for full import and type reference completions. Without it defined, certain
* completions will not be provided
*/
getDirectories?(directoryName: string): string[];
}
//
// Public services of a language service instance associated
// with a language service host instance
//
export interface LanguageService {
cleanupSemanticCache(): void;
getSyntacticDiagnostics(fileName: string): Diagnostic[];
getSemanticDiagnostics(fileName: string): Diagnostic[];
// TODO: Rename this to getProgramDiagnostics to better indicate that these are any
// diagnostics present for the program level, and not just 'options' diagnostics.
getCompilerOptionsDiagnostics(): Diagnostic[];
/**
* @deprecated Use getEncodedSyntacticClassifications instead.
*/
getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
/**
* @deprecated Use getEncodedSemanticClassifications instead.
*/
getSemanticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
// Encoded as triples of [start, length, ClassificationType].
getEncodedSyntacticClassifications(fileName: string, span: TextSpan): Classifications;
getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications;
getCompletionsAtPosition(fileName: string, position: number): CompletionInfo;
getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails;
getQuickInfoAtPosition(fileName: string, position: number): QuickInfo;
getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): TextSpan;
getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan;
getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems;
getRenameInfo(fileName: string, position: number): RenameInfo;
findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[];
getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[];
getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[];
findReferences(fileName: string, position: number): ReferencedSymbol[];
getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[];
/** @deprecated */
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[];
getNavigateToItems(searchValue: string, maxResultCount?: number): NavigateToItem[];
getNavigationBarItems(fileName: string): NavigationBarItem[];
getOutliningSpans(fileName: string): OutliningSpan[];
getTodoComments(fileName: string, descriptors: TodoCommentDescriptor[]): TodoComment[];
getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[];
getIndentationAtPosition(fileName: string, position: number, options: EditorOptions): number;
getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[];
getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[];
getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[];
getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion;
isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean;
getEmitOutput(fileName: string): EmitOutput;
getProgram(): Program;
/* @internal */ getNonBoundSourceFile(fileName: string): SourceFile;
dispose(): void;
}
export interface Classifications {
spans: number[];
endOfLineState: EndOfLineState;
}
export interface ClassifiedSpan {
textSpan: TextSpan;
classificationType: string; // ClassificationTypeNames
}
export interface NavigationBarItem {
text: string;
kind: string;
kindModifiers: string;
spans: TextSpan[];
childItems: NavigationBarItem[];
indent: number;
bolded: boolean;
grayed: boolean;
}
export interface TodoCommentDescriptor {
text: string;
priority: number;
}
export interface TodoComment {
descriptor: TodoCommentDescriptor;
message: string;
position: number;
}
export class TextChange {
span: TextSpan;
newText: string;
}
export interface TextInsertion {
newText: string;
/** The position in newText the caret should point to after the insertion. */
caretOffset: number;
}
export interface RenameLocation {
textSpan: TextSpan;
fileName: string;
}
export interface ReferenceEntry {
textSpan: TextSpan;
fileName: string;
isWriteAccess: boolean;
isDefinition: boolean;
}
export interface DocumentHighlights {
fileName: string;
highlightSpans: HighlightSpan[];
}
export namespace HighlightSpanKind {
export const none = "none";
export const definition = "definition";
export const reference = "reference";
export const writtenReference = "writtenReference";
}
export interface HighlightSpan {
fileName?: string;
textSpan: TextSpan;
kind: string;
}
export interface NavigateToItem {
name: string;
kind: string;
kindModifiers: string;
matchKind: string;
isCaseSensitive: boolean;
fileName: string;
textSpan: TextSpan;
containerName: string;
containerKind: string;
}
export interface EditorOptions {
BaseIndentSize?: number;
IndentSize: number;
TabSize: number;
NewLineCharacter: string;
ConvertTabsToSpaces: boolean;
IndentStyle: IndentStyle;
}
export enum IndentStyle {
None = 0,
Block = 1,
Smart = 2,
}
export interface FormatCodeOptions extends EditorOptions {
InsertSpaceAfterCommaDelimiter: boolean;
InsertSpaceAfterSemicolonInForStatements: boolean;
InsertSpaceBeforeAndAfterBinaryOperators: boolean;
InsertSpaceAfterKeywordsInControlFlowStatements: boolean;
InsertSpaceAfterFunctionKeywordForAnonymousFunctions: boolean;
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean;
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean;
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
PlaceOpenBraceOnNewLineForFunctions: boolean;
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
[s: string]: boolean | number | string | undefined;
}
export interface DefinitionInfo {
fileName: string;
textSpan: TextSpan;
kind: string;
name: string;
containerKind: string;
containerName: string;
}
export interface ReferencedSymbolDefinitionInfo extends DefinitionInfo {
displayParts: SymbolDisplayPart[];
}
export interface ReferencedSymbol {
definition: ReferencedSymbolDefinitionInfo;
references: ReferenceEntry[];
}
export enum SymbolDisplayPartKind {
aliasName,
className,
enumName,
fieldName,
interfaceName,
keyword,
lineBreak,
numericLiteral,
stringLiteral,
localName,
methodName,
moduleName,
operator,
parameterName,
propertyName,
punctuation,
space,
text,
typeParameterName,
enumMemberName,
functionName,
regularExpressionLiteral,
}
export interface SymbolDisplayPart {
text: string;
kind: string;
}
export interface QuickInfo {
kind: string;
kindModifiers: string;
textSpan: TextSpan;
displayParts: SymbolDisplayPart[];
documentation: SymbolDisplayPart[];
}
export interface RenameInfo {
canRename: boolean;
localizedErrorMessage: string;
displayName: string;
fullDisplayName: string;
kind: string;
kindModifiers: string;
triggerSpan: TextSpan;
}
export interface SignatureHelpParameter {
name: string;
documentation: SymbolDisplayPart[];
displayParts: SymbolDisplayPart[];
isOptional: boolean;
}
/**
* Represents a single signature to show in signature help.
* The id is used for subsequent calls into the language service to ask questions about the
* signature help item in the context of any documents that have been updated. i.e. after
* an edit has happened, while signature help is still active, the host can ask important
* questions like 'what parameter is the user currently contained within?'.
*/
export interface SignatureHelpItem {
isVariadic: boolean;
prefixDisplayParts: SymbolDisplayPart[];
suffixDisplayParts: SymbolDisplayPart[];
separatorDisplayParts: SymbolDisplayPart[];
parameters: SignatureHelpParameter[];
documentation: SymbolDisplayPart[];
}
/**
* Represents a set of signature help items, and the preferred item that should be selected.
*/
export interface SignatureHelpItems {
items: SignatureHelpItem[];
applicableSpan: TextSpan;
selectedItemIndex: number;
argumentIndex: number;
argumentCount: number;
}
export interface CompletionInfo {
isMemberCompletion: boolean;
isNewIdentifierLocation: boolean; // true when the current location also allows for a new identifier
entries: CompletionEntry[];
}
export interface CompletionEntry {
name: string;
kind: string; // see ScriptElementKind
kindModifiers: string; // see ScriptElementKindModifier, comma separated
sortText: string;
/**
* An optional span that indicates the text to be replaced by this completion item. It will be
* set if the required span differs from the one generated by the default replacement behavior and should
* be used in that case
*/
replacementSpan?: TextSpan;
}
export interface CompletionEntryDetails {
name: string;
kind: string; // see ScriptElementKind
kindModifiers: string; // see ScriptElementKindModifier, comma separated
displayParts: SymbolDisplayPart[];
documentation: SymbolDisplayPart[];
}
export interface OutliningSpan {
/** The span of the document to actually collapse. */
textSpan: TextSpan;
/** The span of the document to display when the user hovers over the collapsed span. */
hintSpan: TextSpan;
/** The text to display in the editor for the collapsed region. */
bannerText: string;
/**
* Whether or not this region should be automatically collapsed when
* the 'Collapse to Definitions' command is invoked.
*/
autoCollapse: boolean;
}
export interface EmitOutput {
outputFiles: OutputFile[];
emitSkipped: boolean;
}
export const enum OutputFileType {
JavaScript,
SourceMap,
Declaration
}
export interface OutputFile {
name: string;
writeByteOrderMark: boolean;
text: string;
}
export const enum EndOfLineState {
None,
InMultiLineCommentTrivia,
InSingleQuoteStringLiteral,
InDoubleQuoteStringLiteral,
InTemplateHeadOrNoSubstitutionTemplate,
InTemplateMiddleOrTail,
InTemplateSubstitutionPosition,
}
export enum TokenClass {
Punctuation,
Keyword,
Operator,
Comment,
Whitespace,
Identifier,
NumberLiteral,
StringLiteral,
RegExpLiteral,
}
export interface ClassificationResult {
finalLexState: EndOfLineState;
entries: ClassificationInfo[];
}
export interface ClassificationInfo {
length: number;
classification: TokenClass;
}
export interface Classifier {
/**
* Gives lexical classifications of tokens on a line without any syntactic context.
* For instance, a token consisting of the text 'string' can be either an identifier
* named 'string' or the keyword 'string', however, because this classifier is not aware,
* it relies on certain heuristics to give acceptable results. For classifications where
* speed trumps accuracy, this function is preferable; however, for true accuracy, the
* syntactic classifier is ideal. In fact, in certain editing scenarios, combining the
* lexical, syntactic, and semantic classifiers may issue the best user experience.
*
* @param text The text of a line to classify.
* @param lexState The state of the lexical classifier at the end of the previous line.
* @param syntacticClassifierAbsent Whether the client is *not* using a syntactic classifier.
* If there is no syntactic classifier (syntacticClassifierAbsent=true),
* certain heuristics may be used in its place; however, if there is a
* syntactic classifier (syntacticClassifierAbsent=false), certain
* classifications which may be incorrectly categorized will be given
* back as Identifiers in order to allow the syntactic classifier to
* subsume the classification.
* @deprecated Use getLexicalClassifications instead.
*/
getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult;
getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications;
}
/**
* The document registry represents a store of SourceFile objects that can be shared between
* multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST)
* of files in the context.
* SourceFile objects account for most of the memory usage by the language service. Sharing
* the same DocumentRegistry instance between different instances of LanguageService allow
* for more efficient memory utilization since all projects will share at least the library
* file (lib.d.ts).
*
* A more advanced use of the document registry is to serialize sourceFile objects to disk
* and re-hydrate them when needed.
*
* To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it
* to all subsequent createLanguageService calls.
*/
export interface DocumentRegistry {
/**
* Request a stored SourceFile with a given fileName and compilationSettings.
* The first call to acquire will call createLanguageServiceSourceFile to generate
* the SourceFile if was not found in the registry.
*
* @param fileName The name of the file requested
* @param compilationSettings Some compilation settings like target affects the
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
* multiple copies of the same file for different compilation settings.
* @parm scriptSnapshot Text of the file. Only used if the file was not found
* in the registry and a new one was created.
* @parm version Current version of the file. Only used if the file was not found
* in the registry and a new one was created.
*/
acquireDocument(
fileName: string,
compilationSettings: CompilerOptions,
scriptSnapshot: IScriptSnapshot,
version: string,
scriptKind?: ScriptKind): SourceFile;
acquireDocumentWithKey(
fileName: string,
path: Path,
compilationSettings: CompilerOptions,
key: DocumentRegistryBucketKey,
scriptSnapshot: IScriptSnapshot,
version: string,
scriptKind?: ScriptKind): SourceFile;
/**
* Request an updated version of an already existing SourceFile with a given fileName
* and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile
* to get an updated SourceFile.
*
* @param fileName The name of the file requested
* @param compilationSettings Some compilation settings like target affects the
* shape of a the resulting SourceFile. This allows the DocumentRegistry to store
* multiple copies of the same file for different compilation settings.
* @param scriptSnapshot Text of the file.
* @param version Current version of the file.
*/
updateDocument(
fileName: string,
compilationSettings: CompilerOptions,
scriptSnapshot: IScriptSnapshot,
version: string,
scriptKind?: ScriptKind): SourceFile;
updateDocumentWithKey(
fileName: string,
path: Path,
compilationSettings: CompilerOptions,
key: DocumentRegistryBucketKey,
scriptSnapshot: IScriptSnapshot,
version: string,
scriptKind?: ScriptKind): SourceFile;
getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey;
/**
* Informs the DocumentRegistry that a file is not needed any longer.
*
* Note: It is not allowed to call release on a SourceFile that was not acquired from
* this registry originally.
*
* @param fileName The name of the file to be released
* @param compilationSettings The compilation settings used to acquire the file
*/
releaseDocument(fileName: string, compilationSettings: CompilerOptions): void;
releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void;
reportStats(): string;
}
export type DocumentRegistryBucketKey = string & { __bucketKey: any };
// TODO: move these to enums
export namespace ScriptElementKind {
export const unknown = "";
export const warning = "warning";
/** predefined type (void) or keyword (class) */
export const keyword = "keyword";
/** top level script node */
export const scriptElement = "script";
/** module foo {} */
export const moduleElement = "module";
/** class X {} */
export const classElement = "class";
/** var x = class X {} */
export const localClassElement = "local class";
/** interface Y {} */
export const interfaceElement = "interface";
/** type T = ... */
export const typeElement = "type";
/** enum E */
export const enumElement = "enum";
// TODO: GH#9983
export const enumMemberElement = "const";
/**
* Inside module and script only
* const v = ..
*/
export const variableElement = "var";
/** Inside function */
export const localVariableElement = "local var";
/**
* Inside module and script only
* function f() { }
*/
export const functionElement = "function";
/** Inside function */
export const localFunctionElement = "local function";
/** class X { [public|private]* foo() {} } */
export const memberFunctionElement = "method";
/** class X { [public|private]* [get|set] foo:number; } */
export const memberGetAccessorElement = "getter";
export const memberSetAccessorElement = "setter";
/**
* class X { [public|private]* foo:number; }
* interface Y { foo:number; }
*/
export const memberVariableElement = "property";
/** class X { constructor() { } } */
export const constructorImplementationElement = "constructor";
/** interface Y { ():number; } */
export const callSignatureElement = "call";
/** interface Y { []:number; } */
export const indexSignatureElement = "index";
/** interface Y { new():Y; } */
export const constructSignatureElement = "construct";
/** function foo(*Y*: string) */
export const parameterElement = "parameter";
export const typeParameterElement = "type parameter";
export const primitiveType = "primitive type";
export const label = "label";
export const alias = "alias";
export const constElement = "const";
export const letElement = "let";
export const directory = "directory";
export const externalModuleName = "external module name";
}
export namespace ScriptElementKindModifier {
export const none = "";
export const publicMemberModifier = "public";
export const privateMemberModifier = "private";
export const protectedMemberModifier = "protected";
export const exportedModifier = "export";
export const ambientModifier = "declare";
export const staticModifier = "static";
export const abstractModifier = "abstract";
}
export class ClassificationTypeNames {
public static comment = "comment";
public static identifier = "identifier";
public static keyword = "keyword";
public static numericLiteral = "number";
public static operator = "operator";
public static stringLiteral = "string";
public static whiteSpace = "whitespace";
public static text = "text";
public static punctuation = "punctuation";
public static className = "class name";
public static enumName = "enum name";
public static interfaceName = "interface name";
public static moduleName = "module name";
public static typeParameterName = "type parameter name";
public static typeAliasName = "type alias name";
public static parameterName = "parameter name";
public static docCommentTagName = "doc comment tag name";
public static jsxOpenTagName = "jsx open tag name";
public static jsxCloseTagName = "jsx close tag name";
public static jsxSelfClosingTagName = "jsx self closing tag name";
public static jsxAttribute = "jsx attribute";
public static jsxText = "jsx text";
public static jsxAttributeStringLiteralValue = "jsx attribute string literal value";
}
export const enum ClassificationType {
comment = 1,
identifier = 2,
keyword = 3,
numericLiteral = 4,
operator = 5,
stringLiteral = 6,
regularExpressionLiteral = 7,
whiteSpace = 8,
text = 9,
punctuation = 10,
className = 11,
enumName = 12,
interfaceName = 13,
moduleName = 14,
typeParameterName = 15,
typeAliasName = 16,
parameterName = 17,
docCommentTagName = 18,
jsxOpenTagName = 19,
jsxCloseTagName = 20,
jsxSelfClosingTagName = 21,
jsxAttribute = 22,
jsxText = 23,
jsxAttributeStringLiteralValue = 24,
}
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,8 +1,6 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' does not exist.",
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/a/b'",
"File '/a/b/node_modules/jquery.ts' does not exist.",
"File '/a/b/node_modules/jquery.d.ts' does not exist.",
@@ -1,8 +1,6 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' does not exist.",
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/a/b'",
"File '/a/b/node_modules/jquery.ts' does not exist.",
"File '/a/b/node_modules/jquery.d.ts' does not exist.",
@@ -1,8 +1,6 @@
[
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory '/src/node_modules/@types'. ========",
"Resolving with primary search path '/src/node_modules/@types'",
"File '/src/node_modules/@types/jquery/package.json' does not exist.",
"File '/src/node_modules/@types/jquery/index.d.ts' does not exist.",
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/src'",
"File '/src/node_modules/jquery.ts' does not exist.",
"File '/src/node_modules/jquery.d.ts' does not exist.",
@@ -1,8 +1,6 @@
[
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' does not exist.",
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"Looking up in 'node_modules' folder, initial location '/src'",
"File '/src/node_modules/jquery.ts' does not exist.",
"File '/src/node_modules/jquery.d.ts' does not exist.",
@@ -0,0 +1,31 @@
//// [tests/cases/compiler/typeRootsFromMultipleNodeModulesDirectories.ts] ////
//// [index.d.ts]
declare module "xyz" {
export const x: number;
}
//// [index.d.ts]
declare module "pdq" {
export const y: number;
}
//// [index.d.ts]
declare module "abc" {
export const z: number;
}
//// [a.ts]
import { x } from "xyz";
import { y } from "pdq";
import { z } from "abc";
x + y + z;
//// [a.js]
"use strict";
var xyz_1 = require("xyz");
var pdq_1 = require("pdq");
var abc_1 = require("abc");
xyz_1.x + pdq_1.y + abc_1.z;
@@ -0,0 +1,34 @@
=== /foo/bar/a.ts ===
import { x } from "xyz";
>x : Symbol(x, Decl(a.ts, 0, 8))
import { y } from "pdq";
>y : Symbol(y, Decl(a.ts, 1, 8))
import { z } from "abc";
>z : Symbol(z, Decl(a.ts, 2, 8))
x + y + z;
>x : Symbol(x, Decl(a.ts, 0, 8))
>y : Symbol(y, Decl(a.ts, 1, 8))
>z : Symbol(z, Decl(a.ts, 2, 8))
=== /node_modules/@types/dopey/index.d.ts ===
declare module "xyz" {
export const x: number;
>x : Symbol(x, Decl(index.d.ts, 2, 16))
}
=== /foo/node_modules/@types/grumpy/index.d.ts ===
declare module "pdq" {
export const y: number;
>y : Symbol(y, Decl(index.d.ts, 1, 16))
}
=== /foo/node_modules/@types/sneezy/index.d.ts ===
declare module "abc" {
export const z: number;
>z : Symbol(z, Decl(index.d.ts, 1, 16))
}
@@ -0,0 +1,157 @@
[
"======== Resolving module 'xyz' from '/foo/bar/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'xyz' from 'node_modules' folder.",
"File '/foo/bar/node_modules/xyz.ts' does not exist.",
"File '/foo/bar/node_modules/xyz.tsx' does not exist.",
"File '/foo/bar/node_modules/xyz.d.ts' does not exist.",
"File '/foo/bar/node_modules/xyz/package.json' does not exist.",
"File '/foo/bar/node_modules/xyz/index.ts' does not exist.",
"File '/foo/bar/node_modules/xyz/index.tsx' does not exist.",
"File '/foo/bar/node_modules/xyz/index.d.ts' does not exist.",
"File '/foo/bar/node_modules/@types/xyz.ts' does not exist.",
"File '/foo/bar/node_modules/@types/xyz.tsx' does not exist.",
"File '/foo/bar/node_modules/@types/xyz.d.ts' does not exist.",
"File '/foo/bar/node_modules/@types/xyz/package.json' does not exist.",
"File '/foo/bar/node_modules/@types/xyz/index.ts' does not exist.",
"File '/foo/bar/node_modules/@types/xyz/index.tsx' does not exist.",
"File '/foo/bar/node_modules/@types/xyz/index.d.ts' does not exist.",
"File '/foo/node_modules/xyz.ts' does not exist.",
"File '/foo/node_modules/xyz.tsx' does not exist.",
"File '/foo/node_modules/xyz.d.ts' does not exist.",
"File '/foo/node_modules/xyz/package.json' does not exist.",
"File '/foo/node_modules/xyz/index.ts' does not exist.",
"File '/foo/node_modules/xyz/index.tsx' does not exist.",
"File '/foo/node_modules/xyz/index.d.ts' does not exist.",
"File '/foo/node_modules/@types/xyz.ts' does not exist.",
"File '/foo/node_modules/@types/xyz.tsx' does not exist.",
"File '/foo/node_modules/@types/xyz.d.ts' does not exist.",
"File '/foo/node_modules/@types/xyz/package.json' does not exist.",
"File '/foo/node_modules/@types/xyz/index.ts' does not exist.",
"File '/foo/node_modules/@types/xyz/index.tsx' does not exist.",
"File '/foo/node_modules/@types/xyz/index.d.ts' does not exist.",
"File '/node_modules/xyz.ts' does not exist.",
"File '/node_modules/xyz.tsx' does not exist.",
"File '/node_modules/xyz.d.ts' does not exist.",
"File '/node_modules/xyz/package.json' does not exist.",
"File '/node_modules/xyz/index.ts' does not exist.",
"File '/node_modules/xyz/index.tsx' does not exist.",
"File '/node_modules/xyz/index.d.ts' does not exist.",
"File '/node_modules/@types/xyz.ts' does not exist.",
"File '/node_modules/@types/xyz.tsx' does not exist.",
"File '/node_modules/@types/xyz.d.ts' does not exist.",
"File '/node_modules/@types/xyz/package.json' does not exist.",
"File '/node_modules/@types/xyz/index.ts' does not exist.",
"File '/node_modules/@types/xyz/index.tsx' does not exist.",
"File '/node_modules/@types/xyz/index.d.ts' does not exist.",
"======== Module name 'xyz' was not resolved. ========",
"======== Resolving module 'pdq' from '/foo/bar/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'pdq' from 'node_modules' folder.",
"File '/foo/bar/node_modules/pdq.ts' does not exist.",
"File '/foo/bar/node_modules/pdq.tsx' does not exist.",
"File '/foo/bar/node_modules/pdq.d.ts' does not exist.",
"File '/foo/bar/node_modules/pdq/package.json' does not exist.",
"File '/foo/bar/node_modules/pdq/index.ts' does not exist.",
"File '/foo/bar/node_modules/pdq/index.tsx' does not exist.",
"File '/foo/bar/node_modules/pdq/index.d.ts' does not exist.",
"File '/foo/bar/node_modules/@types/pdq.ts' does not exist.",
"File '/foo/bar/node_modules/@types/pdq.tsx' does not exist.",
"File '/foo/bar/node_modules/@types/pdq.d.ts' does not exist.",
"File '/foo/bar/node_modules/@types/pdq/package.json' does not exist.",
"File '/foo/bar/node_modules/@types/pdq/index.ts' does not exist.",
"File '/foo/bar/node_modules/@types/pdq/index.tsx' does not exist.",
"File '/foo/bar/node_modules/@types/pdq/index.d.ts' does not exist.",
"File '/foo/node_modules/pdq.ts' does not exist.",
"File '/foo/node_modules/pdq.tsx' does not exist.",
"File '/foo/node_modules/pdq.d.ts' does not exist.",
"File '/foo/node_modules/pdq/package.json' does not exist.",
"File '/foo/node_modules/pdq/index.ts' does not exist.",
"File '/foo/node_modules/pdq/index.tsx' does not exist.",
"File '/foo/node_modules/pdq/index.d.ts' does not exist.",
"File '/foo/node_modules/@types/pdq.ts' does not exist.",
"File '/foo/node_modules/@types/pdq.tsx' does not exist.",
"File '/foo/node_modules/@types/pdq.d.ts' does not exist.",
"File '/foo/node_modules/@types/pdq/package.json' does not exist.",
"File '/foo/node_modules/@types/pdq/index.ts' does not exist.",
"File '/foo/node_modules/@types/pdq/index.tsx' does not exist.",
"File '/foo/node_modules/@types/pdq/index.d.ts' does not exist.",
"File '/node_modules/pdq.ts' does not exist.",
"File '/node_modules/pdq.tsx' does not exist.",
"File '/node_modules/pdq.d.ts' does not exist.",
"File '/node_modules/pdq/package.json' does not exist.",
"File '/node_modules/pdq/index.ts' does not exist.",
"File '/node_modules/pdq/index.tsx' does not exist.",
"File '/node_modules/pdq/index.d.ts' does not exist.",
"File '/node_modules/@types/pdq.ts' does not exist.",
"File '/node_modules/@types/pdq.tsx' does not exist.",
"File '/node_modules/@types/pdq.d.ts' does not exist.",
"File '/node_modules/@types/pdq/package.json' does not exist.",
"File '/node_modules/@types/pdq/index.ts' does not exist.",
"File '/node_modules/@types/pdq/index.tsx' does not exist.",
"File '/node_modules/@types/pdq/index.d.ts' does not exist.",
"======== Module name 'pdq' was not resolved. ========",
"======== Resolving module 'abc' from '/foo/bar/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'abc' from 'node_modules' folder.",
"File '/foo/bar/node_modules/abc.ts' does not exist.",
"File '/foo/bar/node_modules/abc.tsx' does not exist.",
"File '/foo/bar/node_modules/abc.d.ts' does not exist.",
"File '/foo/bar/node_modules/abc/package.json' does not exist.",
"File '/foo/bar/node_modules/abc/index.ts' does not exist.",
"File '/foo/bar/node_modules/abc/index.tsx' does not exist.",
"File '/foo/bar/node_modules/abc/index.d.ts' does not exist.",
"File '/foo/bar/node_modules/@types/abc.ts' does not exist.",
"File '/foo/bar/node_modules/@types/abc.tsx' does not exist.",
"File '/foo/bar/node_modules/@types/abc.d.ts' does not exist.",
"File '/foo/bar/node_modules/@types/abc/package.json' does not exist.",
"File '/foo/bar/node_modules/@types/abc/index.ts' does not exist.",
"File '/foo/bar/node_modules/@types/abc/index.tsx' does not exist.",
"File '/foo/bar/node_modules/@types/abc/index.d.ts' does not exist.",
"File '/foo/node_modules/abc.ts' does not exist.",
"File '/foo/node_modules/abc.tsx' does not exist.",
"File '/foo/node_modules/abc.d.ts' does not exist.",
"File '/foo/node_modules/abc/package.json' does not exist.",
"File '/foo/node_modules/abc/index.ts' does not exist.",
"File '/foo/node_modules/abc/index.tsx' does not exist.",
"File '/foo/node_modules/abc/index.d.ts' does not exist.",
"File '/foo/node_modules/@types/abc.ts' does not exist.",
"File '/foo/node_modules/@types/abc.tsx' does not exist.",
"File '/foo/node_modules/@types/abc.d.ts' does not exist.",
"File '/foo/node_modules/@types/abc/package.json' does not exist.",
"File '/foo/node_modules/@types/abc/index.ts' does not exist.",
"File '/foo/node_modules/@types/abc/index.tsx' does not exist.",
"File '/foo/node_modules/@types/abc/index.d.ts' does not exist.",
"File '/node_modules/abc.ts' does not exist.",
"File '/node_modules/abc.tsx' does not exist.",
"File '/node_modules/abc.d.ts' does not exist.",
"File '/node_modules/abc/package.json' does not exist.",
"File '/node_modules/abc/index.ts' does not exist.",
"File '/node_modules/abc/index.tsx' does not exist.",
"File '/node_modules/abc/index.d.ts' does not exist.",
"File '/node_modules/@types/abc.ts' does not exist.",
"File '/node_modules/@types/abc.tsx' does not exist.",
"File '/node_modules/@types/abc.d.ts' does not exist.",
"File '/node_modules/@types/abc/package.json' does not exist.",
"File '/node_modules/@types/abc/index.ts' does not exist.",
"File '/node_modules/@types/abc/index.tsx' does not exist.",
"File '/node_modules/@types/abc/index.d.ts' does not exist.",
"======== Module name 'abc' was not resolved. ========",
"======== Resolving type reference directive 'grumpy', containing file '/src/__inferred type names__.ts', root directory '/foo/node_modules/@types,/node_modules/@types'. ========",
"Resolving with primary search path '/foo/node_modules/@types, /node_modules/@types'",
"File '/foo/node_modules/@types/grumpy/package.json' does not exist.",
"File '/foo/node_modules/@types/grumpy/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'grumpy' was successfully resolved to '/foo/node_modules/@types/grumpy/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'sneezy', containing file '/src/__inferred type names__.ts', root directory '/foo/node_modules/@types,/node_modules/@types'. ========",
"Resolving with primary search path '/foo/node_modules/@types, /node_modules/@types'",
"File '/foo/node_modules/@types/sneezy/package.json' does not exist.",
"File '/foo/node_modules/@types/sneezy/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'sneezy' was successfully resolved to '/foo/node_modules/@types/sneezy/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'dopey', containing file '/src/__inferred type names__.ts', root directory '/foo/node_modules/@types,/node_modules/@types'. ========",
"Resolving with primary search path '/foo/node_modules/@types, /node_modules/@types'",
"File '/foo/node_modules/@types/dopey/package.json' does not exist.",
"File '/foo/node_modules/@types/dopey/index.d.ts' does not exist.",
"File '/node_modules/@types/dopey/package.json' does not exist.",
"File '/node_modules/@types/dopey/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'dopey' was successfully resolved to '/node_modules/@types/dopey/index.d.ts', primary: true. ========"
]
@@ -0,0 +1,36 @@
=== /foo/bar/a.ts ===
import { x } from "xyz";
>x : number
import { y } from "pdq";
>y : number
import { z } from "abc";
>z : number
x + y + z;
>x + y + z : number
>x + y : number
>x : number
>y : number
>z : number
=== /node_modules/@types/dopey/index.d.ts ===
declare module "xyz" {
export const x: number;
>x : number
}
=== /foo/node_modules/@types/grumpy/index.d.ts ===
declare module "pdq" {
export const y: number;
>y : number
}
=== /foo/node_modules/@types/sneezy/index.d.ts ===
declare module "abc" {
export const z: number;
>z : number
}
@@ -0,0 +1,17 @@
//// [tests/cases/compiler/typeRootsFromNodeModulesInParentDirectory.ts] ////
//// [index.d.ts]
declare module "xyz" {
export const x: number;
}
//// [a.ts]
import { x } from "xyz";
x;
//// [a.js]
"use strict";
var xyz_1 = require("xyz");
xyz_1.x;
@@ -0,0 +1,14 @@
=== /src/a.ts ===
import { x } from "xyz";
>x : Symbol(x, Decl(a.ts, 0, 8))
x;
>x : Symbol(x, Decl(a.ts, 0, 8))
=== /node_modules/@types/foo/index.d.ts ===
declare module "xyz" {
export const x: number;
>x : Symbol(x, Decl(index.d.ts, 2, 16))
}
@@ -0,0 +1,39 @@
[
"======== Resolving module 'xyz' from '/src/a.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module 'xyz' from 'node_modules' folder.",
"File '/src/node_modules/xyz.ts' does not exist.",
"File '/src/node_modules/xyz.tsx' does not exist.",
"File '/src/node_modules/xyz.d.ts' does not exist.",
"File '/src/node_modules/xyz/package.json' does not exist.",
"File '/src/node_modules/xyz/index.ts' does not exist.",
"File '/src/node_modules/xyz/index.tsx' does not exist.",
"File '/src/node_modules/xyz/index.d.ts' does not exist.",
"File '/src/node_modules/@types/xyz.ts' does not exist.",
"File '/src/node_modules/@types/xyz.tsx' does not exist.",
"File '/src/node_modules/@types/xyz.d.ts' does not exist.",
"File '/src/node_modules/@types/xyz/package.json' does not exist.",
"File '/src/node_modules/@types/xyz/index.ts' does not exist.",
"File '/src/node_modules/@types/xyz/index.tsx' does not exist.",
"File '/src/node_modules/@types/xyz/index.d.ts' does not exist.",
"File '/node_modules/xyz.ts' does not exist.",
"File '/node_modules/xyz.tsx' does not exist.",
"File '/node_modules/xyz.d.ts' does not exist.",
"File '/node_modules/xyz/package.json' does not exist.",
"File '/node_modules/xyz/index.ts' does not exist.",
"File '/node_modules/xyz/index.tsx' does not exist.",
"File '/node_modules/xyz/index.d.ts' does not exist.",
"File '/node_modules/@types/xyz.ts' does not exist.",
"File '/node_modules/@types/xyz.tsx' does not exist.",
"File '/node_modules/@types/xyz.d.ts' does not exist.",
"File '/node_modules/@types/xyz/package.json' does not exist.",
"File '/node_modules/@types/xyz/index.ts' does not exist.",
"File '/node_modules/@types/xyz/index.tsx' does not exist.",
"File '/node_modules/@types/xyz/index.d.ts' does not exist.",
"======== Module name 'xyz' was not resolved. ========",
"======== Resolving type reference directive 'foo', containing file '/src/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/foo/package.json' does not exist.",
"File '/node_modules/@types/foo/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'foo' was successfully resolved to '/node_modules/@types/foo/index.d.ts', primary: true. ========"
]
@@ -0,0 +1,14 @@
=== /src/a.ts ===
import { x } from "xyz";
>x : number
x;
>x : number
=== /node_modules/@types/foo/index.d.ts ===
declare module "xyz" {
export const x: number;
>x : number
}
@@ -0,0 +1,27 @@
// @noImplicitReferences: true
// @traceResolution: true
// @currentDirectory: /src
// @Filename: /node_modules/@types/dopey/index.d.ts
declare module "xyz" {
export const x: number;
}
// @Filename: /foo/node_modules/@types/grumpy/index.d.ts
declare module "pdq" {
export const y: number;
}
// @Filename: /foo/node_modules/@types/sneezy/index.d.ts
declare module "abc" {
export const z: number;
}
// @Filename: /foo/bar/a.ts
import { x } from "xyz";
import { y } from "pdq";
import { z } from "abc";
x + y + z;
// @Filename: /foo/bar/tsconfig.json
{}
@@ -0,0 +1,15 @@
// @noImplicitReferences: true
// @traceResolution: true
// @currentDirectory: /src
// @Filename: /node_modules/@types/foo/index.d.ts
declare module "xyz" {
export const x: number;
}
// @Filename: /src/a.ts
import { x } from "xyz";
x;
// @Filename: /src/tsconfig.json
{}
File diff suppressed because one or more lines are too long
@@ -12,28 +12,25 @@
goTo.marker("useFoo");
verify.quickInfoIs("import foo");
goTo.definition();
verify.caretAtMarker("importFoo");
goTo.definition();
verify.caretAtMarker("module");
verify.goToDefinition({
useFoo: "importFoo",
importFoo: "module"
});
goTo.marker("useBar");
verify.quickInfoIs("import bar");
goTo.definition();
verify.caretAtMarker("module");
verify.goToDefinition("useBar", "module");
goTo.marker("useBaz");
verify.quickInfoIs("import baz");
goTo.definition();
verify.caretAtMarker("importBaz");
goTo.marker("idBaz");
goTo.definition();
verify.caretAtMarker("module");
verify.goToDefinition({
useBaz: "importBaz",
idBaz: "module"
});
goTo.marker("useBang");
verify.quickInfoIs("import bang = require(\"jquery\")");
goTo.definition();
verify.caretAtMarker("importBang");
goTo.marker("idBang");
goTo.definition();
verify.caretAtMarker("module");
verify.goToDefinition({
useBang: "importBang",
idBang: "module"
});
+1 -3
View File
@@ -7,6 +7,4 @@
// @Filename: a.ts
//// /*2*/export class Foo {}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");
@@ -8,4 +8,4 @@
////var enumMember = e./*1*/thirdMember;
goTo.marker("1");
verify.verifyDefinitionsName("thirdMember", "e");
verify.goToDefinitionName("thirdMember", "e");
@@ -0,0 +1,46 @@
/// <reference path="fourslash.ts" />
// @Filename: a.ts
////export class C {
//// [|constructor|](n: number);
//// [|constructor|]();
//// [|constructor|](n?: number){}
//// static f() {
//// this.f();
//// new [|this|]();
//// }
////}
////new [|C|]();
// Does not handle alias.
////const D = C;
////new D();
// @Filename: b.ts
////import { C } from "./a";
////new [|C|]();
// @Filename: c.ts
////import { C } from "./a";
////class D extends C {
//// constructor() {
//// [|super|]();
//// super.method();
//// }
//// method() { super(); }
////}
// Does not find 'super()' calls for a class that merely implements 'C',
// since those must be calling a different constructor.
////class E implements C {
//// constructor() { super(); }
////}
// Works with qualified names too
// @Filename: d.ts
////import * as a from "./a";
////new a.[|C|]();
////class d extends a.C { constructor() { [|super|](); }
const ranges = test.ranges();
for (const ctr of ranges.slice(0, 3)) {
verify.referencesOf(ctr, ranges);
}
@@ -0,0 +1,8 @@
/// <reference path="fourslash.ts" />
////class C {
//// [|constructor|](n: number);
//// [|constructor|](){}
////}
verify.rangesReferenceEachOther();
+16 -4
View File
@@ -99,6 +99,7 @@ declare namespace FourSlashInterface {
}
class test_ {
markers(): Marker[];
markerNames(): string[];
marker(name?: string): Marker;
ranges(): Range[];
rangesByText(): { [text: string]: Range[] };
@@ -108,7 +109,6 @@ declare namespace FourSlashInterface {
marker(name?: string): void;
bof(): void;
eof(): void;
definition(definitionIndex?: number): void;
type(definitionIndex?: number): void;
position(position: number, fileIndex?: number): any;
position(position: number, fileName?: string): any;
@@ -132,10 +132,7 @@ declare namespace FourSlashInterface {
errorExistsBeforeMarker(markerName?: string): void;
quickInfoIs(expectedText?: string, expectedDocumentation?: string): void;
quickInfoExists(): void;
definitionCountIs(expectedCount: number): void;
typeDefinitionCountIs(expectedCount: number): void;
definitionLocationExists(): void;
verifyDefinitionsName(name: string, containerName: string): void;
isValidBraceCompletionAtPosition(openingBrace?: string): void;
}
class verify extends verifyNegatable {
@@ -152,6 +149,21 @@ declare namespace FourSlashInterface {
eval(expr: string, value: any): void;
currentLineContentIs(text: string): void;
currentFileContentIs(text: string): void;
/** Verifies that goToDefinition at the current position would take you to `endMarker`. */
goToDefinitionIs(endMarkers: string | string[]): void;
goToDefinitionName(name: string, containerName: string): void;
/**
* `verify.goToDefinition("a", "b");` verifies that go-to-definition at marker "a" takes you to marker "b".
* `verify.goToDefinition(["a", "aa"], "b");` verifies that markers "a" and "aa" have the same definition "b".
* `verify.goToDefinition("a", ["b", "bb"]);` verifies that "a" has multiple definitions available.
*/
goToDefinition(startMarkerNames: string | string[], endMarkerNames: string | string[]): void;
/** Performs `goToDefinition` for each pair. */
goToDefinition(startsAndEnds: [string | string[], string | string[]][]): void;
/** Performs `goToDefinition` on each key and value. */
goToDefinition(startsAndEnds: { [startMarkerName: string]: string | string[] }): void;
/** Verifies goToDefinition for each `${markerName}Reference` -> `${markerName}Definition` */
goToDefinitionForMarkers(...markerNames: string[]): void;
verifyGetEmitOutputForCurrentFile(expected: string): void;
verifyGetEmitOutputContentsForCurrentFile(expected: ts.OutputFile[]): void;
/**
@@ -0,0 +1,19 @@
// @Target: ES6
// @experimentaldecorators: true
////async function f() {}
////
/////*defDecString*/function dec(target: any, propertyKey: string): void;
/////*defDecSymbol*/function dec(target: any, propertyKey: symbol): void;
////function dec(target: any, propertyKey: string | symbol) {}
////
////declare const s: symbol;
////class C {
//// @/*useDecString*/dec f() {}
//// @/*useDecSymbol*/dec [s]() {}
////}
verify.goToDefinition({
useDecString: "defDecString",
useDecSymbol: "defDecSymbol"
});
@@ -1,17 +1,14 @@
/// <reference path="fourslash.ts" />
//@Filename: a.ts
////var x: number;
////var /*def1*/x: number;
//@Filename: b.ts
////var x: number;
////var /*def2*/x: number;
//@Filename: c.ts
/////// <reference path="a.ts" />
/////// <reference path="b.ts" />
/////**/x++;
/////*use*/x++;
goTo.file("c.ts");
goTo.marker();
verify.definitionCountIs(2);
verify.goToDefinition("use", ["def1", "def2"]);
+4 -17
View File
@@ -23,20 +23,7 @@
//// x;
////}
goTo.marker('alias1Type');
goTo.definition();
verify.caretAtMarker('alias1Definition');
goTo.marker('alias2Type');
goTo.definition();
verify.caretAtMarker('alias2Definition');
goTo.marker('alias1Value');
goTo.definition();
verify.caretAtMarker('alias1Definition');
goTo.marker('alias2Value');
goTo.definition();
verify.caretAtMarker('alias2Definition');
verify.goToDefinition([
[["alias1Type", "alias1Value"], "alias1Definition"],
[["alias2Type", "alias2Value"], "alias2Definition"]
]);
@@ -14,16 +14,4 @@
////ambientClass./*staticMethodReference*/method();
////ambientClassVariable./*instanceMethodReference*/method();
var markerList = [
"ambientVariable",
"ambientFunction",
"constructor",
"staticMethod",
"instanceMethod",
];
markerList.forEach((marker) => {
goTo.marker(marker + 'Reference');
goTo.definition();
verify.caretAtMarker(marker + 'Definition');
});
verify.goToDefinitionForMarkers("ambientVariable", "ambientFunction", "constructor", "staticMethod", "instanceMethod");
@@ -8,10 +8,4 @@
////o./*reference1*/myObjectMethod();
////o["/*reference2*/myObjectMethod"]();
goTo.marker("reference1");
goTo.definition();
verify.caretAtMarker("definition");
goTo.marker("reference2");
goTo.definition();
verify.caretAtMarker("definition");
verify.goToDefinition(["reference1", "reference2"], "definition");
@@ -5,7 +5,6 @@
////var b: /*boolean*/boolean;
////var v: /*void*/void;
test.markers().forEach((m, i, a) => {
goTo.position(m.position, m.fileName);
verify.not.definitionLocationExists();
});
for (const marker of test.markerNames()) {
verify.goToDefinition(marker, []);
}
@@ -6,7 +6,6 @@
////var t = /*true*/true;
////var f = /*false*/false;
test.markers().forEach((m, i, a) => {
goTo.position(m.position, m.fileName);
verify.not.definitionLocationExists();
});
for (const marker of test.markerNames()) {
verify.goToDefinition(marker, []);
}
@@ -6,6 +6,4 @@
//// }
////}
goTo.marker("usage");
goTo.definition();
verify.caretAtMarker("definition");
verify.goToDefinition("usage", "definition");
@@ -11,6 +11,4 @@
////
////var x = new /*usage*/Foo();
goTo.marker("usage");
goTo.definition();
verify.caretAtMarker("definition");
verify.goToDefinition("usage", "definition");
@@ -9,14 +9,8 @@
////var constructorOverload = new /*constructorOverloadReference1*/ConstructorOverload();
////var constructorOverload = new /*constructorOverloadReference2*/ConstructorOverload("foo");
goTo.marker('constructorOverloadReference1');
goTo.definition();
verify.caretAtMarker('constructorDefinition');
goTo.marker('constructorOverloadReference2');
goTo.definition();
verify.caretAtMarker('constructorDefinition');
goTo.marker('constructorOverload1');
goTo.definition();
verify.caretAtMarker('constructorDefinition');
verify.goToDefinition({
constructorOverloadReference1: "constructorOverload1",
constructorOverloadReference2: "constructorOverload2",
constructorOverload1: "constructorDefinition"
});
@@ -16,11 +16,7 @@
//// return target => target;
////}
goTo.marker('decoratorUse');
goTo.definition();
verify.caretAtMarker('decoratorDefinition');
goTo.marker('decoratorFactoryUse');
goTo.definition();
verify.caretAtMarker('decoratorFactoryDefinition');
verify.goToDefinition({
decoratorUse: "decoratorDefinition",
decoratorFactoryUse: "decoratorFactoryDefinition"
});
@@ -14,16 +14,4 @@
////class fooCls implements /*remoteInterfaceReference*/remoteInterface { }
////var fooVar = /*remoteModuleReference*/remoteModule.foo;
var markerList = [
"remoteVariable",
"remoteFunction",
"remoteClass",
"remoteInterface",
"remoteModule",
];
markerList.forEach((marker) => {
goTo.marker(marker + 'Reference');
goTo.definition();
verify.caretAtMarker(marker + 'Definition');
});
verify.goToDefinitionForMarkers("remoteVariable", "remoteFunction", "remoteClass", "remoteInterface", "remoteModule");
@@ -21,16 +21,4 @@
////class rem2fooCls implements /*remoteInterfaceReference*/rem2Int { }
////var rem2fooVar = /*remoteModuleReference*/rem2Mod.foo;
var markerList = [
"remoteVariable",
"remoteFunction",
"remoteClass",
"remoteInterface",
"remoteModule",
];
markerList.forEach((marker) => {
goTo.marker(marker + 'Reference');
goTo.definition();
verify.caretAtMarker(marker + 'Definition');
});
verify.goToDefinitionForMarkers("remoteVariable", "remoteFunction", "remoteClass", "remoteInterface", "remoteModule")
@@ -7,6 +7,4 @@
// @Filename: a.ts
//// /*2*/export class Foo {}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");
@@ -8,6 +8,4 @@
/////*2*/class Foo {}
////export var x = 0;
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");
@@ -9,6 +9,4 @@
//// class Foo { }
////}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");
@@ -3,5 +3,4 @@
// @Filename: b.ts
////import n = require('unknown/*1*/');
goTo.marker('1');
verify.not.definitionLocationExists();
verify.goToDefinition("1", []);
@@ -5,6 +5,4 @@
//// class Foo { }
////}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");
@@ -8,6 +8,4 @@
//// class Foo { }
////}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");
@@ -8,6 +8,4 @@
//// class Foo { }
////}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");
@@ -8,6 +8,4 @@
//// class Foo { }
////}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");
@@ -8,6 +8,4 @@
//// class Foo { }
////}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition("1", "2");
@@ -1,20 +1,16 @@
/// <reference path='fourslash.ts' />
/////*functionOverload1*/function /*functionOverload*/functionOverload();
/////*functionOverload1*/function /*functionOverload*/functionOverload(value: number);
/////*functionOverload2*/function functionOverload(value: string);
/////*functionOverloadDefinition*/function functionOverload() {}
////
/////*functionOverloadReference1*/functionOverload();
/////*functionOverloadReference1*/functionOverload(123);
/////*functionOverloadReference2*/functionOverload("123");
/////*brokenOverload*/functionOverload({});
goTo.marker('functionOverloadReference1');
goTo.definition();
verify.caretAtMarker('functionOverloadDefinition');
goTo.marker('functionOverloadReference2');
goTo.definition();
verify.caretAtMarker('functionOverloadDefinition');
goTo.marker('functionOverload');
goTo.definition();
verify.caretAtMarker('functionOverloadDefinition');
verify.goToDefinition({
functionOverloadReference1: "functionOverload1",
functionOverloadReference2: "functionOverload2",
brokenOverload: "functionOverload1",
functionOverload: "functionOverloadDefinition"
});
@@ -11,10 +11,7 @@
//// constructor() { }
////}
goTo.marker('staticFunctionOverload');
goTo.definition();
verify.caretAtMarker('staticFunctionOverloadDefinition');
goTo.marker('functionOverload');
goTo.definition();
verify.caretAtMarker('functionOverloadDefinition');
verify.goToDefinition({
staticFunctionOverload: "staticFunctionOverloadDefinition",
functionOverload: "functionOverloadDefinition"
});
@@ -4,6 +4,4 @@
////}
////var implicitConstructor = new /*constructorReference*/ImplicitConstructor();
goTo.marker('constructorReference');
goTo.definition();
verify.caretAtMarker('constructorDefinition');
verify.goToDefinitionForMarkers("constructor");
@@ -14,8 +14,5 @@
//// x;
////}
goTo.file("b.ts");
goTo.marker('classAliasDefinition');
goTo.definition();
verify.caretAtMarker('classDefinition');
verify.goToDefinition("classAliasDefinition", "classDefinition");
@@ -14,8 +14,4 @@
//// x;
////}
goTo.file("b.ts");
goTo.marker('classAliasDefinition');
goTo.definition();
verify.caretAtMarker('classDefinition');
verify.goToDefinition("classAliasDefinition", "classDefinition");
@@ -27,12 +27,4 @@
//// x;
////}
goTo.file("e.ts");
goTo.marker('classReference');
goTo.definition();
verify.caretAtMarker('classDefinition');
goTo.marker('classAliasDefinition');
goTo.definition();
verify.caretAtMarker('classDefinition');
verify.goToDefinition(["classReference", "classAliasDefinition"], "classDefinition");
@@ -14,8 +14,4 @@
//// x;
////}
goTo.file("b.ts");
goTo.marker('classAliasDefinition');
goTo.definition();
verify.caretAtMarker('classDefinition');
verify.goToDefinition("classAliasDefinition", "classDefinition");
@@ -14,8 +14,4 @@
//// x;
////}
goTo.file("b.ts");
goTo.marker('classAliasDefinition');
goTo.definition();
verify.caretAtMarker('classDefinition');
verify.goToDefinition("classAliasDefinition", "classDefinition");
@@ -14,8 +14,4 @@
//// x;
////}
goTo.file("b.ts");
goTo.marker('moduleAliasDefinition');
goTo.definition();
verify.caretAtMarker('moduleDefinition');
verify.goToDefinition("moduleAliasDefinition", "moduleDefinition");
@@ -10,8 +10,4 @@
////}
////export default Class;
goTo.file("b.ts");
goTo.marker('classAliasDefinition');
goTo.definition();
verify.caretAtMarker('classDefinition');
verify.goToDefinition("classAliasDefinition", "classDefinition");
@@ -19,35 +19,9 @@
//// }
////}
goTo.marker("interfaceReference");
goTo.definition();
verify.caretAtMarker("interfaceDefinition");
goTo.marker("interfaceReferenceInList");
goTo.definition();
verify.caretAtMarker("interfaceDefinition");
goTo.marker("interfaceReferenceInConstructor");
goTo.definition();
verify.caretAtMarker("interfaceDefinition");
goTo.marker("classReference");
goTo.definition();
verify.caretAtMarker("classDefinition");
goTo.marker("classReferenceInInitializer");
goTo.definition();
verify.caretAtMarker("classDefinition");
goTo.marker("enumReference");
goTo.definition();
verify.caretAtMarker("enumDefinition");
goTo.marker("enumReferenceInInitializer");
goTo.definition();
verify.caretAtMarker("enumDefinition");
goTo.marker("selfReference");
goTo.definition();
verify.caretAtMarker("selfDefinition");
verify.goToDefinition([
[["interfaceReference", "interfaceReferenceInList", "interfaceReferenceInConstructor"], "interfaceDefinition"],
[["classReference", "classReferenceInInitializer"], "classDefinition"],
[["enumReference", "enumReferenceInInitializer"], "enumDefinition"],
["selfReference", "selfDefinition"]
]);
@@ -6,11 +6,4 @@
////
////var x = new Fo/*fooReference*/o<Ba/*barReference*/r>();
goTo.marker("barReference");
goTo.definition();
verify.caretAtMarker("barDefinition");
goTo.marker("fooReference");
goTo.definition();
verify.caretAtMarker("fooDefinition");
verify.goToDefinitionForMarkers("bar", "foo");
@@ -11,6 +11,4 @@
//// }
////}
goTo.marker('interfaceReference');
goTo.definition();
verify.caretAtMarker('interfaceDefinition');
verify.goToDefinitionForMarkers("interface");
+8 -16
View File
@@ -9,19 +9,11 @@
//// }
////}
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('label1Definition');
goTo.marker('2');
goTo.definition();
verify.caretAtMarker('label2Definition');
// labels accross function bounderies
goTo.marker('3');
goTo.definition();
verify.caretAtMarker('label1Definition');
// undefined label
goTo.marker('4');
verify.not.definitionLocationExists();
verify.goToDefinition({
1: "label1Definition",
2: "label2Definition",
// labels accross function boundaries
3: "label1Definition",
// undefined label
4: []
});
@@ -1,11 +1,11 @@
/// <reference path='fourslash.ts' />
////class MethodOverload {
//// static me/*staticMethodOverload1*/thod();
//// static me/*staticMethodOverload2*/thod(foo: string);
/////*staticMethodDefinition*/static method(foo?: any) { }
//// public met/*instanceMethodOverload1*/hod(): any;
//// public met/*instanceMethodOverload2*/hod(foo: string);
//// /*staticMethodOverload1*/static /*staticMethodOverload1Name*/method();
//// /*staticMethodOverload2*/static method(foo: string);
//// /*staticMethodDefinition*/static method(foo?: any) { }
//// /*instanceMethodOverload1*/public /*instanceMethodOverload1Name*/method(): any;
//// /*instanceMethodOverload2*/public method(foo: string);
/////*instanceMethodDefinition*/public method(foo?: any) { return "foo" }
////}
@@ -18,27 +18,11 @@
////methodOverload./*instanceMethodReference1*/method();
////methodOverload./*instanceMethodReference2*/method("456");
goTo.marker('staticMethodReference1');
goTo.definition();
verify.caretAtMarker('staticMethodDefinition');
goTo.marker('staticMethodReference2');
goTo.definition();
verify.caretAtMarker('staticMethodDefinition');
goTo.marker('instanceMethodReference1');
goTo.definition();
verify.caretAtMarker('instanceMethodDefinition');
goTo.marker('instanceMethodReference2');
goTo.definition();
verify.caretAtMarker('instanceMethodDefinition');
goTo.marker('staticMethodOverload1');
goTo.definition();
verify.caretAtMarker('staticMethodDefinition');
goTo.marker('instanceMethodOverload1');
goTo.definition();
verify.caretAtMarker('instanceMethodDefinition');
verify.goToDefinition({
staticMethodReference1: "staticMethodOverload1",
staticMethodReference2: "staticMethodOverload2",
instanceMethodReference1: "instanceMethodOverload1",
instanceMethodReference2: "instanceMethodOverload2",
staticMethodOverload1Name: "staticMethodDefinition",
instanceMethodOverload1Name: "instanceMethodDefinition"
});
@@ -1,51 +1,34 @@
/// <reference path='fourslash.ts' />
// @Filename: a.ts
/////*interfaceDefintion1*/interface IFoo {
/////*interfaceDefinition1*/interface IFoo {
//// instance1: number;
////}
// @Filename: b.ts
/////*interfaceDefintion2*/interface IFoo {
/////*interfaceDefinition2*/interface IFoo {
//// instance2: number;
////}
////
/////*interfaceDefintion3*/interface IFoo {
/////*interfaceDefinition3*/interface IFoo {
//// instance3: number;
////}
////
////var ifoo: IFo/*interfaceReference*/o;
goTo.marker('interfaceReference');
goTo.definition(0);
verify.caretAtMarker('interfaceDefintion1');
goTo.marker('interfaceReference');
goTo.definition(1);
verify.caretAtMarker('interfaceDefintion2');
goTo.marker('interfaceReference');
goTo.definition(2);
verify.caretAtMarker('interfaceDefintion3');
verify.goToDefinition("interfaceReference", ["interfaceDefinition1", "interfaceDefinition2", "interfaceDefinition3"]);
// @Filename: c.ts
/////*moduleDefintion1*/module Module {
/////*moduleDefinition1*/module Module {
//// export class c1 { }
////}
// @Filename: d.ts
/////*moduleDefintion2*/module Module {
/////*moduleDefinition2*/module Module {
//// export class c2 { }
////}
// @Filename: e.ts
////Modul/*moduleReference*/e;
goTo.marker('moduleReference');
goTo.definition(0);
verify.caretAtMarker('moduleDefintion1');
goTo.marker('moduleReference');
goTo.definition(1);
verify.caretAtMarker('moduleDefintion2');
verify.goToDefinition("moduleReference", ["moduleDefinition1", "moduleDefinition2"]);
@@ -8,7 +8,4 @@
////var foo: I;
////var { /*use*/property1: prop1 } = foo;
goTo.marker("use");
verify.definitionLocationExists();
goTo.definition();
verify.caretAtMarker("def");
verify.goToDefinition("use", "def");
@@ -14,16 +14,4 @@
////o./*methodReference*/method;
////o./*es6StyleMethodReference*/es6StyleMethod;
var markerList = [
"value",
"getter",
"setter",
"method",
"es6StyleMethod",
];
markerList.forEach((marker) => {
goTo.marker(marker + 'Reference');
goTo.definition();
verify.caretAtMarker(marker + 'Definition');
});
verify.goToDefinitionForMarkers("value", "getter", "setter", "method", "es6StyleMethod");
@@ -0,0 +1,14 @@
/// <reference path='fourslash.ts' />
// Test that we can climb past more than one property access to reach a call expression.
////namespace A {
//// export namespace B {
//// export function f(value: number): void;
//// /*1*/export function f(value: string): void;
//// export function f(value: number | string) {}
//// }
////}
////A.B./*2*/f("");
verify.goToDefinition("2", "1");
@@ -9,13 +9,11 @@
// @Filename: goToDefinitionPartialImplementation_2.ts
////module A {
//// export interface IA {
//// /*Part2Definition*/export interface IA {
//// x: number;
//// }
////
//// var x: /*Part2Use*/IA;
////}
goTo.marker('Part2Use');
goTo.definition();
verify.caretAtMarker('Part1Definition');
verify.goToDefinition("Part2Use", ["Part1Definition", "Part2Definition"]);
@@ -2,7 +2,4 @@
////var x: st/*primitive*/ring;
goTo.marker("primitive");
verify.not.definitionLocationExists();
verify.goToDefinition("primitive", []);
@@ -13,16 +13,4 @@
////class fooCls implements /*localInterfaceReference*/localInterface { }
////var fooVar = /*localModuleReference*/localModule.foo;
var markerList = [
"localVariable",
"localFunction",
"localClass",
"localInterface",
"localModule",
];
markerList.forEach((marker) => {
goTo.marker(marker + 'Reference');
goTo.definition();
verify.caretAtMarker(marker + 'Definition');
});
verify.goToDefinitionForMarkers("localVariable", "localFunction", "localClass", "localInterface", "localModule");
@@ -6,6 +6,4 @@
//// /*shadowVariableReference*/shadowVariable = 1;
////}
goTo.marker('shadowVariableReference');
goTo.definition();
verify.caretAtMarker('shadowVariableDefinition');
verify.goToDefinitionForMarkers("shadowVariable");
@@ -5,6 +5,4 @@
//// /*shadowVariableReference*/shdVar = 1;
////}
goTo.marker('shadowVariableReference');
goTo.definition();
verify.caretAtMarker('shadowVariableDefinition');
verify.goToDefinitionForMarkers("shadowVariable");
@@ -7,19 +7,9 @@
//// obj./*valueReference1*/name;
//// obj./*valueReference2*/id;
goTo.marker("valueDefinition1");
goTo.definition();
verify.caretAtMarker("valueDeclaration1");
goTo.marker("valueDefinition2");
goTo.definition(0);
verify.caretAtMarker("valueDeclaration2");
goTo.definition(1);
verify.caretAtMarker("valueDeclaration3");
goTo.marker("valueReference1");
goTo.definition();
verify.caretAtMarker("valueDefinition1");
goTo.marker("valueReference2");
goTo.definition();
verify.caretAtMarker("valueDefinition2");
verify.goToDefinition({
valueDefinition1: "valueDeclaration1",
valueDefinition2: ["valueDeclaration2", "valueDeclaration3"],
valueReference1: "valueDefinition1",
valueReference2: "valueDefinition2"
});
@@ -4,5 +4,4 @@
//// f/*1*/oo
////}
goTo.marker("1");
verify.not.definitionLocationExists();
verify.goToDefinition("1", []);
@@ -7,10 +7,7 @@
//// /*letProp*/y
////}
goTo.marker("varProp");
goTo.definition();
verify.caretAtMarker("varDef");
goTo.marker("letProp");
goTo.definition();
verify.caretAtMarker("letDef");
verify.goToDefinition({
varProp: "varDef",
letProp: "letDef"
});
@@ -7,10 +7,4 @@
//// var n = new /*1*/c();
//// var n = new c/*3*/();
goTo.marker('1');
goTo.definition();
verify.caretAtMarker('2');
goTo.marker('3');
goTo.definition();
verify.caretAtMarker('2');
verify.goToDefinition(["1", "3"], "2");
@@ -16,9 +16,7 @@
// @Filename: b.ts
/////*fileB*/
goTo.marker("unknownFile");
verify.not.definitionLocationExists();
goTo.marker("knownFile");
goTo.definition();
verify.caretAtMarker('fileB');
verify.goToDefinition({
unknownFile: [],
knownFile: "fileB"
});
@@ -0,0 +1,13 @@
/// <reference path='fourslash.ts' />
/////*defFNumber*/function f(strs: TemplateStringsArray, x: number): void;
/////*defFBool*/function f(strs: TemplateStringsArray, x: boolean): void;
////function f(strs: TemplateStringsArray, x: number | boolean) {}
////
/////*useFNumber*/f`${0}`;
/////*useFBool*/f`${false}`;
verify.goToDefinition({
useFNumber: "defFNumber",
useFBool: "defFBool"
});
+5 -10
View File
@@ -1,6 +1,5 @@
/// <reference path='fourslash.ts'/>
// @noLib: true
////function f(/*fnDecl*/this: number) {
//// return /*fnUse*/this;
////}
@@ -9,12 +8,8 @@
//// get self(/*getterDecl*/this: number) { return /*getterUse*/this; }
////}
function verifyDefinition(a, b) {
goTo.marker(a);
goTo.definition();
verify.caretAtMarker(b);
}
verifyDefinition("fnUse", "fnDecl");
verifyDefinition("clsUse", "cls");
verifyDefinition("getterUse", "getterDecl");
verify.goToDefinition({
"fnUse": "fnDecl",
"clsUse": "cls",
"getterUse": "getterDecl"
});
@@ -5,12 +5,7 @@
//// return typeof parameter === "string";
//// }
goTo.marker('parameterName');
goTo.definition();
verify.caretAtMarker('parameterDeclaration');
goTo.marker('typeReference');
goTo.definition();
verify.caretAtMarker('classDeclaration');
verify.goToDefinition({
parameterName: "parameterDeclaration",
typeReference: "classDeclaration"
});
@@ -8,6 +8,4 @@
//// /// <reference types="lib/*1*/"/>
//// $.x;
goTo.marker("1");
goTo.definition();
verify.caretAtMarker("0");
verify.goToDefinition("1", "0");
@@ -5,7 +5,6 @@
////var x = {}; x.some/*undefinedProperty*/Property;
////var a: any; a.some/*unkownProperty*/Property;
test.markers().forEach((m, i, a) => {
goTo.position(m.position, m.fileName);
verify.not.definitionLocationExists();
});
for (const marker of test.markerNames()) {
verify.goToDefinition(marker, []);
}
@@ -15,12 +15,4 @@
////x./*propertyReference*/commonProperty;
////x./*3*/commonFunction;
goTo.marker("propertyReference");
verify.definitionCountIs(2);
goTo.definition(0);
verify.caretAtMarker("propertyDefinition1");
goTo.marker("propertyReference");
goTo.definition(1);
verify.caretAtMarker("propertyDefinition2");
verify.goToDefinition("propertyReference", ["propertyDefinition1", "propertyDefinition2"]);
@@ -16,11 +16,4 @@
////
////x.common./*propertyReference*/a;
goTo.marker("propertyReference");
verify.definitionCountIs(2);
goTo.definition(0);
verify.caretAtMarker("propertyDefinition2");
goTo.marker("propertyReference");
goTo.definition(1);
verify.caretAtMarker("propertyDefinition1");
verify.goToDefinition("propertyReference", ["propertyDefinition2", "propertyDefinition1"]);
@@ -9,7 +9,4 @@
////
////var x = (strings || numbers)./*usage*/specialPop()
goTo.marker("usage");
verify.definitionCountIs(1);
goTo.definition();
verify.caretAtMarker("definition");
verify.goToDefinition("usage", "definition");
@@ -18,15 +18,4 @@
////
////var x = (snapcrackle || magnitude || art)./*usage*/pop;
goTo.marker("usage");
verify.definitionCountIs(3);
goTo.definition(0);
verify.caretAtMarker("def1");
goTo.marker("usage");
goTo.definition(1);
verify.caretAtMarker("def2");
goTo.marker("usage");
goTo.definition(2);
verify.caretAtMarker("def3");
verify.goToDefinition("usage", ["def1", "def2", "def3"]);

Some files were not shown because too many files have changed in this diff Show More