mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
The JVM file presentation now reports whether a file's primary type is deprecated: annotated @Deprecated (Java and Kotlin), or a Java type whose Javadoc has a @deprecated tag. The Project view and editor tabs strike the name out, and an error marker on the same file still shows. Closes #4151
59 lines
2.5 KiB
TypeScript
59 lines
2.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { presentationIcon } from "./filePresentation";
|
|
import type { RootFolder } from "@/platform/languageSettings";
|
|
import type { JvmPresentation } from "@/platform/ipc";
|
|
|
|
const roots: RootFolder[] = [
|
|
{ path: "src/main/java", kind: "source", detectedFrom: "pom.xml" },
|
|
{ path: "src/test/java", kind: "test", detectedFrom: "pom.xml" },
|
|
{ path: "src/main/resources", kind: "resources", detectedFrom: "pom.xml" },
|
|
{ path: "src/test/resources", kind: "testResources", detectedFrom: "pom.xml" },
|
|
];
|
|
const type = (kind: JvmPresentation["kind"]): JvmPresentation => ({
|
|
kind,
|
|
springBoot: false,
|
|
runnable: false,
|
|
deprecated: false,
|
|
});
|
|
const icon = (path: string, info: JvmPresentation | null = null, spring = false) =>
|
|
presentationIcon(`/p/${path}`, info, roots, "/p", spring);
|
|
|
|
describe("JVM file presentation", () => {
|
|
it.each([
|
|
["class", "class"],
|
|
["abstractClass", "class-abstract"],
|
|
["interface", "interface"],
|
|
["enum", "enum"],
|
|
["record", "record"],
|
|
["annotation", "annotation"],
|
|
["exception", "exception"],
|
|
["object", "kotlin-object"],
|
|
] as const)("maps %s to %s", (kind, expected) => expect(icon("Foo.java", type(kind))).toBe(expected));
|
|
it.each(["LIMIT.java", "AUDIT.java", "Contest.java"])("keeps the type icon of %s", (path) =>
|
|
expect(icon(path, type("class"))).toBe("class"),
|
|
);
|
|
it.each(["FooTest.java", "FooTests.java", "FooIT.java", "FooTest.kt", "src/test/java/Anything.java"])(
|
|
"marks test classes: %s",
|
|
(path) => expect(icon(path, type("class"))).toBe("jvm-test"),
|
|
);
|
|
it("keeps files without declarations and binaries as file types", () => {
|
|
expect(icon("Foo.java", type(null))).toBe("file-java");
|
|
expect(icon("FooTest.java", type(null))).toBe("file-java");
|
|
expect(icon("Foo.kt")).toBe("file-kotlin");
|
|
expect(icon("Foo.class")).toBe("file-binary");
|
|
expect(icon("Contest.java", type("class"))).toBe("class");
|
|
});
|
|
it.each(["application.yml", "application-dev.yaml", "bootstrap.properties", "bootstrap-local.yml"])(
|
|
"requires Spring or a resource root: %s",
|
|
(name) => {
|
|
expect(icon(`src/main/resources/${name}`)).toBe("spring-config");
|
|
expect(icon(`src/test/resources/${name}`)).toBe("spring-config");
|
|
expect(icon(name, null, true)).toBe("spring-config");
|
|
expect(icon(name)).not.toBe("spring-config");
|
|
},
|
|
);
|
|
it("uses the entire Boot icon on application classes", () => {
|
|
expect(icon("App.java", { ...type("class"), springBoot: true, runnable: true })).toBe("spring-boot");
|
|
});
|
|
});
|