Файли
openidea/src/editor/refactor/javaMove.test.ts
T
l0ng-ai 34c81a61e4 feat(refactor): Java Move for classes, static members, nested types and instance methods (#3704)
Move… (F6, Refactor This) in Java now asks for the destination and moves:
a top-level class to another package (package declaration, imports and
references follow), a static member or nested type to another class (or a
nested type to a new file), an instance method to the class of one of its
fields or parameters. jdtls offers these only as client-side commands
(java.action.applyRefactoringCommand), now enabled with
moveRefactoringSupport; the IDE picks the destination from
java/getMoveDestinations or java/searchSymbols, then java/move checks the move
and computes the edit, confirmed in Problems Detected when it warns.

Code actions can register client-side command handlers
(registerClientCommand); jdtls' changeSignature command opens the Change
Signature dialog. New IPC: lsp_java_move_destinations, lsp_java_source_types,
lsp_java_move. SignatureChanged is now ServerRefactored.
2026-11-16 15:36:01 +08:00

29 рядки
1.2 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { packageRow, runJavaRefactoringCommand, targetTypes } from "./javaMove";
describe("java move", () => {
it("shows packages by name and marks the current one", () => {
expect(packageRow({ displayName: "com.example", path: "/app/src/main/java/com/example" })).toEqual({
label: "com.example",
detail: "/app/src/main/java/com/example",
current: false,
});
expect(packageRow({ displayName: "", isParentOfSelectedFile: true }).label).toBe("(default package)");
expect(packageRow({ isParentOfSelectedFile: true }).current).toBe(true);
});
it("offers every source type but the member's own, sorted by name", () => {
const types = [
{ name: "Order", containerName: "com.example.orders" },
{ name: "App", containerName: "com.example.orders" },
{ name: "Strings", containerName: "com.example.util" },
{ name: "" },
];
expect(targetTypes(types, new Set(["com.example.orders.App"])).map((t) => t.name)).toEqual(["Order", "Strings"]);
});
it("leaves commands it doesn't know to the server", async () => {
expect(await runJavaRefactoringCommand({} as never, ["extractInterface"])).toBe(false);
});
});