delete imports on safe delete of class (IDEA-139288)

This commit is contained in:
Anna Kozlova
2015-04-16 20:30:33 +02:00
parent 09f4d7ea1f
commit 3e57002e28
5 changed files with 19 additions and 2 deletions
@@ -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);