fix(search): show a library class's archive instead of its document URI (#7938)

Search Everywhere listed classes from dependency jars and the JDK with the language server's raw jdt:// URI as their location. Library rows now show the archive or JDK module, and the status line the archive and package.

Refs #7919
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-12-04 12:37:54 +08:00
1 джерело 16e160f5b9
коміт 8b1ca86526
3 files changed
+22 -1

No files matched your search

+12
Переглянути файл
@@ -105,6 +105,18 @@ describe("mergeSymbols", () => {
expect(mergeSymbols([], lsp, "ord", { ...opts, includeNonProject: true }).items[0]!.rel).toBe("/usr/lib/x.kt");
});
it("locates library classes by their archive, not the server's document URI", () => {
const jdt =
"jdt://contents/opentest4j-1.3.0.jar/org.opentest4j/AssertionFailedError.class?=demo/%5C/m2%5C/opentest4j-1.3.0.jar%3Corg.opentest4j%28AssertionFailedError.class";
const jdk = "jdt://contents/java.base/java.util/ArrayList.class?=demo/%5C/jdk%5C/lib%5C/jrt-fs.jar%60java.base";
const lsp = [ws("AssertionFailedError", "class", jdt, 20), ws("ArrayList", "class", jdk, 100)];
const all = { ...opts, includeNonProject: true };
expect(mergeSymbols([], lsp, "AssertionFailedError", all).items.map((i) => [i.path, i.rel])).toEqual([
[jdt, "opentest4j-1.3.0.jar"],
]);
expect(mergeSymbols([], lsp, "ArrayList", all).items[0]!.rel).toBe("java.base");
});
it("applies type filters and reports overflow", () => {
const index = [
sym("Order", "class", "/p/A.kt", 0),
+3
Переглянути файл
@@ -84,6 +84,7 @@ import {
import styles from "./SearchEverywhere.module.css";
import { isImeKey } from "@/platform/ime";
import { nativePath } from "@/platform/paths";
import { isVirtualUri, virtualContainer } from "@/platform/virtualDocs";
type SeScope = "allPlaces" | ProjectFileSet;
@@ -889,6 +890,8 @@ function describe(row: SeRow | undefined): string {
case "file":
return row.rel;
case "symbol":
// A library class: its archive and package, not the server's document URI.
return isVirtualUri(row.path) ? virtualContainer(row.path) : `${row.rel}:${row.line + 1}`;
case "text":
return `${row.rel}:${row.line + 1}`;
}
+7 -1
Переглянути файл
@@ -9,6 +9,7 @@ import { tx } from "@/platform/i18n";
import { basename, isTypeKind, relDir, symbolDisplayName } from "../common/open";
import { byScore, matchText } from "../common/rank";
import { wordMatch } from "@/ui";
import { isVirtualUri, virtualContainer } from "@/platform/virtualDocs";
export type SeTab = "all" | "classes" | "files" | "symbols" | "endpoints" | "actions" | "text" | SearchCategoryId;
export const isCustomTab = (tab: string): tab is SearchCategoryId => tab.startsWith("plugin:");
@@ -295,6 +296,11 @@ const dedupeKey = (path: string, line: number, name: string) => `${path}\u0000${
* index doesn't know are scored locally and appended (or interleaved when they
* clearly match better, e.g. an exact name hit).
*/
/** A library class (`jdt://`, `jar:`) by its archive or JDK module, e.g. `spring-boot-4.1.1.jar`. */
function libraryLocation(path: string): string {
return isVirtualUri(path) ? (virtualContainer(path).split(" › ")[0] ?? path) : path;
}
export function mergeSymbols(
index: readonly SymbolMatch[],
lsp: readonly WorkspaceSymbol[],
@@ -325,7 +331,7 @@ export function mergeSymbols(
if (!hit) continue;
if (qualified.container && !(s.container && matchText(containerTail(s.container), qualified.container))) continue;
seen.add(k);
const rel = opts.root && inProject ? path.slice(opts.root.length + 1) : path;
const rel = opts.root && inProject ? path.slice(opts.root.length + 1) : libraryLocation(path);
scored.push({
item: {
kind: "symbol",