void (final Editor editor, final PsiFile file, final PsiClass targetClass, final TestFramework framework) { if (framework instanceof JavaTestFramework && ((JavaTestFramework)framework).isSingleConfig()) { PsiElement alreadyExist = switch (myMethodKind) { case SET_UP -> framework.findSetUpMethod(targetClass); case TEAR_DOWN -> framework.findTearDownMethod(targetClass); default -> null; }; if (alreadyExist instanceof PsiMethod) { editor.getCaretModel().moveToOffset(alreadyExist.getNavigationElement().getTextOffset()); String message = JavaBundle.message("generate.test.support.method.error.method.already.exists", ((PsiMethod)alreadyExist).getName()); HintManager.getInstance().showErrorHint(editor, message); return; } } if (!CommonRefactoringUtil.checkReadOnlyStatus(file)) return; WriteCommandAction.runWriteCommandAction(file.getProject(), () -> { try { PsiDocumentManager.getInstance(file.getProject()).commitAllDocuments(); PsiMethod method = generateDummyMethod(file, editor, targetClass); if (method == null) return; TestIntegrationUtils.runTestMethodTemplate(myMethodKind, framework, editor, targetClass, method, "name", false, null); } catch (IncorrectOperationException e) { String message = JavaBundle.message("generate.test.support.method.error.cannot.generate.method", e.getMessage()); HintManager.getInstance().showErrorHint(editor, message); LOG.warn(e); } }); }