diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExceptionToThrowsFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExceptionToThrowsFix.java index 55bebfc91553..36bfb93897a7 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExceptionToThrowsFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddExceptionToThrowsFix.java @@ -94,12 +94,12 @@ public class AddExceptionToThrowsFix extends BaseIntentionAction { processSuperMethods = false; } - if (!FileModificationService.getInstance().prepareFileForWrite(targetMethod.getContainingFile())) return; + List toModify = new ArrayList<>(); + toModify.add(targetMethod); if (processSuperMethods) { - for (PsiMethod superMethod : superMethods) { - if (!FileModificationService.getInstance().prepareFileForWrite(superMethod.getContainingFile())) return; - } + Collections.addAll(toModify, superMethods); } + if (!FileModificationService.getInstance().preparePsiElementsForWrite(toModify)) return; WriteAction.run(() -> { processMethod(project, targetMethod, unhandledExceptions);