mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
safe delete: ignore imports on inner classes (IDEA-180327)
This commit is contained in:
@@ -27,15 +27,10 @@ public class JavaImportSearcher extends ImportSearcher {
|
||||
final PsiFile containingFile = element.getContainingFile();
|
||||
if (!(containingFile instanceof PsiJavaFile)) return null;
|
||||
|
||||
if (onlyNonStatic) {
|
||||
PsiElement parent = element.getParent();
|
||||
if (parent instanceof PsiImportStatement) {
|
||||
return parent;
|
||||
}
|
||||
PsiImportStatementBase importStatementBase = PsiTreeUtil.getParentOfType(element, PsiImportStatementBase.class);
|
||||
if (onlyNonStatic && importStatementBase instanceof PsiImportStaticStatement) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return PsiTreeUtil.getParentOfType(element, PsiImportStatementBase.class);
|
||||
}
|
||||
return null;
|
||||
return importStatementBase;
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package p;
|
||||
|
||||
class B {
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package p;
|
||||
public class A {
|
||||
public static class Inner {}
|
||||
}
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package p;
|
||||
|
||||
import p.<caret>A.Inner;
|
||||
class B {
|
||||
|
||||
}
|
||||
@@ -168,6 +168,10 @@ public class SafeDeleteTest extends MultiFileTestCase {
|
||||
doTest("B");
|
||||
}
|
||||
|
||||
public void testSafeDeleteImportsOnInnerClasses() {
|
||||
doTest("p.B");
|
||||
}
|
||||
|
||||
public void testRemoveOverridersInspiteOfUnsafeUsages() {
|
||||
try {
|
||||
BaseRefactoringProcessor.ConflictsInTestsException.setTestIgnore(true);
|
||||
|
||||
Reference in New Issue
Block a user