mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extract superclass: process same name type parameters inside class members
This commit is contained in:
+7
-14
@@ -199,20 +199,13 @@ public class ExtractSuperClassUtil {
|
||||
for (final MemberInfo info : selectedMembers) {
|
||||
movedElements.add(info.getMember());
|
||||
}
|
||||
final PsiTypeParameterList typeParameterList = RefactoringUtil.createTypeParameterListWithUsedTypeParameters(null,
|
||||
new Condition<PsiTypeParameter>() {
|
||||
@Override
|
||||
public boolean value(
|
||||
PsiTypeParameter parameter) {
|
||||
return
|
||||
findTypeParameterInDerived(
|
||||
derivedClass,
|
||||
parameter
|
||||
.getName()) !=
|
||||
null;
|
||||
}
|
||||
}, PsiUtilCore
|
||||
.toPsiElementArray(movedElements));
|
||||
final Condition<PsiTypeParameter> filter = new Condition<PsiTypeParameter>() {
|
||||
@Override
|
||||
public boolean value(PsiTypeParameter parameter) {
|
||||
return findTypeParameterInDerived(derivedClass, parameter.getName()) == parameter;
|
||||
}
|
||||
};
|
||||
final PsiTypeParameterList typeParameterList = RefactoringUtil.createTypeParameterListWithUsedTypeParameters(null, filter, PsiUtilCore.toPsiElementArray(movedElements));
|
||||
final PsiTypeParameterList originalTypeParameterList = superClass.getTypeParameterList();
|
||||
assert originalTypeParameterList != null;
|
||||
final PsiTypeParameterList newList = typeParameterList != null ? (PsiTypeParameterList)originalTypeParameterList.replace(typeParameterList) : originalTypeParameterList;
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class Test {
|
||||
interface A<T> {
|
||||
void foo(T t);
|
||||
}
|
||||
|
||||
interface B<T> {
|
||||
void bar(T t);
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
public class TestSubclass<T> extends Test {
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
public class Test<T> {
|
||||
interface A<T> {
|
||||
void foo(T t);
|
||||
}
|
||||
interface B<T> {
|
||||
void bar(T t);
|
||||
}
|
||||
}
|
||||
@@ -104,6 +104,10 @@ public class ExtractSuperClassTest extends RefactoringTestCase {
|
||||
doTest("Test", "TestSubclass", new RefactoringTestUtil.MemberDescriptor("a", PsiField.class));
|
||||
}
|
||||
|
||||
public void testSameTypeParameterName() throws Exception {
|
||||
doTest("Test", "TestSubclass", new RefactoringTestUtil.MemberDescriptor("A", PsiClass.class), new RefactoringTestUtil.MemberDescriptor("B", PsiClass.class));
|
||||
}
|
||||
|
||||
public void testExtendsLibraryClass() throws Exception {
|
||||
doTest("Test", "TestSubclass");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user