AnAction (DataContext dataContext) { final Project project = CommonDataKeys.PROJECT.getData(dataContext); final Editor editor = CommonDataKeys.EDITOR.getData(dataContext); final PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext); final PsiClass targetClass = editor == null || file == null ? null : getTargetClass(editor, file); if (targetClass != null) { final List<TestFramework> frameworks = TestIntegrationUtils.findSuitableFrameworks(targetClass); final TestIntegrationUtils.MethodKind methodKind = ((MyHandler)getHandler()).myMethodKind; if (!frameworks.isEmpty()) { return new AnAction(JavaBundle.message("action.text.edit.template")) { @Override public void actionPerformed(@NotNull AnActionEvent e) { chooseAndPerform(editor, frameworks, framework -> { final FileTemplateDescriptor descriptor = methodKind.getFileTemplateDescriptor(framework); if (descriptor != null) { final String fileName = descriptor.getFileName(); AllFileTemplatesConfigurable.editCodeTemplate(FileUtilRt.getNameWithoutExtension(fileName), project); } else { String message = JavaBundle.message( "generate.test.support.method.error.no.template.found.for.framework", framework.getName(), BaseGenerateTestSupportMethodAction.this.getTemplatePresentation().getText()); HintManager.getInstance().showErrorHint(editor, message); } }); } }; } } return null; }