change class signature should not touch instanceof statements (IDEA-82661) [roma] (cherry picked from commit dcd5e50)

This commit is contained in:
anna
2012-03-21 18:02:04 +01:00
parent 85d86cea33
commit 7bd0e144e9
4 changed files with 34 additions and 0 deletions
@@ -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> {
}
@@ -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