дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 03:05:40 +02:00
feat(usages): search Java usages in Project Files first, Project and Libraries on demand (#1837)
Цей коміт міститься в:
1 джерело
ef95cd1716
коміт
a6d17543fd
26 files changed
+963
-96
No files matched your search
@@ -15,6 +15,12 @@ vi.mock("@/platform/ipc", async (orig) => {
|
||||
});
|
||||
const executeAction = vi.hoisted(() => vi.fn(async () => true));
|
||||
vi.mock("@/platform/actions", () => ({ executeAction }));
|
||||
vi.mock("@tauri-apps/api/core", async (orig) => ({
|
||||
...(await orig<object>()),
|
||||
Channel: class {
|
||||
onmessage = () => {};
|
||||
},
|
||||
}));
|
||||
|
||||
const { lensTargets, usagesLensExtension } = await import("./codeLens");
|
||||
const { lspDoc } = await import("./lsp");
|
||||
@@ -89,7 +95,15 @@ describe("background usage counts", () => {
|
||||
it("uses the server's existing scope and leaves full searches to the explicit action", async () => {
|
||||
const view = editor();
|
||||
await settle();
|
||||
expect(ipc.lspReferences).toHaveBeenCalledWith(expect.any(Number), 7, { line: 0, col: 0 }, false, false);
|
||||
expect(ipc.lspReferences).toHaveBeenCalledWith(
|
||||
expect.any(Number),
|
||||
7,
|
||||
{ line: 0, col: 0 },
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
expect.anything(),
|
||||
);
|
||||
expect(titles(view)).toEqual(["2 usages"]);
|
||||
view.state.facet(codeLenses)[0]!.run!(view, new MouseEvent("click"));
|
||||
expect(executeAction).toHaveBeenCalledWith("find.showUsages");
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* and symbol, and at most a few reference requests in flight. Beside each
|
||||
* count, the declaration's last author from VCS blame (`authorLens`).
|
||||
*/
|
||||
import { Channel } from "@tauri-apps/api/core";
|
||||
import { EditorSelection, MapMode, StateEffect, StateField, type Extension, type Text } from "@codemirror/state";
|
||||
import { EditorView, ViewPlugin, type ViewUpdate } from "@codemirror/view";
|
||||
import { codeLenses, type CodeLens } from "@/editor/api";
|
||||
@@ -195,7 +196,15 @@ class UsagesLensPlugin {
|
||||
this.pending.add(request);
|
||||
// Opening candidate files for each count triggers expensive server analysis.
|
||||
// Only an explicit Find Usages should widen the server's scope.
|
||||
return commands.lspReferences(request, doc.doc, { line: t.line, col: t.col }, false, false);
|
||||
return commands.lspReferences(
|
||||
request,
|
||||
doc.doc,
|
||||
{ line: t.line, col: t.col },
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
new Channel(),
|
||||
);
|
||||
}, wanted);
|
||||
if (wanted()) {
|
||||
if (incomplete) this.incomplete = true;
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Заблокувати користувача