-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Actual signature help trigger filtering #25422
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
6 commits
Select commit
Hold shift + click to select a range
dc6653e
Renamed test.
DanielRosenwasser 3e38693
Amend test for comments, other string types.
DanielRosenwasser 0fd587a
Account for comments.
DanielRosenwasser 53a0f23
Remove 'name' property which was invalid.
DanielRosenwasser a3b2237
Added tests for syntactic context.
DanielRosenwasser 9481faa
Only provide signature help contextually on a character trigger.
DanielRosenwasser 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
23 changes: 0 additions & 23 deletions
23
tests/cases/fourslash/signatureHelpFilteredTriggerCharacters01.ts
This file was deleted.
Oops, something went wrong.
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,31 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
////function foo<T>(x: T): T { | ||
//// throw null; | ||
////} | ||
//// | ||
////foo("/*1*/"); | ||
////foo('/*2*/'); | ||
////foo(` ${100}/*3*/`); | ||
////foo(/* /*4*/ */); | ||
////foo( | ||
//// ///*5*/ | ||
////); | ||
|
||
for (const marker of test.markers()) { | ||
goTo.marker(marker); | ||
for (const triggerCharacter of ["<", "(", ","]) { | ||
edit.insert(triggerCharacter); | ||
verify.noSignatureHelpForTriggerReason({ | ||
kind: "characterTyped", | ||
triggerCharacter, | ||
}); | ||
verify.signatureHelpPresentForTriggerReason({ | ||
kind: "retrigger", | ||
triggerCharacter, | ||
}); | ||
edit.backspace(); | ||
} | ||
verify.signatureHelpPresentForTriggerReason(/*triggerReason*/ undefined); | ||
verify.signatureHelpPresentForTriggerReason({ kind: "invoked" }); | ||
} |
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,36 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
////function foo<T>(x: T): T { | ||
//// throw null; | ||
////} | ||
//// | ||
////foo(/*1*/""); | ||
////foo(` ${100/*2*/}`); | ||
////foo(/*3*/); | ||
////foo(100 /*4*/) | ||
////foo([/*5*/]) | ||
////foo({ hello: "hello"/*6*/}) | ||
|
||
const charMap = { | ||
1: "(", | ||
2: ",", | ||
3: "(", | ||
4: "<", | ||
5: ",", | ||
6: ",", | ||
} | ||
|
||
for (const markerName of Object.keys(charMap)) { | ||
const triggerCharacter = charMap[markerName]; | ||
goTo.marker(markerName); | ||
edit.insert(triggerCharacter); | ||
verify.noSignatureHelpForTriggerReason({ | ||
kind: "characterTyped", | ||
triggerCharacter, | ||
}); | ||
verify.signatureHelpPresentForTriggerReason({ | ||
kind: "retrigger", | ||
triggerCharacter, | ||
}); | ||
edit.backspace(triggerCharacter.length); | ||
} |
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,23 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
////declare class ViewJayEss { | ||
//// constructor(obj: object); | ||
////} | ||
////new ViewJayEss({ | ||
//// methods: { | ||
//// sayHello/**/ | ||
//// } | ||
////}); | ||
|
||
goTo.marker(); | ||
edit.insert("("); | ||
verify.noSignatureHelpForTriggerReason({ | ||
kind: "characterTyped", | ||
triggerCharacter: "(", | ||
}); | ||
|
||
edit.insert(") {},"); | ||
verify.noSignatureHelpForTriggerReason({ | ||
kind: "characterTyped", | ||
triggerCharacter: ",", | ||
}); |
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,31 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
////declare function foo<T>(x: T, y: T): T; | ||
//// | ||
////foo/*1*//*2*/; | ||
////foo(/*3*/100/*4*/); | ||
////foo/*5*//*6*/(); | ||
|
||
const charMap = { | ||
1: "(", | ||
2: "<", | ||
3: ",", | ||
4: ",", | ||
5: "(", | ||
6: "<", | ||
} | ||
|
||
for (const markerName of Object.keys(charMap)) { | ||
const triggerCharacter = charMap[markerName]; | ||
goTo.marker(markerName); | ||
edit.insert(triggerCharacter); | ||
verify.signatureHelpPresentForTriggerReason({ | ||
kind: "characterTyped", | ||
triggerCharacter, | ||
}); | ||
verify.signatureHelpPresentForTriggerReason({ | ||
kind: "retrigger", | ||
triggerCharacter, | ||
}); | ||
edit.backspace(triggerCharacter.length); | ||
} |
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,38 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
////declare function foo<T>(x: T, y: T): T; | ||
////declare function bar<U>(x: U, y: U): U; | ||
//// | ||
////foo(bar/*1*/) | ||
|
||
goTo.marker("1"); | ||
|
||
edit.insert("("); | ||
verify.signatureHelp({ | ||
text: "bar<U>(x: U, y: U): U", | ||
triggerReason: { | ||
kind: "characterTyped", | ||
triggerCharacter: "(", | ||
} | ||
}); | ||
edit.backspace(); | ||
|
||
edit.insert("<"); | ||
verify.signatureHelp({ | ||
text: "bar<U>(x: U, y: U): U", | ||
triggerReason: { | ||
kind: "characterTyped", | ||
triggerCharacter: "(", | ||
} | ||
}); | ||
edit.backspace(); | ||
|
||
edit.insert(","); | ||
verify.signatureHelp({ | ||
text: "foo(x: <U>(x: U, y: U) => U, y: <U>(x: U, y: U) => U): <U>(x: U, y: U) => U", | ||
triggerReason: { | ||
kind: "characterTyped", | ||
triggerCharacter: "(", | ||
} | ||
}); | ||
edit.backspace(); |
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.
You should
return ts.Debug.fail("Unexpected key " + key);
, probably.Uh oh!
There was an error while loading. Please reload this page.
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.
I usually only do that when the compiler needs to know more about reachability, but I don't think it's necessary here unless I'm missing something.
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.
We were talking about making it a lint rule a few weeks ago, that way the reachability graph is more complete and may expose more logic bugs (eg, can a following if statement never actually occur because of the implied throw here).