mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java, import-module] fix: "Replace with single class imports" in module-info.java is removed instead of replaced (IDEA-367507)
GitOrigin-RevId: f4889b0d2bf8b21ef77243b06ad7dc606e2ae07a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
36b0f89fb0
commit
d208f217ca
@@ -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.siyeh.ipp.imports;
|
||||
|
||||
import com.intellij.codeInspection.util.IntentionName;
|
||||
@@ -49,10 +49,14 @@ public final class ReplaceOnDemandImportIntention extends MCIntention {
|
||||
if (importStatementBase instanceof PsiImportModuleStatement || importStatementBase instanceof PsiImportStatement) {
|
||||
final PsiClass[] classes = javaFile.getClasses();
|
||||
final ClassCollector visitor = ClassCollector.create(importStatementBase);
|
||||
if(visitor==null) return;
|
||||
if (visitor == null) return;
|
||||
for (PsiClass aClass : classes) {
|
||||
aClass.accept(visitor);
|
||||
}
|
||||
PsiJavaModule psiJavaModule = javaFile.getModuleDeclaration();
|
||||
if (psiJavaModule != null) {
|
||||
psiJavaModule.accept(visitor);
|
||||
}
|
||||
ImportUtils.ImplicitImportChecker checker = ImportUtils.createImplicitImportChecker(javaFile);
|
||||
final PsiClass[] importedClasses = Arrays.stream(visitor.getImportedClasses())
|
||||
.filter(
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import module java<caret>.base;
|
||||
|
||||
module my.module {
|
||||
requires java.base;
|
||||
|
||||
provides Random with A;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import java.util.Random;
|
||||
|
||||
module my.module {
|
||||
requires java.base;
|
||||
|
||||
provides Random with A;
|
||||
}
|
||||
+2
-1
@@ -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.siyeh.ipp.imports;
|
||||
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
@@ -16,6 +16,7 @@ public class ReplaceOnDemandImportIntentionTest extends IPPTestCase {
|
||||
public void testStaticImport() { doTest(); }
|
||||
public void testModuleImport() { doTest(); }
|
||||
public void testModuleImportImplicitImport() { doTest(); }
|
||||
public void testModuleImportModuleInfo() { doTest(); }
|
||||
|
||||
@Override
|
||||
protected String getIntentionName() {
|
||||
|
||||
Reference in New Issue
Block a user