-
Notifications
You must be signed in to change notification settings - Fork 871
Properly track first Quick Info declaration + fix issue in fourslash #2641
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
7 commits
Select commit
Hold shift + click to select a range
3df5c67
Consistently track first Quick Info declaration
ahejlsberg 50b1c6b
Fix bug in fourslash
ahejlsberg 325914e
Add test
ahejlsberg 59b8105
Accept new baselines
ahejlsberg 4a89dca
Fix formatting
ahejlsberg 7e44a2c
Update failing tests
ahejlsberg 020f0a7
Accept new baselines
ahejlsberg 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
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,46 @@ | ||
| package fourslash_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/microsoft/typescript-go/internal/fourslash" | ||
| "github.com/microsoft/typescript-go/internal/testutil" | ||
| ) | ||
|
|
||
| func TestQuickInfoMergedAlias(t *testing.T) { | ||
| fourslash.SkipIfFailing(t) | ||
| t.Parallel() | ||
| defer testutil.RecoverAndFail(t, "Panic on fourslash test") | ||
| const content = `// @filename: /a.ts | ||
| /** | ||
| * A function | ||
| */ | ||
| export function foo/*1*/() {} | ||
| // @filename: /b.ts | ||
| import { foo/*2*/ } from './a'; | ||
| export { foo/*3*/ }; | ||
|
|
||
| /** | ||
| * A type | ||
| */ | ||
| type foo/*4*/ = number; | ||
|
|
||
| foo/*5*/() | ||
| let x1: foo/*6*/; | ||
| // @filename: /c.ts | ||
| import { foo/*7*/ } from './b'; | ||
|
|
||
| /** | ||
| * A namespace | ||
| */ | ||
| namespace foo/*8*/ { | ||
| export type bar = string[]; | ||
| } | ||
|
|
||
| foo/*9*/() | ||
| let x1: foo/*10*/; | ||
| let x2: foo/*11*/.bar;` | ||
| f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) | ||
| defer done() | ||
| f.VerifyBaselineHover(t) | ||
| } |
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
56 changes: 56 additions & 0 deletions
56
testdata/baselines/reference/fourslash/quickInfo/jsdocLink2.baseline
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,56 @@ | ||
| // === QuickInfo === | ||
| === /script.ts === | ||
| // /** | ||
| // * {@link C} | ||
| // * @wat Makes a {@link C}. A default one. | ||
| // * {@link C()} | ||
| // * {@link C|postfix text} | ||
| // * {@link unformatted postfix text} | ||
| // * @see {@link C} its great | ||
| // */ | ||
| // function CC() { | ||
| // ^^ | ||
| // | ---------------------------------------------------------------------- | ||
| // | ```tsx | ||
| // | function CC(): void | ||
| // | ``` | ||
| // | [C](file:///jsdocLink2.ts#1,7-1,8) | ||
| // | | ||
| // | *@wat* — Makes a [C](file:///jsdocLink2.ts#1,7-1,8). A default one. | ||
| // | [C()](file:///jsdocLink2.ts#1,7-1,8) | ||
| // | [postfix text](file:///jsdocLink2.ts#1,7-1,8) | ||
| // | unformatted postfix text | ||
| // | | ||
| // | *@see* — [C](file:///jsdocLink2.ts#1,7-1,8) its great | ||
| // | | ||
| // | ---------------------------------------------------------------------- | ||
| // } | ||
| [ | ||
| { | ||
| "marker": { | ||
| "Position": 177, | ||
| "LSPosition": { | ||
| "line": 8, | ||
| "character": 9 | ||
| }, | ||
| "Name": "", | ||
| "Data": {} | ||
| }, | ||
| "item": { | ||
| "contents": { | ||
| "kind": "markdown", | ||
| "value": "```tsx\nfunction CC(): void\n```\n[C](file:///jsdocLink2.ts#1,7-1,8)\n\n*@wat* — Makes a [C](file:///jsdocLink2.ts#1,7-1,8). A default one.\n[C()](file:///jsdocLink2.ts#1,7-1,8)\n[postfix text](file:///jsdocLink2.ts#1,7-1,8)\nunformatted postfix text\n\n*@see* — [C](file:///jsdocLink2.ts#1,7-1,8) its great\n" | ||
| }, | ||
| "range": { | ||
| "start": { | ||
| "line": 8, | ||
| "character": 9 | ||
| }, | ||
| "end": { | ||
| "line": 8, | ||
| "character": 11 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] |
Oops, something went wrong.
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.
I get checking the alias level, but why do we need to check if
b.Len() != 0here?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.
The check is here such that we reach the subsequent logic only when
aliasLevelis zero and nothing has been output yet. In that case we want to do a final sanity check where we output any meaning of the symbol, even ifgetMeaningFromLocationdoesn't indicate it. There are cases wheregetMeaningFromLocationreturns "wrong" results because of errors in the source file, for example during completion (and completion actually invokes Quick Info).