correctly check for super call in constructor (IDEA-97203)

This commit is contained in:
anna
2012-12-11 22:02:28 +01:00
parent 224d9540b5
commit dea70f5fdd
4 changed files with 36 additions and 1 deletions
@@ -244,7 +244,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
if (toCatchExceptions) {
if (!(ref instanceof PsiReferenceExpression &&
((PsiReferenceExpression)ref).getQualifierExpression() instanceof PsiSuperExpression)) {
RefactoringUtil.isSuperOrThisCall(PsiTreeUtil.getParentOfType(ref, PsiStatement.class), true, false))) {
if (needToCatchExceptions(changeInfo, caller)) {
PsiClassType[] newExceptions =
callee != null ? getCalleeChangedExceptionInfo(callee) : getPrimaryChangedExceptionInfo(changeInfo);
@@ -0,0 +1,10 @@
class Base {
public B<caret>ase() {
}
}
class AAA extends Base {
public AAA() {
super();
}
}
@@ -0,0 +1,12 @@
import java.io.IOException;
class Base {
public Base() throws IOException {
}
}
class AAA extends Base {
public AAA() {
super();
}
}
@@ -251,6 +251,19 @@ public class ChangeSignatureTest extends LightRefactoringTestCase {
false);
}
public void testConstructorException() throws Exception {
doTest(null, null, null, new SimpleParameterGen(new ParameterInfoImpl[0]),
new GenExceptions() {
@Override
public ThrownExceptionInfo[] genExceptions(PsiMethod method) {
return new ThrownExceptionInfo[] {
new JavaThrownExceptionInfo(-1, JavaPsiFacade.getInstance(method.getProject()).getElementFactory().createTypeByFQClassName("java.io.IOException", method.getResolveScope()))
};
}
},
false);
}
public void testAddRuntimeException() throws Exception {
doTest(null, null, null, new SimpleParameterGen(new ParameterInfoImpl[0]),
new GenExceptions() {