void (@NotNull IntentionAction action, @NotNull PsiFile file, @NotNull Editor editor) { // Test that action will automatically clear the read-only attribute if modification is necessary. // If your test fails due to this, make sure that your quick-fix/intention // overrides "getElementToMakeWritable" or has the following line: // if (!FileModificationService.getInstance().prepareFileForWrite(file)) return; Project project = file.getProject(); VirtualFile vFile = Objects.requireNonNull(InjectedLanguageManager.getInstance(project).getTopLevelFile(file)).getVirtualFile(); withReadOnlyFile(vFile, project, () -> { try { ApplicationManager.getApplication().invokeLater(() -> { try { boolean executed = ShowIntentionActionsHandler.chooseActionAndInvoke(file, editor, action, action.getText()); if (!executed) { boolean available = action.isAvailable(project, editor, file); Assert.fail("Quick fix '" + action.getText() + "' (" + action.getClass()+")"+ " hasn't executed. isAvailable()="+available); } } catch (StubTextInconsistencyException e) { PsiTestUtil.compareStubTexts(e); } }); UIUtil.dispatchAllInvocationEvents(); checkPsiTextConsistency(project, vFile); } catch (AssertionError e) { ExceptionUtil.rethrowUnchecked(ExceptionUtil.getRootCause(e)); throw e; } }); }