mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
safe delete: do not insert additional extends item if already present (IDEA-106144)
This commit is contained in:
+6
-1
@@ -18,6 +18,7 @@ package com.intellij.refactoring.safeDelete.usageInfo;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
|
||||
/**
|
||||
@@ -50,15 +51,19 @@ public class SafeDeleteExtendsClassUsageInfo extends SafeDeleteReferenceUsageInf
|
||||
if (extendsList != null) {
|
||||
final PsiClassType[] referenceTypes = extendsList.getReferencedTypes();
|
||||
final PsiReferenceList listToAddExtends = refClass.isInterface() == myExtendingClass.isInterface() ? myExtendingClass.getExtendsList() : extendingImplementsList;
|
||||
final PsiClassType[] existingRefTypes = listToAddExtends.getReferencedTypes();
|
||||
for (PsiClassType referenceType : referenceTypes) {
|
||||
if (ArrayUtilRt.find(existingRefTypes, referenceType) > -1) continue;
|
||||
listToAddExtends.add(elementFactory.createReferenceElementByType((PsiClassType)mySubstitutor.substitute(referenceType)));
|
||||
}
|
||||
}
|
||||
|
||||
final PsiReferenceList implementsList = refClass.getImplementsList();
|
||||
if (implementsList != null) {
|
||||
final PsiClassType[] referenceTypes = implementsList.getReferencedTypes();
|
||||
final PsiClassType[] existingRefTypes = extendingImplementsList.getReferencedTypes();
|
||||
PsiClassType[] referenceTypes = implementsList.getReferencedTypes();
|
||||
for (PsiClassType referenceType : referenceTypes) {
|
||||
if (ArrayUtilRt.find(existingRefTypes, referenceType) > -1) continue;
|
||||
extendingImplementsList.add(elementFactory.createReferenceElementByType((PsiClassType)mySubstitutor.substitute(referenceType)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
nterface Foo {}
|
||||
interface Ba<caret>r extends Foo {}
|
||||
class FooBarImpl implements Foo, Bar {}
|
||||
@@ -0,0 +1,3 @@
|
||||
nterface Foo {}
|
||||
|
||||
class FooBarImpl implements Foo {}
|
||||
@@ -65,6 +65,10 @@ public class SafeDeleteTest extends MultiFileTestCase {
|
||||
doTest("IFoo");
|
||||
}
|
||||
|
||||
public void testUsageInExtendsList() throws Exception {
|
||||
doSingleFileTest();
|
||||
}
|
||||
|
||||
public void testParameterInHierarchy() throws Exception {
|
||||
myDoCompare = false;
|
||||
doTest("C2");
|
||||
|
||||
Reference in New Issue
Block a user