[java jigsaw inspection] update the empty module-info file check to skip the current module and java.base IDEA-379419

GitOrigin-RevId: 31effa497149f7b5ac3712de01c653166fcbd814
This commit is contained in:
Aleksey Dobrynin
2025-10-07 15:01:16 +02:00
committed by intellij-monorepo-bot
parent 97bc33a07f
commit 82e7c16852
3 changed files with 15 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.codeInspection.java19api;
import com.intellij.codeInsight.daemon.impl.analysis.JavaModuleGraphUtil;
@@ -98,7 +98,9 @@ public class JavaEmptyModuleInfoFileInspection extends AbstractBaseJavaLocalInsp
}
private static boolean needRequires(@NotNull PsiJavaModule descriptor) {
Set<PsiJavaModule> modules = walk(descriptor, psiJavaModule -> psiJavaModule.getName().equals(descriptor.getName()));
Set<PsiJavaModule> modules = walk(descriptor, psiJavaModule ->
psiJavaModule.getName().equals(descriptor.getName()) ||
psiJavaModule.getName().equals(PsiJavaModule.JAVA_BASE));
return !modules.isEmpty();
}
@@ -140,6 +142,7 @@ public class JavaEmptyModuleInfoFileInspection extends AbstractBaseJavaLocalInsp
return imports.values().stream()
.filter(Objects::nonNull)
.filter(m -> !m.getName().equals(descriptor.getName()))
.filter(m -> !m.getName().equals(PsiJavaModule.JAVA_BASE))
.collect(Collectors.toCollection(() -> new TreeSet<>((o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()))));
}

View File

@@ -1,5 +1,9 @@
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
System.out.println("test");
List<String> list = new ArrayList<>();
System.out.println(list.size());
}
}

View File

@@ -1,5 +1,9 @@
import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main(String[] args) {
System.out.println("test");
List<String> list = new ArrayList<>();
System.out.println(list.size());
}
}