From efa6b822d136f211eb5db13d40905513e23a1f3b Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Thu, 31 Aug 2023 17:34:03 -0700 Subject: [PATCH 01/11] exclude external files in navto --- src/harness/fourslashImpl.ts | 4 +- src/harness/fourslashInterfaceImpl.ts | 1 + src/services/navigateTo.ts | 25 ++++++++--- src/services/services.ts | 4 +- src/services/types.ts | 2 +- tests/cases/fourslash/fourslash.ts | 1 + .../cases/fourslash/navto_excludeExternal1.ts | 42 +++++++++++++++++++ .../cases/fourslash/navto_excludeExternal2.ts | 29 +++++++++++++ 8 files changed, 97 insertions(+), 11 deletions(-) create mode 100644 tests/cases/fourslash/navto_excludeExternal1.ts create mode 100644 tests/cases/fourslash/navto_excludeExternal2.ts diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts index aff225aec806b..080a82295dd2e 100644 --- a/src/harness/fourslashImpl.ts +++ b/src/harness/fourslashImpl.ts @@ -3765,9 +3765,9 @@ export class TestState { } public verifyNavigateTo(options: readonly FourSlashInterface.VerifyNavigateToOptions[]): void { - for (const { pattern, expected, fileName } of options) { + for (const { pattern, expected, fileName, excludeExternalFiles } of options) { const file = fileName && this.findFile(fileName).fileName; - const items = this.languageService.getNavigateToItems(pattern, /*maxResultCount*/ undefined, file); + const items = this.languageService.getNavigateToItems(pattern, /*maxResultCount*/ undefined, file, /*excludeDtsFiles*/ undefined, excludeExternalFiles); this.assertObjectsEqual( items, expected.map((e): ts.NavigateToItem => ({ diff --git a/src/harness/fourslashInterfaceImpl.ts b/src/harness/fourslashInterfaceImpl.ts index 6a15ca0a3ff09..262bf0ee04da5 100644 --- a/src/harness/fourslashInterfaceImpl.ts +++ b/src/harness/fourslashInterfaceImpl.ts @@ -1809,6 +1809,7 @@ export interface VerifyNavigateToOptions { readonly pattern: string; readonly fileName?: string; readonly expected: readonly ExpectedNavigateToItem[]; + readonly excludeExternalFiles?: boolean; } export interface ExpectedNavigateToItem { diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 873bba76e9278..7b549616af1b7 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -16,6 +16,7 @@ import { ImportClause, ImportEqualsDeclaration, ImportSpecifier, + isInsideNodeModules, isPropertyAccessExpression, isPropertyNameLiteral, NavigateToItem, @@ -37,7 +38,7 @@ interface RawNavigateToItem { } /** @internal */ -export function getNavigateToItems(sourceFiles: readonly SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number | undefined, excludeDtsFiles: boolean): NavigateToItem[] { +export function getNavigateToItems(sourceFiles: readonly SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number | undefined, excludeDtsFiles: boolean, excludeExternalFiles?: boolean): NavigateToItem[] { const patternMatcher = createPatternMatcher(searchValue); if (!patternMatcher) return emptyArray; const rawItems: RawNavigateToItem[] = []; @@ -50,8 +51,12 @@ export function getNavigateToItems(sourceFiles: readonly SourceFile[], checker: continue; } + if (shouldExcludeFile(sourceFile, !!excludeExternalFiles)) { + continue; + } + sourceFile.getNamedDeclarations().forEach((declarations, name) => { - getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, sourceFile.fileName, rawItems); + getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, sourceFile.fileName, !!excludeExternalFiles, rawItems); }); } @@ -59,7 +64,14 @@ export function getNavigateToItems(sourceFiles: readonly SourceFile[], checker: return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem); } -function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: string, declarations: readonly Declaration[], checker: TypeChecker, fileName: string, rawItems: RawNavigateToItem[]): void { +/** + * Exclude 'node_modules/' files and standard library files if 'excludeExternalFiles' is true. + */ +function shouldExcludeFile(file: SourceFile, excludeExternalFiles: boolean): boolean { + return excludeExternalFiles && (isInsideNodeModules(file.path) || file.hasNoDefaultLib); +} + +function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: string, declarations: readonly Declaration[], checker: TypeChecker, fileName: string, excludeExternalFiles: boolean, rawItems: RawNavigateToItem[]): void { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. const match = patternMatcher.getMatchForLastSegmentOfPattern(name); @@ -68,7 +80,7 @@ function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: stri } for (const declaration of declarations) { - if (!shouldKeepItem(declaration, checker)) continue; + if (!shouldKeepItem(declaration, checker, excludeExternalFiles)) continue; if (patternMatcher.patternContainsDots) { // If the pattern has dots in it, then also see if the declaration container matches as well. @@ -83,14 +95,15 @@ function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: stri } } -function shouldKeepItem(declaration: Declaration, checker: TypeChecker): boolean { +function shouldKeepItem(declaration: Declaration, checker: TypeChecker, excludeExternalFiles: boolean): boolean { switch (declaration.kind) { case SyntaxKind.ImportClause: case SyntaxKind.ImportSpecifier: case SyntaxKind.ImportEqualsDeclaration: const importer = checker.getSymbolAtLocation((declaration as ImportClause | ImportSpecifier | ImportEqualsDeclaration).name!)!; // TODO: GH#18217 const imported = checker.getAliasedSymbol(importer); - return importer.escapedName !== imported.escapedName; + return importer.escapedName !== imported.escapedName + && !imported.declarations?.some(d => shouldExcludeFile(d.getSourceFile(), excludeExternalFiles)); default: return true; } diff --git a/src/services/services.ts b/src/services/services.ts index 44d93e544d0ba..7cd249b419128 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2192,10 +2192,10 @@ export function createLanguageService( return FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(FindAllReferences.toReferenceEntry); } - function getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles = false): NavigateToItem[] { + function getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles = false, excludeExternalFiles = false): NavigateToItem[] { synchronizeHostData(); const sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); - return NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); + return NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles, excludeExternalFiles); } function getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean, forceDtsEmit?: boolean) { diff --git a/src/services/types.ts b/src/services/types.ts index 9c1fe3a73eb73..edef20cb8c7c8 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -594,7 +594,7 @@ export interface LanguageService { getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined; getFileReferences(fileName: string): ReferenceEntry[]; - getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; + getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean, excludeExternalFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 87f0019695c37..eeb09b48f82c8 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -811,6 +811,7 @@ declare namespace FourSlashInterface { readonly pattern: string; readonly fileName?: string; readonly expected: ReadonlyArray; + readonly excludeExternalFiles?: boolean; } interface ExpectedNavigateToItem { readonly name: string; diff --git a/tests/cases/fourslash/navto_excludeExternal1.ts b/tests/cases/fourslash/navto_excludeExternal1.ts new file mode 100644 index 0000000000000..f0a9471516898 --- /dev/null +++ b/tests/cases/fourslash/navto_excludeExternal1.ts @@ -0,0 +1,42 @@ +/// + +// @filename: /index.ts +//// const [|weirdName: number = 1|]; + +// @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", + range: weird, + matchKind: "exact", + }, + { + name: "weirdName", + kind: "const", + kindModifiers: "export,declare", + range: otherWeird, + matchKind: "exact", + }], +}); + +verify.navigateTo({ + pattern: "weirdName", + excludeExternalFiles: true, + expected: [{ + name: "weirdName", + kind: "const", + range: weird, + matchKind: "exact", + }], + +}); \ No newline at end of file diff --git a/tests/cases/fourslash/navto_excludeExternal2.ts b/tests/cases/fourslash/navto_excludeExternal2.ts new file mode 100644 index 0000000000000..23c5821f7e2ef --- /dev/null +++ b/tests/cases/fourslash/navto_excludeExternal2.ts @@ -0,0 +1,29 @@ +/// + +// @filename: /index.ts +//// import { [|someName as weirdName|] } from "bar"; + +// @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", + excludeExternalFiles: true, + expected: [], +}); \ No newline at end of file From 80984d9d674c054ad9f45d4024261c2c8200c9f9 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 1 Sep 2023 11:10:53 -0700 Subject: [PATCH 02/11] add new test --- .../cases/fourslash/navto_excludeExternal3.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/cases/fourslash/navto_excludeExternal3.ts diff --git a/tests/cases/fourslash/navto_excludeExternal3.ts b/tests/cases/fourslash/navto_excludeExternal3.ts new file mode 100644 index 0000000000000..dfd3c5409c4e0 --- /dev/null +++ b/tests/cases/fourslash/navto_excludeExternal3.ts @@ -0,0 +1,19 @@ +/// + +// @filename: /index.ts +//// [|function parseInt(s: string): number {}|] + +const [local] = test.ranges(); + +verify.navigateTo({ + pattern: "parseInt", + excludeExternalFiles: true, + expected: [ + { + name: "parseInt", + kind: "function", + range: local, + matchKind: "exact", + }, + ], +}); \ No newline at end of file From 43233bd8a3e8fa02a83a94139566a4e8863af07a Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 1 Sep 2023 13:27:50 -0700 Subject: [PATCH 03/11] fix preference restoration --- src/harness/client.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/harness/client.ts b/src/harness/client.ts index 6f3a3cf9bbac5..91dfb9eec312e 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -579,14 +579,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; // 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 +811,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 +822,7 @@ export class SessionClient implements LanguageService { const request = this.processRequest(protocol.CommandTypes.GetApplicableRefactors, args); const response = this.processResponse(request); if (preferences) { // Restore preferences - this.configure(this.preferences || {}); + this.configure(oldPreferences || {}); } return response.body!; // TODO: GH#18217 } @@ -844,6 +844,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 +869,7 @@ export class SessionClient implements LanguageService { } if (preferences) { // Restore preferences - this.configure(this.preferences || {}); + this.configure(oldPreferences || {}); } return { From daba2a642db3cad3646b158c6403c003160c8d5d Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 1 Sep 2023 14:14:39 -0700 Subject: [PATCH 04/11] add userpreference option to exclude external files --- src/compiler/types.ts | 1 + src/harness/client.ts | 14 +++++- src/server/protocol.ts | 5 +++ src/server/session.ts | 9 +++- .../server/navto_serverExcludeExternal.ts | 45 +++++++++++++++++++ 5 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 tests/cases/fourslash/server/navto_serverExcludeExternal.ts diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 14575e7f1733d..1b07d9803d62b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -9936,6 +9936,7 @@ export interface UserPreferences { readonly organizeImportsNumericCollation?: boolean; readonly organizeImportsAccentCollation?: boolean; readonly organizeImportsCaseFirst?: "upper" | "lower" | false; + readonly excludeExternalFileSymbols?: boolean; } /** Represents a bigint literal value without requiring bigint support */ diff --git a/src/harness/client.ts b/src/harness/client.ts index 91dfb9eec312e..8bfb2eca7fec0 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -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, excludeExternalFiles: boolean | undefined): NavigateToItem[] { const args: protocol.NavtoRequestArgs = { searchValue, - file: this.host.getScriptFileNames()[0], + file, + currentFileOnly: !!file, + maxResultCount, }; + const oldPreferences = this.preferences; + if (excludeExternalFiles) { + this.configure({ excludeExternalFileSymbols: true }); + } const request = this.processRequest(protocol.CommandTypes.Navto, args); const response = this.processResponse(request); + if (excludeExternalFiles) { + this.configure(oldPreferences || {}); + } + return response.body!.map(entry => ({ // TODO: GH#18217 name: entry.name, containerName: entry.containerName || "", diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 1b0624497ef6c..46bcfcdd417f0 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -3599,6 +3599,11 @@ export interface UserPreferences { * Indicates whether {@link ReferencesResponseItem.lineText} is supported. */ readonly disableLineTextInReferences?: boolean; + + /** + * Indicates whether to exclude standard library and node_modules files from navTo results. + */ + readonly excludeExternalFileSymbols?: boolean; } export interface CompilerOptions { diff --git a/src/server/session.ts b/src/server/session.ts index 39a57df5ebfcf..6eee665bcc15f 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -2613,6 +2613,7 @@ export class Session implements EventSender { const { file, project } = this.getFileAndProject(args as protocol.FileRequestArgs); return [{ project, navigateToItems: project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, file) }]; } + const preferences = this.getHostPreferences(); const outputs: ProjectNavigateToItems[] = []; @@ -2646,7 +2647,13 @@ export class Session implements EventSender { // Mutates `outputs` function addItemsForProject(project: Project) { - const projectItems = project.getLanguageService().getNavigateToItems(searchValue, maxResultCount, /*fileName*/ undefined, /*excludeDts*/ project.isNonTsProject()); + const projectItems = project.getLanguageService().getNavigateToItems( + searchValue, + maxResultCount, + /*fileName*/ undefined, + /*excludeDts*/ project.isNonTsProject(), + /*excludeExternalFiles*/ preferences.excludeExternalFileSymbols, + ); const unseenItems = filter(projectItems, item => tryAddSeenItem(item) && !getMappedLocationForProject(documentSpanLocation(item), project)); if (unseenItems.length) { outputs.push({ project, navigateToItems: unseenItems }); diff --git a/tests/cases/fourslash/server/navto_serverExcludeExternal.ts b/tests/cases/fourslash/server/navto_serverExcludeExternal.ts new file mode 100644 index 0000000000000..a4cf43592e212 --- /dev/null +++ b/tests/cases/fourslash/server/navto_serverExcludeExternal.ts @@ -0,0 +1,45 @@ +/// + +// @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", + excludeExternalFiles: true, + expected: [{ + name: "weirdName", + kind: "const", + range: weird, + matchKind: "exact", + }], +}); \ No newline at end of file From 778539429a14b1b1d67bc018ffbd75efeaa29a93 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 1 Sep 2023 14:25:22 -0700 Subject: [PATCH 05/11] refactor tests --- tests/cases/fourslash/navto_excludeExternal1.ts | 10 +++++++--- tests/cases/fourslash/navto_excludeExternal2.ts | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/cases/fourslash/navto_excludeExternal1.ts b/tests/cases/fourslash/navto_excludeExternal1.ts index f0a9471516898..6c52710c83f84 100644 --- a/tests/cases/fourslash/navto_excludeExternal1.ts +++ b/tests/cases/fourslash/navto_excludeExternal1.ts @@ -1,8 +1,12 @@ /// // @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|]; @@ -17,14 +21,14 @@ verify.navigateTo({ expected: [{ name: "weirdName", kind: "const", - range: weird, + kindModifiers: "export,declare", + range: otherWeird, matchKind: "exact", }, { name: "weirdName", kind: "const", - kindModifiers: "export,declare", - range: otherWeird, + range: weird, matchKind: "exact", }], }); diff --git a/tests/cases/fourslash/navto_excludeExternal2.ts b/tests/cases/fourslash/navto_excludeExternal2.ts index 23c5821f7e2ef..fa7d6628770d2 100644 --- a/tests/cases/fourslash/navto_excludeExternal2.ts +++ b/tests/cases/fourslash/navto_excludeExternal2.ts @@ -3,6 +3,9 @@ // @filename: /index.ts //// import { [|someName as weirdName|] } from "bar"; +// @filename: /tsconfig.json +//// {} + // @filename: /node_modules/bar/index.d.ts //// export const someName: number; From 5e739bac1a9ad97b975ddec1b6f7eef26a944d4a Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 1 Sep 2023 14:47:52 -0700 Subject: [PATCH 06/11] rename option --- src/compiler/types.ts | 2 +- src/harness/client.ts | 8 ++++---- src/harness/fourslashImpl.ts | 4 ++-- src/harness/fourslashInterfaceImpl.ts | 2 +- src/server/protocol.ts | 2 +- src/server/session.ts | 2 +- src/services/navigateTo.ts | 20 +++++++++---------- src/services/services.ts | 4 ++-- src/services/types.ts | 2 +- tests/cases/fourslash/fourslash.ts | 2 +- ...cludeExternal1.ts => navto_excludeLib1.ts} | 2 +- ...cludeExternal2.ts => navto_excludeLib2.ts} | 2 +- ...cludeExternal3.ts => navto_excludeLib3.ts} | 2 +- ...eExternal.ts => navto_serverExcludeLib.ts} | 2 +- 14 files changed, 28 insertions(+), 28 deletions(-) rename tests/cases/fourslash/{navto_excludeExternal1.ts => navto_excludeLib1.ts} (92%) rename tests/cases/fourslash/{navto_excludeExternal2.ts => navto_excludeLib2.ts} (89%) rename tests/cases/fourslash/{navto_excludeExternal3.ts => navto_excludeLib3.ts} (87%) rename tests/cases/fourslash/server/{navto_serverExcludeExternal.ts => navto_serverExcludeLib.ts} (92%) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1b07d9803d62b..fd6d12edcdbc0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -9936,7 +9936,7 @@ export interface UserPreferences { readonly organizeImportsNumericCollation?: boolean; readonly organizeImportsAccentCollation?: boolean; readonly organizeImportsCaseFirst?: "upper" | "lower" | false; - readonly excludeExternalFileSymbols?: boolean; + readonly excludeLibrarySymbols?: boolean; } /** Represents a bigint literal value without requiring bigint support */ diff --git a/src/harness/client.ts b/src/harness/client.ts index 8bfb2eca7fec0..c6f943e2f438c 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -314,7 +314,7 @@ export class SessionClient implements LanguageService { return notImplemented(); } - getNavigateToItems(searchValue: string, maxResultCount: number, file: string | undefined, _excludeDtsFiles: boolean | undefined, excludeExternalFiles: boolean | undefined): NavigateToItem[] { + getNavigateToItems(searchValue: string, maxResultCount: number, file: string | undefined, _excludeDtsFiles: boolean | undefined, excludeLibFiles: boolean | undefined): NavigateToItem[] { const args: protocol.NavtoRequestArgs = { searchValue, file, @@ -322,14 +322,14 @@ export class SessionClient implements LanguageService { maxResultCount, }; const oldPreferences = this.preferences; - if (excludeExternalFiles) { - this.configure({ excludeExternalFileSymbols: true }); + if (excludeLibFiles) { + this.configure({ excludeLibrarySymbols: true }); } const request = this.processRequest(protocol.CommandTypes.Navto, args); const response = this.processResponse(request); - if (excludeExternalFiles) { + if (excludeLibFiles) { this.configure(oldPreferences || {}); } diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts index 080a82295dd2e..68b097d185cb5 100644 --- a/src/harness/fourslashImpl.ts +++ b/src/harness/fourslashImpl.ts @@ -3765,9 +3765,9 @@ export class TestState { } public verifyNavigateTo(options: readonly FourSlashInterface.VerifyNavigateToOptions[]): void { - for (const { pattern, expected, fileName, excludeExternalFiles } of options) { + for (const { pattern, expected, fileName, excludeLibFiles } of options) { const file = fileName && this.findFile(fileName).fileName; - const items = this.languageService.getNavigateToItems(pattern, /*maxResultCount*/ undefined, file, /*excludeDtsFiles*/ undefined, excludeExternalFiles); + const items = this.languageService.getNavigateToItems(pattern, /*maxResultCount*/ undefined, file, /*excludeDtsFiles*/ undefined, excludeLibFiles); this.assertObjectsEqual( items, expected.map((e): ts.NavigateToItem => ({ diff --git a/src/harness/fourslashInterfaceImpl.ts b/src/harness/fourslashInterfaceImpl.ts index 262bf0ee04da5..d115c7b42dc90 100644 --- a/src/harness/fourslashInterfaceImpl.ts +++ b/src/harness/fourslashInterfaceImpl.ts @@ -1809,7 +1809,7 @@ export interface VerifyNavigateToOptions { readonly pattern: string; readonly fileName?: string; readonly expected: readonly ExpectedNavigateToItem[]; - readonly excludeExternalFiles?: boolean; + readonly excludeLibFiles?: boolean; } export interface ExpectedNavigateToItem { diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 46bcfcdd417f0..33dac5ac5269c 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -3603,7 +3603,7 @@ export interface UserPreferences { /** * Indicates whether to exclude standard library and node_modules files from navTo results. */ - readonly excludeExternalFileSymbols?: boolean; + readonly excludeLibrarySymbols?: boolean; } export interface CompilerOptions { diff --git a/src/server/session.ts b/src/server/session.ts index 6eee665bcc15f..d34b06e56be7f 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -2652,7 +2652,7 @@ export class Session implements EventSender { maxResultCount, /*fileName*/ undefined, /*excludeDts*/ project.isNonTsProject(), - /*excludeExternalFiles*/ preferences.excludeExternalFileSymbols, + /*excludeLibFiles*/ preferences.excludeLibrarySymbols, ); const unseenItems = filter(projectItems, item => tryAddSeenItem(item) && !getMappedLocationForProject(documentSpanLocation(item), project)); if (unseenItems.length) { diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 7b549616af1b7..8149e27dd5cca 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -38,7 +38,7 @@ interface RawNavigateToItem { } /** @internal */ -export function getNavigateToItems(sourceFiles: readonly SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number | undefined, excludeDtsFiles: boolean, excludeExternalFiles?: boolean): NavigateToItem[] { +export function getNavigateToItems(sourceFiles: readonly SourceFile[], checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number | undefined, excludeDtsFiles: boolean, excludeLibFiles?: boolean): NavigateToItem[] { const patternMatcher = createPatternMatcher(searchValue); if (!patternMatcher) return emptyArray; const rawItems: RawNavigateToItem[] = []; @@ -51,12 +51,12 @@ export function getNavigateToItems(sourceFiles: readonly SourceFile[], checker: continue; } - if (shouldExcludeFile(sourceFile, !!excludeExternalFiles)) { + if (shouldExcludeFile(sourceFile, !!excludeLibFiles)) { continue; } sourceFile.getNamedDeclarations().forEach((declarations, name) => { - getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, sourceFile.fileName, !!excludeExternalFiles, rawItems); + getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, sourceFile.fileName, !!excludeLibFiles, rawItems); }); } @@ -65,13 +65,13 @@ export function getNavigateToItems(sourceFiles: readonly SourceFile[], checker: } /** - * Exclude 'node_modules/' files and standard library files if 'excludeExternalFiles' is true. + * Exclude 'node_modules/' files and standard library files if 'excludeLibFiles' is true. */ -function shouldExcludeFile(file: SourceFile, excludeExternalFiles: boolean): boolean { - return excludeExternalFiles && (isInsideNodeModules(file.path) || file.hasNoDefaultLib); +function shouldExcludeFile(file: SourceFile, excludeLibFiles: boolean): boolean { + return excludeLibFiles && (isInsideNodeModules(file.path) || file.hasNoDefaultLib); } -function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: string, declarations: readonly Declaration[], checker: TypeChecker, fileName: string, excludeExternalFiles: boolean, rawItems: RawNavigateToItem[]): void { +function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: string, declarations: readonly Declaration[], checker: TypeChecker, fileName: string, excludeLibFiles: boolean, rawItems: RawNavigateToItem[]): void { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. const match = patternMatcher.getMatchForLastSegmentOfPattern(name); @@ -80,7 +80,7 @@ function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: stri } for (const declaration of declarations) { - if (!shouldKeepItem(declaration, checker, excludeExternalFiles)) continue; + if (!shouldKeepItem(declaration, checker, excludeLibFiles)) continue; if (patternMatcher.patternContainsDots) { // If the pattern has dots in it, then also see if the declaration container matches as well. @@ -95,7 +95,7 @@ function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: stri } } -function shouldKeepItem(declaration: Declaration, checker: TypeChecker, excludeExternalFiles: boolean): boolean { +function shouldKeepItem(declaration: Declaration, checker: TypeChecker, excludeLibFiles: boolean): boolean { switch (declaration.kind) { case SyntaxKind.ImportClause: case SyntaxKind.ImportSpecifier: @@ -103,7 +103,7 @@ function shouldKeepItem(declaration: Declaration, checker: TypeChecker, excludeE const importer = checker.getSymbolAtLocation((declaration as ImportClause | ImportSpecifier | ImportEqualsDeclaration).name!)!; // TODO: GH#18217 const imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName - && !imported.declarations?.some(d => shouldExcludeFile(d.getSourceFile(), excludeExternalFiles)); + && !imported.declarations?.some(d => shouldExcludeFile(d.getSourceFile(), excludeLibFiles)); default: return true; } diff --git a/src/services/services.ts b/src/services/services.ts index 7cd249b419128..7da1e0bff9143 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2192,10 +2192,10 @@ export function createLanguageService( return FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(FindAllReferences.toReferenceEntry); } - function getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles = false, excludeExternalFiles = false): NavigateToItem[] { + function getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles = false, excludeLibFiles = false): NavigateToItem[] { synchronizeHostData(); const sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); - return NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles, excludeExternalFiles); + return NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles, excludeLibFiles); } function getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean, forceDtsEmit?: boolean) { diff --git a/src/services/types.ts b/src/services/types.ts index edef20cb8c7c8..e18b15264b54b 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -594,7 +594,7 @@ export interface LanguageService { getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined; getFileReferences(fileName: string): ReferenceEntry[]; - getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean, excludeExternalFiles?: boolean): NavigateToItem[]; + getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean, excludeLibFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index eeb09b48f82c8..858f545e416a0 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -811,7 +811,7 @@ declare namespace FourSlashInterface { readonly pattern: string; readonly fileName?: string; readonly expected: ReadonlyArray; - readonly excludeExternalFiles?: boolean; + readonly excludeLibFiles?: boolean; } interface ExpectedNavigateToItem { readonly name: string; diff --git a/tests/cases/fourslash/navto_excludeExternal1.ts b/tests/cases/fourslash/navto_excludeLib1.ts similarity index 92% rename from tests/cases/fourslash/navto_excludeExternal1.ts rename to tests/cases/fourslash/navto_excludeLib1.ts index 6c52710c83f84..aafd416100954 100644 --- a/tests/cases/fourslash/navto_excludeExternal1.ts +++ b/tests/cases/fourslash/navto_excludeLib1.ts @@ -35,7 +35,7 @@ verify.navigateTo({ verify.navigateTo({ pattern: "weirdName", - excludeExternalFiles: true, + excludeLibFiles: true, expected: [{ name: "weirdName", kind: "const", diff --git a/tests/cases/fourslash/navto_excludeExternal2.ts b/tests/cases/fourslash/navto_excludeLib2.ts similarity index 89% rename from tests/cases/fourslash/navto_excludeExternal2.ts rename to tests/cases/fourslash/navto_excludeLib2.ts index fa7d6628770d2..918a5f3398244 100644 --- a/tests/cases/fourslash/navto_excludeExternal2.ts +++ b/tests/cases/fourslash/navto_excludeLib2.ts @@ -27,6 +27,6 @@ verify.navigateTo({ verify.navigateTo({ pattern: "weirdName", - excludeExternalFiles: true, + excludeLibFiles: true, expected: [], }); \ No newline at end of file diff --git a/tests/cases/fourslash/navto_excludeExternal3.ts b/tests/cases/fourslash/navto_excludeLib3.ts similarity index 87% rename from tests/cases/fourslash/navto_excludeExternal3.ts rename to tests/cases/fourslash/navto_excludeLib3.ts index dfd3c5409c4e0..4cd2d7b99b736 100644 --- a/tests/cases/fourslash/navto_excludeExternal3.ts +++ b/tests/cases/fourslash/navto_excludeLib3.ts @@ -7,7 +7,7 @@ const [local] = test.ranges(); verify.navigateTo({ pattern: "parseInt", - excludeExternalFiles: true, + excludeLibFiles: true, expected: [ { name: "parseInt", diff --git a/tests/cases/fourslash/server/navto_serverExcludeExternal.ts b/tests/cases/fourslash/server/navto_serverExcludeLib.ts similarity index 92% rename from tests/cases/fourslash/server/navto_serverExcludeExternal.ts rename to tests/cases/fourslash/server/navto_serverExcludeLib.ts index a4cf43592e212..cbe0d5fc7e2a9 100644 --- a/tests/cases/fourslash/server/navto_serverExcludeExternal.ts +++ b/tests/cases/fourslash/server/navto_serverExcludeLib.ts @@ -35,7 +35,7 @@ verify.navigateTo({ verify.navigateTo({ pattern: "weirdName", - excludeExternalFiles: true, + excludeLibFiles: true, expected: [{ name: "weirdName", kind: "const", From c44ff2bdfdcf4cfe0f961d98deacaa4ffc09d35f Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 1 Sep 2023 14:48:03 -0700 Subject: [PATCH 07/11] update baselines --- tests/baselines/reference/api/typescript.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index dcea4be64289a..4ef22404bb652 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2897,6 +2897,10 @@ declare namespace ts { * Indicates whether {@link ReferencesResponseItem.lineText} is supported. */ readonly disableLineTextInReferences?: boolean; + /** + * Indicates whether to exclude standard library and node_modules files from navTo results. + */ + readonly excludeLibrarySymbols?: boolean; } interface CompilerOptions { allowJs?: boolean; @@ -8640,6 +8644,7 @@ declare namespace ts { readonly organizeImportsNumericCollation?: boolean; readonly organizeImportsAccentCollation?: boolean; readonly organizeImportsCaseFirst?: "upper" | "lower" | false; + readonly excludeLibrarySymbols?: boolean; } /** Represents a bigint literal value without requiring bigint support */ interface PseudoBigInt { @@ -10396,7 +10401,7 @@ declare namespace ts { findReferences(fileName: string, position: number): ReferencedSymbol[] | undefined; getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined; getFileReferences(fileName: string): ReferenceEntry[]; - getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; + getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean, excludeLibFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; prepareCallHierarchy(fileName: string, position: number): CallHierarchyItem | CallHierarchyItem[] | undefined; From d799de8f3f15587fa2a17754e0cc192ac26708ba Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 1 Sep 2023 15:01:58 -0700 Subject: [PATCH 08/11] improve description of new option --- src/server/protocol.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 33dac5ac5269c..bcb45ae6eaab8 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -3601,7 +3601,7 @@ export interface UserPreferences { readonly disableLineTextInReferences?: boolean; /** - * Indicates whether to exclude standard library and node_modules files from navTo results. + * Indicates whether to exclude standard library and node_modules file symbols from navTo results. */ readonly excludeLibrarySymbols?: boolean; } From 9d585d447d1b26fc831e3d1ce929bb14aadbe9db Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Fri, 1 Sep 2023 15:18:15 -0700 Subject: [PATCH 09/11] update api baselines --- tests/baselines/reference/api/typescript.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 4ef22404bb652..e7c27bba27001 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2898,7 +2898,7 @@ declare namespace ts { */ readonly disableLineTextInReferences?: boolean; /** - * Indicates whether to exclude standard library and node_modules files from navTo results. + * Indicates whether to exclude standard library and node_modules file symbols from navTo results. */ readonly excludeLibrarySymbols?: boolean; } From deddc30dd783452042578bd1db8d4e0d8253b422 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Wed, 6 Sep 2023 15:31:12 -0700 Subject: [PATCH 10/11] fix case of single file mode in lib files --- src/services/navigateTo.ts | 33 ++++++++++++++++------ tests/cases/fourslash/navto_excludeLib4.ts | 24 ++++++++++++++++ 2 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 tests/cases/fourslash/navto_excludeLib4.ts diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 8149e27dd5cca..5beb279698d2e 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -42,7 +42,7 @@ export function getNavigateToItems(sourceFiles: readonly SourceFile[], checker: const patternMatcher = createPatternMatcher(searchValue); if (!patternMatcher) return emptyArray; const rawItems: RawNavigateToItem[] = []; - + const singleCurrentFile = sourceFiles.length === 1 ? sourceFiles[0] : undefined; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); @@ -51,12 +51,12 @@ export function getNavigateToItems(sourceFiles: readonly SourceFile[], checker: continue; } - if (shouldExcludeFile(sourceFile, !!excludeLibFiles)) { + if (shouldExcludeFile(sourceFile, !!excludeLibFiles, singleCurrentFile)) { continue; } sourceFile.getNamedDeclarations().forEach((declarations, name) => { - getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, sourceFile.fileName, !!excludeLibFiles, rawItems); + getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, sourceFile.fileName, !!excludeLibFiles, singleCurrentFile, rawItems); }); } @@ -66,12 +66,22 @@ export function getNavigateToItems(sourceFiles: readonly SourceFile[], checker: /** * Exclude 'node_modules/' files and standard library files if 'excludeLibFiles' is true. + * If we're in current file only mode, we don't exclude the current file, even if it is a library file. */ -function shouldExcludeFile(file: SourceFile, excludeLibFiles: boolean): boolean { - return excludeLibFiles && (isInsideNodeModules(file.path) || file.hasNoDefaultLib); +function shouldExcludeFile(file: SourceFile, excludeLibFiles: boolean, singleCurrentFile: SourceFile | undefined): boolean { + return file !== singleCurrentFile && excludeLibFiles && (isInsideNodeModules(file.path) || file.hasNoDefaultLib); } -function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: string, declarations: readonly Declaration[], checker: TypeChecker, fileName: string, excludeLibFiles: boolean, rawItems: RawNavigateToItem[]): void { +function getItemsFromNamedDeclaration( + patternMatcher: PatternMatcher, + name: string, + declarations: readonly Declaration[], + checker: TypeChecker, + fileName: string, + excludeLibFiles: boolean, + singleCurrentFile: SourceFile | undefined, + rawItems: RawNavigateToItem[], +): void { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. const match = patternMatcher.getMatchForLastSegmentOfPattern(name); @@ -80,7 +90,7 @@ function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: stri } for (const declaration of declarations) { - if (!shouldKeepItem(declaration, checker, excludeLibFiles)) continue; + if (!shouldKeepItem(declaration, checker, excludeLibFiles, singleCurrentFile)) continue; if (patternMatcher.patternContainsDots) { // If the pattern has dots in it, then also see if the declaration container matches as well. @@ -95,7 +105,12 @@ function getItemsFromNamedDeclaration(patternMatcher: PatternMatcher, name: stri } } -function shouldKeepItem(declaration: Declaration, checker: TypeChecker, excludeLibFiles: boolean): boolean { +function shouldKeepItem( + declaration: Declaration, + checker: TypeChecker, + excludeLibFiles: boolean, + singleCurrentFile: SourceFile | undefined, +): boolean { switch (declaration.kind) { case SyntaxKind.ImportClause: case SyntaxKind.ImportSpecifier: @@ -103,7 +118,7 @@ function shouldKeepItem(declaration: Declaration, checker: TypeChecker, excludeL const importer = checker.getSymbolAtLocation((declaration as ImportClause | ImportSpecifier | ImportEqualsDeclaration).name!)!; // TODO: GH#18217 const imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName - && !imported.declarations?.some(d => shouldExcludeFile(d.getSourceFile(), excludeLibFiles)); + && !imported.declarations?.every(d => shouldExcludeFile(d.getSourceFile(), excludeLibFiles, singleCurrentFile)); default: return true; } diff --git a/tests/cases/fourslash/navto_excludeLib4.ts b/tests/cases/fourslash/navto_excludeLib4.ts new file mode 100644 index 0000000000000..3bf90de0b1bf2 --- /dev/null +++ b/tests/cases/fourslash/navto_excludeLib4.ts @@ -0,0 +1,24 @@ +/// + +// @filename: /node_modules/bar/index.d.ts +//// import { someOtherName } from "./baz"; +//// export const [|someName: number|]; +// @filename: /node_modules/bar/baz.d.ts +//// export const someOtherName: string; + +const [some] = test.ranges(); + +verify.navigateTo({ + pattern: "some", + excludeLibFiles: true, + fileName: "/node_modules/bar/index.d.ts", + expected: [ + { + name: "someName", + kind: "const", + kindModifiers: "export,declare", + range: some, + matchKind: "prefix", + }, + ], +}); \ No newline at end of file From 41e3ae58ca28376023d66d75a9c0a2d72c4d9ca4 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Wed, 6 Sep 2023 17:01:32 -0700 Subject: [PATCH 11/11] rename option --- src/compiler/types.ts | 2 +- src/harness/client.ts | 2 +- src/server/protocol.ts | 2 +- src/server/session.ts | 2 +- tests/baselines/reference/api/typescript.d.ts | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index fd6d12edcdbc0..342cfc59be965 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -9936,7 +9936,7 @@ export interface UserPreferences { readonly organizeImportsNumericCollation?: boolean; readonly organizeImportsAccentCollation?: boolean; readonly organizeImportsCaseFirst?: "upper" | "lower" | false; - readonly excludeLibrarySymbols?: boolean; + readonly excludeLibrarySymbolsInNavTo?: boolean; } /** Represents a bigint literal value without requiring bigint support */ diff --git a/src/harness/client.ts b/src/harness/client.ts index c6f943e2f438c..619fece8cae62 100644 --- a/src/harness/client.ts +++ b/src/harness/client.ts @@ -323,7 +323,7 @@ export class SessionClient implements LanguageService { }; const oldPreferences = this.preferences; if (excludeLibFiles) { - this.configure({ excludeLibrarySymbols: true }); + this.configure({ excludeLibrarySymbolsInNavTo: true }); } const request = this.processRequest(protocol.CommandTypes.Navto, args); diff --git a/src/server/protocol.ts b/src/server/protocol.ts index bcb45ae6eaab8..6d06376d196eb 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -3603,7 +3603,7 @@ export interface UserPreferences { /** * Indicates whether to exclude standard library and node_modules file symbols from navTo results. */ - readonly excludeLibrarySymbols?: boolean; + readonly excludeLibrarySymbolsInNavTo?: boolean; } export interface CompilerOptions { diff --git a/src/server/session.ts b/src/server/session.ts index d34b06e56be7f..1da59c00e763a 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -2652,7 +2652,7 @@ export class Session implements EventSender { maxResultCount, /*fileName*/ undefined, /*excludeDts*/ project.isNonTsProject(), - /*excludeLibFiles*/ preferences.excludeLibrarySymbols, + /*excludeLibFiles*/ preferences.excludeLibrarySymbolsInNavTo, ); const unseenItems = filter(projectItems, item => tryAddSeenItem(item) && !getMappedLocationForProject(documentSpanLocation(item), project)); if (unseenItems.length) { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index e7c27bba27001..fd798b0487be1 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2900,7 +2900,7 @@ declare namespace ts { /** * Indicates whether to exclude standard library and node_modules file symbols from navTo results. */ - readonly excludeLibrarySymbols?: boolean; + readonly excludeLibrarySymbolsInNavTo?: boolean; } interface CompilerOptions { allowJs?: boolean; @@ -8644,7 +8644,7 @@ declare namespace ts { readonly organizeImportsNumericCollation?: boolean; readonly organizeImportsAccentCollation?: boolean; readonly organizeImportsCaseFirst?: "upper" | "lower" | false; - readonly excludeLibrarySymbols?: boolean; + readonly excludeLibrarySymbolsInNavTo?: boolean; } /** Represents a bigint literal value without requiring bigint support */ interface PseudoBigInt {