[java-intention] IDEA-357879 "Replace catch sections with throw" intention doesn't check ancestors

- fix test's flakiness

GitOrigin-RevId: ce2d52a107441215c5c8f953916e2203196fbc25
This commit is contained in:
Mikhail Pyltsin
2024-08-19 23:55:03 +02:00
committed by intellij-monorepo-bot
parent 9b8735ca88
commit 46c33c46e3
2 changed files with 6 additions and 1 deletions

View File

@@ -69,7 +69,7 @@ public final class ConvertCatchToThrowsIntention extends PsiBasedModCommandActio
PsiFile containingFile = catchSection.getContainingFile();
PsiFile copyCatchSectionContainingFile = copyCatchSection.getContainingFile();
for (PsiMethod superMethod : superMethods) {
if (!superMethod.isWritable() || !superMethod.isPhysical()) continue;
if (!superMethod.isPhysical() || superMethod instanceof PsiCompiledElement) continue;
if (superMethod.getContainingFile() == containingFile) {
superMethodsToModify.add(
PsiTreeUtil.findSameElementInCopy(superMethod, copyCatchSectionContainingFile));

View File

@@ -3,6 +3,8 @@
*/
package com.siyeh.ipp.exceptions;
import com.intellij.ui.ChooserInterceptor;
import com.intellij.ui.UiInterceptors;
import com.siyeh.IntentionPowerPackBundle;
import com.siyeh.ipp.IPPTestCase;
@@ -23,6 +25,9 @@ public class ConvertCatchToThrowsTest extends IPPTestCase {
public void testInLoopSingleLine() { doTest(); }
public void testInLoopSingleLineDeclaration() { doTest(); }
public void testWithSuperMethods() {
UiInterceptors.register(
new ChooserInterceptor(null,
IntentionPowerPackBundle.message("convert.catch.to.throws.super.and.current.methods")));
doTest();
}