mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
change class signature should not touch instanceof statements (IDEA-82661) [roma] (cherry picked from commit dcd5e50)
This commit is contained in:
+1
@@ -72,6 +72,7 @@ public class ChangeClassSignatureProcessor extends BaseRefactoringProcessor {
|
||||
if (reference.getElement() instanceof PsiJavaCodeReferenceElement) {
|
||||
PsiJavaCodeReferenceElement referenceElement = (PsiJavaCodeReferenceElement)reference.getElement();
|
||||
PsiElement parent = referenceElement.getParent();
|
||||
if (parent instanceof PsiTypeElement && parent.getParent() instanceof PsiInstanceOfExpression) continue;
|
||||
if (parent instanceof PsiTypeElement || parent instanceof PsiNewExpression || parent instanceof PsiAnonymousClass ||
|
||||
parent instanceof PsiReferenceList) {
|
||||
if (!hadTypeParameters || referenceElement.getTypeParameters().length > 0) {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
public class ChangeClassSignatureAddParameter {
|
||||
|
||||
public void test(Object object) {
|
||||
if (object instanceof MyClass) {
|
||||
MyClass myClass = (MyClass)object;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class My<caret>Class {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
public class ChangeClassSignatureAddParameter {
|
||||
|
||||
public void test(Object object) {
|
||||
if (object instanceof MyClass) {
|
||||
MyClass<String> myClass = (MyClass<String>)object;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MyClass<T> {
|
||||
}
|
||||
+11
@@ -30,6 +30,17 @@ public class ChangeClassSignatureTest extends LightRefactoringTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
public void testInstanceOf() throws Exception {
|
||||
doTest(new GenParams() {
|
||||
@Override
|
||||
public TypeParameterInfo[] gen(PsiClass aClass) throws IncorrectOperationException {
|
||||
return new TypeParameterInfo[]{
|
||||
new TypeParameterInfo(aClass, "T", "java.lang.String")
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testSubstituteParamInsideClass() throws Exception {
|
||||
doTest(new GenParams() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user