-
Notifications
You must be signed in to change notification settings - Fork 13k
Make goto-definition go to a signature declaration if possible #10593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4514f8f
Make goto-definition go to a signature declaration if possible
5977473
Support decorators and templates
efc7e9d
Climb past multiple property accesses if necessary
e8e7ec6
Remember to check for existence of `target.parent`
3eadbf6
Rename function
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/cases/fourslash/goToDeclarationDecoratorOverloads.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// @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]() {} | ||
////} | ||
|
||
goTo.marker("useDecString"); | ||
goTo.definition(); | ||
verify.caretAtMarker("defDecString"); | ||
|
||
goTo.marker("useDecSymbol"); | ||
goTo.definition(); | ||
verify.caretAtMarker("defDecSymbol"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/// <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(""); | ||
|
||
goTo.marker("2"); | ||
goTo.definition(); | ||
verify.caretAtMarker("1"); |
16 changes: 16 additions & 0 deletions
16
tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/// <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}`; | ||
|
||
goTo.marker("useFNumber"); | ||
goTo.definition(); | ||
verify.caretAtMarker("defFNumber"); | ||
|
||
goTo.marker("useFBool"); | ||
goTo.definition(); | ||
verify.caretAtMarker("defFBool"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
///<reference path="fourslash.ts"/> | ||
|
||
////class A { | ||
//// /*ctr*/constructor() {} | ||
//// x() {} | ||
////} | ||
/////*B*/class B extends A {} | ||
////class C extends B { | ||
//// constructor() { | ||
//// /*super*/super(); | ||
//// } | ||
//// method() { | ||
//// /*superExpression*/super.x(); | ||
//// } | ||
////} | ||
////class D { | ||
//// constructor() { | ||
//// /*superBroken*/super(); | ||
//// } | ||
////} | ||
|
||
// Super in call position goes to constructor. | ||
goTo.marker("super"); | ||
goTo.definition(); | ||
verify.caretAtMarker("ctr"); | ||
|
||
// Super in any other position goes to the superclass. | ||
goTo.marker("superExpression"); | ||
goTo.definition(); | ||
verify.caretAtMarker("B"); | ||
|
||
goTo.marker("superBroken"); | ||
verify.definitionCountIs(0); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems you are checking
callLike
twiceThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First one is checking whether it exists. Last one is returning it from the function.