mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
compose throws list on override: ignore supers of super method, ensure same thrown types do not appear in the list (IDEA-166623)
This commit is contained in:
@@ -34,10 +34,7 @@ import com.intellij.psi.impl.source.codeStyle.JavaCodeStyleManagerImpl;
|
||||
import com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl;
|
||||
import com.intellij.psi.javadoc.PsiDocComment;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.refactoring.util.RefactoringUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -297,7 +294,7 @@ public class GenerateMembersUtil {
|
||||
if (target instanceof PsiClass) {
|
||||
final PsiMethod[] methods = ((PsiClass)target).findMethodsBySignature(sourceMethod, true);
|
||||
for (PsiMethod psiMethod : methods) {
|
||||
if (psiMethod != null && psiMethod != sourceMethod) {
|
||||
if (psiMethod != null && psiMethod != sourceMethod && !MethodSignatureUtil.isSuperMethod(psiMethod, sourceMethod)) {
|
||||
PsiClass aSuper = psiMethod.getContainingClass();
|
||||
if (aSuper != null && aSuper != target) {
|
||||
PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(aSuper, (PsiClass)target, PsiSubstitutor.EMPTY);
|
||||
|
||||
@@ -515,16 +515,14 @@ public class ExceptionUtil {
|
||||
} else if (classType.isAssignableFrom(psiClassType)) {
|
||||
if (isUncheckedException(classType) == isUncheckedException(psiClassType)) {
|
||||
replacement.add(psiClassType);
|
||||
iterator.remove();
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
ex.removeAll(replacement);
|
||||
ex.addAll(replacement);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
class Outer {
|
||||
private interface IA {
|
||||
void print() throws FileNotFoundException, IOException;
|
||||
}
|
||||
|
||||
private static class A implements IA {
|
||||
public void print() throws FileNotFoundException, IOException {
|
||||
}
|
||||
}
|
||||
|
||||
private static class B extends A {
|
||||
@Override
|
||||
public void print() throws FileNotFoundException, IOException {
|
||||
super.print();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
class Outer {
|
||||
private interface IA {
|
||||
void print() throws FileNotFoundException, IOException;
|
||||
}
|
||||
|
||||
private static class A {
|
||||
public void print() throws FileNotFoundException, IOException {
|
||||
}
|
||||
}
|
||||
|
||||
private static class B extends A implements IA {
|
||||
public void print() throws IOException, FileNotFoundException {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
class Outer {
|
||||
private interface IA {
|
||||
void print() throws FileNotFoundException, IOException;
|
||||
}
|
||||
|
||||
private static class A implements IA {
|
||||
public void print() throws FileNotFoundException, IOException {
|
||||
}
|
||||
}
|
||||
|
||||
private static class B extends A {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
class Outer {
|
||||
private interface IA {
|
||||
void print() throws FileNotFoundException, IOException;
|
||||
}
|
||||
|
||||
private static class A {
|
||||
public void print() throws FileNotFoundException, IOException {
|
||||
}
|
||||
}
|
||||
|
||||
private static class B extends A implements IA {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,8 @@ public class OverrideImplement15Test extends LightCodeInsightTestCase {
|
||||
public void testSimple() { doTest(true); }
|
||||
public void testAnnotation() { doTest(true); }
|
||||
public void testJavadocForChangedParamName() { doTest(true); }
|
||||
public void testThrowsListFromMethodHierarchy() { doTest(true); }
|
||||
public void testThrowsListUnrelatedMethods() { doTest(true); }
|
||||
public void testIncomplete() { doTest(false); }
|
||||
public void testSubstitutionInTypeParametersList() { doTest(false); }
|
||||
public void testTestMissed() { doTest(false); }
|
||||
|
||||
Reference in New Issue
Block a user