mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 23:31:05 +07:00
[java-import] IJ-CR-163032 IDEA-369199 Preserve module imports even if they are not used
- always highlight unused imports in the hierarchy GitOrigin-RevId: 26b7fb22931e4b37e45f7c5ee5940d1cfed2a03d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
dea7732836
commit
f79bb18278
@@ -176,6 +176,12 @@ class UnusedImportsVisitor extends JavaElementVisitor {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (importStatement instanceof PsiImportModuleStatement moduleStatement) {
|
||||
List<PsiImportModuleStatement> moduleStatements = ImportUtils.optimizeModuleImports(javaFile);
|
||||
if (!moduleStatements.contains(moduleStatement)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return isRedundant;
|
||||
}
|
||||
|
||||
|
||||
@@ -880,10 +880,11 @@ public final class ImportUtils {
|
||||
Map<PsiImportModuleStatement, PsiJavaModule> modules = new HashMap<>();
|
||||
Map<PsiJavaModule, Set<PsiJavaModule>> dependencies = new HashMap<>();
|
||||
Set<PsiImportModuleStatement> toDelete = new HashSet<>();
|
||||
List<PsiImportModuleStatement> allImports = ContainerUtil.concat(implicit, statements);
|
||||
for (PsiImportModuleStatement current : statements) {
|
||||
PsiJavaModule currentModule = modules.computeIfAbsent(current, m -> m.resolveTargetModule());
|
||||
if (currentModule == null) continue;
|
||||
for (PsiImportModuleStatement higher : ContainerUtil.concat(implicit, statements)) {
|
||||
for (PsiImportModuleStatement higher : allImports) {
|
||||
if(toDelete.contains(higher)) continue;
|
||||
if (higher == current) continue;
|
||||
PsiJavaModule higherModule = modules.computeIfAbsent(higher, m -> m.resolveTargetModule());
|
||||
|
||||
Reference in New Issue
Block a user