-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Add option to exclude library symbols from navTo results #55605
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
11 commits
Select commit
Hold shift + click to select a range
efa6b82
exclude external files in navto
gabritto 80984d9
add new test
gabritto 43233bd
fix preference restoration
gabritto daba2a6
add userpreference option to exclude external files
gabritto 7785394
refactor tests
gabritto 5e739ba
rename option
gabritto c44ff2b
update baselines
gabritto d799de8
improve description of new option
gabritto 9d585d4
update api baselines
gabritto deddc30
fix case of single file mode in lib files
gabritto 41e3ae5
rename option
gabritto 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -314,15 +314,25 @@ export class SessionClient implements LanguageService { | |
return notImplemented(); | ||
} | ||
|
||
getNavigateToItems(searchValue: string): NavigateToItem[] { | ||
getNavigateToItems(searchValue: string, maxResultCount: number, file: string | undefined, _excludeDtsFiles: boolean | undefined, excludeLibFiles: boolean | undefined): NavigateToItem[] { | ||
const args: protocol.NavtoRequestArgs = { | ||
searchValue, | ||
file: this.host.getScriptFileNames()[0], | ||
file, | ||
currentFileOnly: !!file, | ||
maxResultCount, | ||
}; | ||
const oldPreferences = this.preferences; | ||
if (excludeLibFiles) { | ||
this.configure({ excludeLibrarySymbolsInNavTo: true }); | ||
} | ||
|
||
const request = this.processRequest<protocol.NavtoRequest>(protocol.CommandTypes.Navto, args); | ||
const response = this.processResponse<protocol.NavtoResponse>(request); | ||
|
||
if (excludeLibFiles) { | ||
this.configure(oldPreferences || {}); | ||
} | ||
|
||
return response.body!.map(entry => ({ // TODO: GH#18217 | ||
name: entry.name, | ||
containerName: entry.containerName || "", | ||
|
@@ -579,14 +589,13 @@ export class SessionClient implements LanguageService { | |
const providePrefixAndSuffixTextForRename = typeof preferences === "boolean" ? preferences : preferences?.providePrefixAndSuffixTextForRename; | ||
const quotePreference = typeof preferences === "boolean" ? undefined : preferences?.quotePreference; | ||
if (providePrefixAndSuffixTextForRename !== undefined || quotePreference !== undefined) { | ||
const oldPreferences = this.preferences; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other diffs in the file were just a drive-by fix to how we restore preferences for the harness client. I think we don't have tests that observe this though. |
||
// User preferences have to be set through the `Configure` command | ||
this.configure({ providePrefixAndSuffixTextForRename, quotePreference }); | ||
// Options argument is not used, so don't pass in options | ||
this.getRenameInfo(fileName, position, /*preferences*/ {}, findInStrings, findInComments); | ||
// Restore previous user preferences | ||
if (this.preferences) { | ||
this.configure(this.preferences); | ||
} | ||
this.configure(oldPreferences || {}); | ||
} | ||
else { | ||
this.getRenameInfo(fileName, position, /*preferences*/ {}, findInStrings, findInComments); | ||
|
@@ -812,6 +821,7 @@ export class SessionClient implements LanguageService { | |
kind?: string, | ||
includeInteractiveActions?: boolean, | ||
): ApplicableRefactorInfo[] { | ||
const oldPreferences = this.preferences; | ||
if (preferences) { // Temporarily set preferences | ||
this.configure(preferences); | ||
} | ||
|
@@ -822,7 +832,7 @@ export class SessionClient implements LanguageService { | |
const request = this.processRequest<protocol.GetApplicableRefactorsRequest>(protocol.CommandTypes.GetApplicableRefactors, args); | ||
const response = this.processResponse<protocol.GetApplicableRefactorsResponse>(request); | ||
if (preferences) { // Restore preferences | ||
this.configure(this.preferences || {}); | ||
this.configure(oldPreferences || {}); | ||
} | ||
return response.body!; // TODO: GH#18217 | ||
} | ||
|
@@ -844,6 +854,7 @@ export class SessionClient implements LanguageService { | |
preferences: UserPreferences | undefined, | ||
interactiveRefactorArguments?: InteractiveRefactorArguments, | ||
): RefactorEditInfo { | ||
const oldPreferences = this.preferences; | ||
if (preferences) { // Temporarily set preferences | ||
this.configure(preferences); | ||
} | ||
|
@@ -868,7 +879,7 @@ export class SessionClient implements LanguageService { | |
} | ||
|
||
if (preferences) { // Restore preferences | ||
this.configure(this.preferences || {}); | ||
this.configure(oldPreferences || {}); | ||
} | ||
|
||
return { | ||
|
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
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
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 @@ | ||
/// <reference path="fourslash.ts"/> | ||
|
||
// @filename: /index.ts | ||
//// import { weirdName as otherName } from "bar"; | ||
//// const [|weirdName: number = 1|]; | ||
|
||
// @filename: /tsconfig.json | ||
//// {} | ||
|
||
// @filename: /node_modules/bar/index.d.ts | ||
//// export const [|weirdName: number|]; | ||
|
||
// @filename: /node_modules/bar/package.json | ||
//// {} | ||
|
||
|
||
const [weird, otherWeird] = test.ranges(); | ||
|
||
verify.navigateTo({ | ||
pattern: "weirdName", | ||
expected: [{ | ||
name: "weirdName", | ||
kind: "const", | ||
kindModifiers: "export,declare", | ||
range: otherWeird, | ||
matchKind: "exact", | ||
}, | ||
{ | ||
name: "weirdName", | ||
kind: "const", | ||
range: weird, | ||
matchKind: "exact", | ||
}], | ||
}); | ||
|
||
verify.navigateTo({ | ||
pattern: "weirdName", | ||
excludeLibFiles: true, | ||
expected: [{ | ||
name: "weirdName", | ||
kind: "const", | ||
range: weird, | ||
matchKind: "exact", | ||
}], | ||
|
||
}); |
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,32 @@ | ||
/// <reference path="fourslash.ts"/> | ||
|
||
// @filename: /index.ts | ||
//// import { [|someName as weirdName|] } from "bar"; | ||
|
||
// @filename: /tsconfig.json | ||
//// {} | ||
|
||
// @filename: /node_modules/bar/index.d.ts | ||
//// export const someName: number; | ||
|
||
// @filename: /node_modules/bar/package.json | ||
//// {} | ||
|
||
|
||
const [weird] = test.ranges(); | ||
|
||
verify.navigateTo({ | ||
pattern: "weirdName", | ||
expected: [{ | ||
name: "weirdName", | ||
kind: "alias", | ||
range: weird, | ||
matchKind: "exact", | ||
}], | ||
}); | ||
|
||
verify.navigateTo({ | ||
pattern: "weirdName", | ||
excludeLibFiles: true, | ||
expected: [], | ||
}); |
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,19 @@ | ||
/// <reference path="fourslash.ts"/> | ||
|
||
// @filename: /index.ts | ||
//// [|function parseInt(s: string): number {}|] | ||
|
||
const [local] = test.ranges(); | ||
|
||
verify.navigateTo({ | ||
pattern: "parseInt", | ||
excludeLibFiles: true, | ||
expected: [ | ||
{ | ||
name: "parseInt", | ||
kind: "function", | ||
range: local, | ||
matchKind: "exact", | ||
}, | ||
], | ||
}); |
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.
Uh oh!
There was an error while loading. Please reload this page.