mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
delete imports on safe delete of class (IDEA-139288)
This commit is contained in:
+5
-2
@@ -46,8 +46,11 @@ public class SafeDeleteReferenceJavaDeleteUsageInfo extends SafeDeleteReferenceS
|
||||
LOG.assertTrue(element != null);
|
||||
PsiElement importStatement = ImportSearcher.getImport(element, false);
|
||||
if (importStatement != null) {
|
||||
if (element instanceof PsiImportStaticReferenceElement &&
|
||||
((PsiImportStaticReferenceElement)element).multiResolve(false).length < 2) {
|
||||
if (element instanceof PsiImportStaticReferenceElement) {
|
||||
if (((PsiImportStaticReferenceElement)element).multiResolve(false).length < 2) {
|
||||
importStatement.delete();
|
||||
}
|
||||
} else {
|
||||
importStatement.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
class B {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
public class A {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import <caret>A;
|
||||
class B {
|
||||
|
||||
}
|
||||
@@ -149,6 +149,10 @@ public class SafeDeleteTest extends MultiFileTestCase {
|
||||
doTest("A");
|
||||
}
|
||||
|
||||
public void testSafeDeleteImports() throws Exception {
|
||||
doTest("B");
|
||||
}
|
||||
|
||||
public void testRemoveOverridersInspiteOfUnsafeUsages() throws Exception {
|
||||
try {
|
||||
BaseRefactoringProcessor.ConflictsInTestsException.setTestIgnore(true);
|
||||
|
||||
Reference in New Issue
Block a user