[Java. Intention Actions] Do not add implicitly declared class to import list

^IDEA-370603 fixed

GitOrigin-RevId: 0cfcef57e1b1dbccea05ab68a57c8906df0e753c
This commit is contained in:
Georgii Ustinov
2025-04-09 15:46:47 +00:00
committed by intellij-monorepo-bot
parent 741a56017c
commit 1192817c91
4 changed files with 19 additions and 0 deletions
@@ -1186,6 +1186,9 @@ public final class ImportHelper {
}
if (refElement instanceof PsiClass psiClass) {
// Implicitly declared classed are not accessible outside the file, so it is not possible to have import statement on them.
if (refElement.getParent() instanceof PsiImplicitClass) continue;
String qName = psiClass.getQualifiedName();
if (qName == null || hasPackage(qName, thisPackageName)) continue;
imports.add(new Import(qName, false));
@@ -0,0 +1,7 @@
package B;
public class A extends <A> {
public A() {
}
}
@@ -0,0 +1,7 @@
package B;
public class A extends <A> {
public A() {
}
}
@@ -772,6 +772,8 @@ public class OptimizeImportsTest extends OptimizeImportsTestCase {
public void testUnresolvedReferenceAfterParenthesis() {
doTest();
}
public void testInvalidExtendsList() { doTest(); }
private void doTest() {
doTest(".java");