diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java index 9ae284705ba7..09fc9efafb53 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java @@ -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); diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java index d0e7fc4ba825..95a4e0ff75bb 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java @@ -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); } diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterThrowsListFromMethodHierarchy.java b/java/java-tests/testData/codeInsight/overrideImplement/afterThrowsListFromMethodHierarchy.java new file mode 100644 index 000000000000..91c1993bd70c --- /dev/null +++ b/java/java-tests/testData/codeInsight/overrideImplement/afterThrowsListFromMethodHierarchy.java @@ -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(); + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterThrowsListUnrelatedMethods.java b/java/java-tests/testData/codeInsight/overrideImplement/afterThrowsListUnrelatedMethods.java new file mode 100644 index 000000000000..61e5da02a7b4 --- /dev/null +++ b/java/java-tests/testData/codeInsight/overrideImplement/afterThrowsListUnrelatedMethods.java @@ -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 { + + } + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/overrideImplement/beforeThrowsListFromMethodHierarchy.java b/java/java-tests/testData/codeInsight/overrideImplement/beforeThrowsListFromMethodHierarchy.java new file mode 100644 index 000000000000..b74c9772d2a8 --- /dev/null +++ b/java/java-tests/testData/codeInsight/overrideImplement/beforeThrowsListFromMethodHierarchy.java @@ -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 { + + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/overrideImplement/beforeThrowsListUnrelatedMethods.java b/java/java-tests/testData/codeInsight/overrideImplement/beforeThrowsListUnrelatedMethods.java new file mode 100644 index 000000000000..761ebcff3392 --- /dev/null +++ b/java/java-tests/testData/codeInsight/overrideImplement/beforeThrowsListUnrelatedMethods.java @@ -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 { + + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplement15Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplement15Test.java index ddf462953065..44990ea0df3b 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplement15Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/OverrideImplement15Test.java @@ -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); }