This commit is contained in:
Isabel Duan 2024-10-30 21:03:16 -07:00
Родитель 12c318a8bf
Коммит 873188557d
5 изменённых файлов: 832 добавлений и 46 удалений

Просмотреть файл

@ -473,7 +473,11 @@ export function getTypeDefinitionAtPosition(typeChecker: TypeChecker, sourceFile
if (isImportMeta(node.parent) && node.parent.name === node) {
return definitionFromType(typeChecker.getTypeAtLocation(node.parent), typeChecker, node.parent, /*failedAliasResolution*/ false);
}
const { symbol, failedAliasResolution } = getSymbol(node, typeChecker, /*stopAtAlias*/ false);
let { symbol, failedAliasResolution } = getSymbol(node, typeChecker, /*stopAtAlias*/ false);
if (isModifier(node) && (isClassElement(node.parent) || isNamedDeclaration(node.parent))) {
symbol = node.parent.symbol;
failedAliasResolution = false;
}
if (!symbol) return undefined;
const typeAtLocation = typeChecker.getTypeOfSymbolAtLocation(symbol, node);

Просмотреть файл

@ -32,39 +32,7 @@
// === goToDefinition ===
// === /a.ts ===
// <|expo/*GOTO DEF*/rt class [|A|] {
//
// private z: string;
//
// readonly x: string;
//
// async a() { }
//
// override b() {}
//
// public async c() { }
// }|>
//
// export function foo() { }
// === Details ===
[
{
"kind": "class",
"name": "A",
"containerName": "\"/a\"",
"isLocal": false,
"isAmbient": false,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToDefinition ===
// === /a.ts ===
// <|export/*GOTO DEF*/ class [|A|] {
// <|export class [|{| textSpan: true |}A|]/*GOTO DEF*/ {
//
// private z: string;
//
@ -119,6 +87,31 @@
// === goToDefinition ===
// === /a.ts ===
// export class A {
//
// <|private [|{| textSpan: true |}z|]/*GOTO DEF*/: string;|>
//
// readonly x: string;
//
// --- (line: 7) skipped ---
// === Details ===
[
{
"kind": "property",
"name": "z",
"containerName": "A",
"isLocal": true,
"isAmbient": false,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToDefinition ===
// === /a.ts ===
// export class A {
@ -146,6 +139,33 @@
// === goToDefinition ===
// === /a.ts ===
// export class A {
//
// private z: string;
//
// <|readonly [|{| textSpan: true |}x|]/*GOTO DEF*/: string;|>
//
// async a() { }
//
// --- (line: 9) skipped ---
// === Details ===
[
{
"kind": "property",
"name": "x",
"containerName": "A",
"isLocal": false,
"isAmbient": false,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToDefinition ===
// === /a.ts ===
// --- (line: 3) skipped ---
@ -173,6 +193,31 @@
// === goToDefinition ===
// === /a.ts ===
// --- (line: 3) skipped ---
//
// readonly x: string;
//
// <|async [|{| textSpan: true |}a|]/*GOTO DEF*/() { }|>
//
// override b() {}
//
// --- (line: 11) skipped ---
// === Details ===
[
{
"kind": "method",
"name": "a",
"containerName": "A",
"isLocal": false,
"isAmbient": false
}
]
// === goToDefinition ===
// === /a.ts ===
// --- (line: 5) skipped ---
@ -201,6 +246,32 @@
// === goToDefinition ===
// === /a.ts ===
// --- (line: 5) skipped ---
//
// async a() { }
//
// <|override [|{| textSpan: true |}b|]/*GOTO DEF*/() {}|>
//
// public async c() { }
// }
//
// export function foo() { }
// === Details ===
[
{
"kind": "method",
"name": "b",
"containerName": "A",
"isLocal": false,
"isAmbient": false
}
]
// === goToDefinition ===
// === /a.ts ===
// --- (line: 7) skipped ---
@ -275,4 +346,72 @@
"unverified": false,
"failedAliasResolution": false
}
]
// === goToDefinition ===
// === /a.ts ===
// --- (line: 7) skipped ---
//
// override b() {}
//
// <|public async [|{| textSpan: true |}c|]/*GOTO DEF*/() { }|>
// }
//
// export function foo() { }
// === Details ===
[
{
"kind": "method",
"name": "c",
"containerName": "A",
"isLocal": false,
"isAmbient": false
}
]
// === goToDefinition ===
// === /a.ts ===
// --- (line: 10) skipped ---
// public async c() { }
// }
//
// <|exp/*GOTO DEF*/ort function [|foo|]() { }|>
// === Details ===
[
{
"kind": "function",
"name": "foo",
"containerName": "\"/a\"",
"isLocal": false,
"isAmbient": false,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToDefinition ===
// === /a.ts ===
// --- (line: 10) skipped ---
// public async c() { }
// }
//
// <|export function [|{| textSpan: true |}foo|]/*GOTO DEF*/() { }|>
// === Details ===
[
{
"kind": "function",
"name": "foo",
"containerName": "\"/a\"",
"isLocal": false,
"isAmbient": false
}
]

Просмотреть файл

@ -0,0 +1,597 @@
// === goToType ===
// === /a.ts ===
// /*GOTO TYPE*/<|export class [|A|] {
//
// private z: string;
//
// private y: A;
//
// readonly x: string;
//
// async a() { }
//
// override b() {}
//
// public async c() { }
// }|>
//
// export function foo() { }
// === Details ===
[
{
"kind": "class",
"name": "A",
"containerName": "\"/a\"",
"isLocal": false,
"isAmbient": false,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToType ===
// === /a.ts ===
// <|export class [|A|]/*GOTO TYPE*/ {
//
// private z: string;
//
// private y: A;
//
// readonly x: string;
//
// async a() { }
//
// override b() {}
//
// public async c() { }
// }|>
//
// export function foo() { }
// === Details ===
[
{
"kind": "class",
"name": "A",
"containerName": "\"/a\"",
"isLocal": false,
"isAmbient": false,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToType ===
// === /a.ts ===
// export class A {
//
// /*GOTO TYPE*/private z: string;
//
// private y: A;
//
// --- (line: 7) skipped ---
// === goToType ===
// === /a.ts ===
// export class A {
//
// private z/*GOTO TYPE*/: string;
//
// private y: A;
//
// --- (line: 7) skipped ---
// === goToType ===
// === /a.ts ===
// <|export class [|A|] {
//
// private z: string;
//
// /*GOTO TYPE*/private y: A;
//
// readonly x: string;
//
// async a() { }
//
// override b() {}
//
// public async c() { }
// }|>
//
// export function foo() { }
// === Details ===
[
{
"kind": "class",
"name": "A",
"containerName": "\"/a\"",
"isLocal": false,
"isAmbient": false,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToType ===
// === /a.ts ===
// <|export class [|A|] {
//
// private z: string;
//
// private y/*GOTO TYPE*/: A;
//
// readonly x: string;
//
// async a() { }
//
// override b() {}
//
// public async c() { }
// }|>
//
// export function foo() { }
// === Details ===
[
{
"kind": "class",
"name": "A",
"containerName": "\"/a\"",
"isLocal": false,
"isAmbient": false,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToType ===
// === /a.ts ===
// --- (line: 3) skipped ---
//
// private y: A;
//
// /*GOTO TYPE*/readonly x: string;
//
// async a() { }
//
// --- (line: 11) skipped ---
// === goToType ===
// === /a.ts ===
// --- (line: 3) skipped ---
//
// private y: A;
//
// readonly x/*GOTO TYPE*/: string;
//
// async a() { }
//
// --- (line: 11) skipped ---
// === goToType ===
// === lib.d.ts ===
// --- (line: --) skipped ---
// /**
// * Represents the completion of an asynchronous operation
// */
// <|interface [|Promise|]<T> {
// /**
// * Attaches callbacks for the resolution and/or rejection of the Promise.
// * @param onfulfilled The callback to execute when the Promise is resolved.
// * @param onrejected The callback to execute when the Promise is rejected.
// * @returns A Promise for the completion of which ever callback is executed.
// */
// then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
//
// /**
// * Attaches a callback for only the rejection of the Promise.
// * @param onrejected The callback to execute when the Promise is rejected.
// * @returns A Promise for the completion of the callback.
// */
// catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
// }|>
//
// /**
// * Recursively unwraps the "awaited type" of a type. Non-promise "thenables" should resolve to `never`. This emulates the behavior of `await`.
// --- (line: --) skipped ---
// === /a.ts ===
// --- (line: 5) skipped ---
//
// readonly x: string;
//
// /*GOTO TYPE*/async a() { }
//
// override b() {}
//
// --- (line: 13) skipped ---
// === Details ===
[
{
"kind": "interface",
"name": "Promise",
"containerName": "",
"isLocal": false,
"isAmbient": true,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToType ===
// === lib.d.ts ===
// --- (line: --) skipped ---
// /**
// * Represents the completion of an asynchronous operation
// */
// <|interface [|Promise|]<T> {
// /**
// * Attaches callbacks for the resolution and/or rejection of the Promise.
// * @param onfulfilled The callback to execute when the Promise is resolved.
// * @param onrejected The callback to execute when the Promise is rejected.
// * @returns A Promise for the completion of which ever callback is executed.
// */
// then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
//
// /**
// * Attaches a callback for only the rejection of the Promise.
// * @param onrejected The callback to execute when the Promise is rejected.
// * @returns A Promise for the completion of the callback.
// */
// catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
// }|>
//
// /**
// * Recursively unwraps the "awaited type" of a type. Non-promise "thenables" should resolve to `never`. This emulates the behavior of `await`.
// --- (line: --) skipped ---
// === /a.ts ===
// --- (line: 5) skipped ---
//
// readonly x: string;
//
// async a/*GOTO TYPE*/() { }
//
// override b() {}
//
// --- (line: 13) skipped ---
// === Details ===
[
{
"kind": "interface",
"name": "Promise",
"containerName": "",
"isLocal": false,
"isAmbient": true,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToType ===
// === /a.ts ===
// --- (line: 7) skipped ---
//
// async a() { }
//
// /*GOTO TYPE*/<|override [|b|]() {}|>
//
// public async c() { }
// }
//
// export function foo() { }
// === Details ===
[
{
"kind": "method",
"name": "b",
"containerName": "A",
"isLocal": false,
"isAmbient": false,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToType ===
// === /a.ts ===
// --- (line: 7) skipped ---
//
// async a() { }
//
// <|override [|b|]/*GOTO TYPE*/() {}|>
//
// public async c() { }
// }
//
// export function foo() { }
// === Details ===
[
{
"kind": "method",
"name": "b",
"containerName": "A",
"isLocal": false,
"isAmbient": false
}
]
// === goToType ===
// === lib.d.ts ===
// --- (line: --) skipped ---
// /**
// * Represents the completion of an asynchronous operation
// */
// <|interface [|Promise|]<T> {
// /**
// * Attaches callbacks for the resolution and/or rejection of the Promise.
// * @param onfulfilled The callback to execute when the Promise is resolved.
// * @param onrejected The callback to execute when the Promise is rejected.
// * @returns A Promise for the completion of which ever callback is executed.
// */
// then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
//
// /**
// * Attaches a callback for only the rejection of the Promise.
// * @param onrejected The callback to execute when the Promise is rejected.
// * @returns A Promise for the completion of the callback.
// */
// catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
// }|>
//
// /**
// * Recursively unwraps the "awaited type" of a type. Non-promise "thenables" should resolve to `never`. This emulates the behavior of `await`.
// --- (line: --) skipped ---
// === /a.ts ===
// --- (line: 9) skipped ---
//
// override b() {}
//
// /*GOTO TYPE*/public async c() { }
// }
//
// export function foo() { }
// === Details ===
[
{
"kind": "interface",
"name": "Promise",
"containerName": "",
"isLocal": false,
"isAmbient": true,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToType ===
// === lib.d.ts ===
// --- (line: --) skipped ---
// /**
// * Represents the completion of an asynchronous operation
// */
// <|interface [|Promise|]<T> {
// /**
// * Attaches callbacks for the resolution and/or rejection of the Promise.
// * @param onfulfilled The callback to execute when the Promise is resolved.
// * @param onrejected The callback to execute when the Promise is rejected.
// * @returns A Promise for the completion of which ever callback is executed.
// */
// then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
//
// /**
// * Attaches a callback for only the rejection of the Promise.
// * @param onrejected The callback to execute when the Promise is rejected.
// * @returns A Promise for the completion of the callback.
// */
// catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
// }|>
//
// /**
// * Recursively unwraps the "awaited type" of a type. Non-promise "thenables" should resolve to `never`. This emulates the behavior of `await`.
// --- (line: --) skipped ---
// === /a.ts ===
// --- (line: 9) skipped ---
//
// override b() {}
//
// public/*GOTO TYPE*/ async c() { }
// }
//
// export function foo() { }
// === Details ===
[
{
"kind": "interface",
"name": "Promise",
"containerName": "",
"isLocal": false,
"isAmbient": true,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToType ===
// === lib.d.ts ===
// --- (line: --) skipped ---
// /**
// * Represents the completion of an asynchronous operation
// */
// <|interface [|Promise|]<T> {
// /**
// * Attaches callbacks for the resolution and/or rejection of the Promise.
// * @param onfulfilled The callback to execute when the Promise is resolved.
// * @param onrejected The callback to execute when the Promise is rejected.
// * @returns A Promise for the completion of which ever callback is executed.
// */
// then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
//
// /**
// * Attaches a callback for only the rejection of the Promise.
// * @param onrejected The callback to execute when the Promise is rejected.
// * @returns A Promise for the completion of the callback.
// */
// catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
// }|>
//
// /**
// * Recursively unwraps the "awaited type" of a type. Non-promise "thenables" should resolve to `never`. This emulates the behavior of `await`.
// --- (line: --) skipped ---
// === /a.ts ===
// --- (line: 9) skipped ---
//
// override b() {}
//
// public as/*GOTO TYPE*/ync c() { }
// }
//
// export function foo() { }
// === Details ===
[
{
"kind": "interface",
"name": "Promise",
"containerName": "",
"isLocal": false,
"isAmbient": true,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToType ===
// === lib.d.ts ===
// --- (line: --) skipped ---
// /**
// * Represents the completion of an asynchronous operation
// */
// <|interface [|Promise|]<T> {
// /**
// * Attaches callbacks for the resolution and/or rejection of the Promise.
// * @param onfulfilled The callback to execute when the Promise is resolved.
// * @param onrejected The callback to execute when the Promise is rejected.
// * @returns A Promise for the completion of which ever callback is executed.
// */
// then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
//
// /**
// * Attaches a callback for only the rejection of the Promise.
// * @param onrejected The callback to execute when the Promise is rejected.
// * @returns A Promise for the completion of the callback.
// */
// catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
// }|>
//
// /**
// * Recursively unwraps the "awaited type" of a type. Non-promise "thenables" should resolve to `never`. This emulates the behavior of `await`.
// --- (line: --) skipped ---
// === /a.ts ===
// --- (line: 9) skipped ---
//
// override b() {}
//
// public async c/*GOTO TYPE*/() { }
// }
//
// export function foo() { }
// === Details ===
[
{
"kind": "interface",
"name": "Promise",
"containerName": "",
"isLocal": false,
"isAmbient": true,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToType ===
// === /a.ts ===
// --- (line: 12) skipped ---
// public async c() { }
// }
//
// <|exp/*GOTO TYPE*/ort function [|foo|]() { }|>
// === Details ===
[
{
"kind": "function",
"name": "foo",
"containerName": "\"/a\"",
"isLocal": false,
"isAmbient": false,
"unverified": false,
"failedAliasResolution": false
}
]
// === goToType ===
// === /a.ts ===
// --- (line: 12) skipped ---
// public async c() { }
// }
//
// <|export function [|foo|]/*GOTO TYPE*/() { }|>
// === Details ===
[
{
"kind": "function",
"name": "foo",
"containerName": "\"/a\"",
"isLocal": false,
"isAmbient": false
}
]

Просмотреть файл

@ -1,30 +1,36 @@
/// <reference path='fourslash.ts'/>
// @Filename: /a.ts
//// /*export1*/expo/*export2*/rt/*export3*/ class A {
//// /*export*/export class A/*A*/ {
////
//// /*private*/private z: string;
//// /*private*/private z/*z*/: string;
////
//// /*readonly*/readonly x/*x*/: string;
////
//// /*readonly*/readonly x: string;
//// /*async*/async a/*a*/() { }
////
//// /*async*/async a() { }
//// /*override*/override b/*b*/() {}
////
//// /*override*/override b() {}
////
//// /*public1*/public/*public2*/ as/*multipleModifiers*/ync c() { }
//// /*public1*/public/*public2*/ as/*multipleModifiers*/ync c/*c*/() { }
//// }
////
//// exp/**/ort function foo() { }
//// exp/*exportFunction*/ort function foo/*foo*/() { }
verify.baselineGoToDefinition(
"export1",
"export2",
"export3",
"export",
"A",
"private",
"z",
"readonly",
"x",
"async",
"a",
"override",
"b",
"public1",
"public2",
"multipleModifiers"
"multipleModifiers",
"c",
"exportFunction",
"foo"
);

Просмотреть файл

@ -0,0 +1,40 @@
/// <reference path='fourslash.ts'/>
// @Filename: /a.ts
//// /*export*/export class A/*A*/ {
////
//// /*private*/private z/*z*/: string;
////
//// /*private2*/private y/*y*/: A;
////
//// /*readonly*/readonly x/*x*/: string;
////
//// /*async*/async a/*a*/() { }
////
//// /*override*/override b/*b*/() {}
////
//// /*public1*/public/*public2*/ as/*multipleModifiers*/ync c/*c*/() { }
//// }
////
//// exp/*exportFunction*/ort function foo/*foo*/() { }
verify.baselineGoToType(
"export",
"A",
"private",
"z",
"private2",
"y",
"readonly",
"x",
"async",
"a",
"override",
"b",
"public1",
"public2",
"multipleModifiers",
"c",
"exportFunction",
"foo"
);