дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +02:00
fix(run): gutter run for Java 25 compact source files (#7814)
A Java 25 compact source file (JEP 512: a top-level void main, no class) showed no gutter Run icon, because the run-target scanner only accepted main inside a class. A top-level main is now the main of the file's implicit class, named after the file, and the Java single-file producer launches such files with the source launcher (java File.java) instead of taking the first declared type as the main class. Co-authored-by: kjeldahl <[email protected]>
Цей коміт міститься в:
1 джерело
22db3ab9c3
коміт
45dd96cdeb
4 files changed
+30
-4
No files matched your search
@@ -69,6 +69,16 @@ describe("scanJvmTargets (Java)", () => {
|
||||
expect(pick("class B {\n void main() {}\n}", "B.java")).toEqual([[1, "main", "B", null, false]]);
|
||||
});
|
||||
|
||||
it("a Java 25 compact source file's top-level main runs the file's implicit class", () => {
|
||||
const src = "// Run: java Hi.java\nenum Day { MONDAY }\n\nvoid main() {\n IO.println(Day.MONDAY);\n}\n";
|
||||
expect(pick(src, "examples/Hi.java")).toEqual([[3, "main", "Hi", null, false]]);
|
||||
expect(scanJvmTargets(src, "examples/Hi.java", false)[0]).toMatchObject({ instance: true, compact: true });
|
||||
expect(pick("static void main(String[] args) {}\nvoid helper() {}", "Tool.java")).toEqual([
|
||||
[0, "main", "Tool", null, false],
|
||||
]);
|
||||
expect(pick("void helper() {}\nint main(String[] a) { return 0; }", "Tool.java")).toEqual([]);
|
||||
});
|
||||
|
||||
it("finds JUnit tests, nested @Nested classes and multi-line annotations", () => {
|
||||
const src = [
|
||||
"package a.b;", // 0
|
||||
|
||||
Reference in new issue
Заблокувати користувача