feat(usages): search Java usages in Project Files first, Project and Libraries on demand (#1837)

Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-06 21:46:29 +08:00
1 джерело ef95cd1716
коміт a6d17543fd
26 files changed
+963 -96

No files matched your search

+6
Переглянути файл
@@ -65,6 +65,12 @@ const showHint = vi.fn();
vi.mock("@/editor/lsp/hint", () => ({ showHint }));
const executeAction = vi.fn();
vi.mock("@/platform/actions", () => ({ executeAction }));
vi.mock("@tauri-apps/api/core", async (orig) => ({
...(await orig<object>()),
Channel: class {
onmessage = () => {};
},
}));
let answer = "cancel";
const ask = vi.fn(async (_request: MessageRequest) => ({ button: answer, checked: false }));
let confirmAnswer: { checked: boolean } | null = { checked: false };
+11 -2
Переглянути файл
@@ -10,6 +10,7 @@
* Files (project view): references to the file's top-level symbols from other
* files, when the language server can answer (`fileUsages`).
*/
import { Channel } from "@tauri-apps/api/core";
import type { EditorView } from "@codemirror/view";
import type { Text } from "@codemirror/state";
import type { LocalSymbol, Location, OutlineItem, Pos, Range, SyntaxNode } from "@/bindings";
@@ -254,7 +255,7 @@ async function findUsages(ctx: EditorDocContext, target: SafeDeleteTarget): Prom
if (target.local)
return target.local.references.filter((r) => outside(ctx.path, r)).map((range) => ({ path: ctx.path, range }));
const { locations: refs } = await lspRequest(() =>
commands.lspReferences(nextRequestId(), ctx.doc, target.at, false, true),
commands.lspReferences(nextRequestId(), ctx.doc, target.at, false, true, false, new Channel()),
);
return refs.filter((l) => outside(l.path, l.range));
}
@@ -554,7 +555,15 @@ export async function fileUsages(paths: readonly string[], signal?: AbortSignal)
// Every symbol of every file: the server's own scope (a project search each would be too slow).
refs = (
await lspRequest(() =>
commands.lspReferences(nextRequestId(), doc, item.selection_range.start, false, false),
commands.lspReferences(
nextRequestId(),
doc,
item.selection_range.start,
false,
false,
false,
new Channel(),
),
)
).locations;
} catch (e) {