void (@NotNull final Project project, final Editor editor, final PsiFile file, final DataContext dataContext) { final int offset = editor.getCaretModel().getOffset(); final PsiElement element = file.findElementAt(offset); final PsiClass psiClass = getParentNamedClass(element); if (psiClass == null) { showErrorMessage(JavaRefactoringBundle.message("replace.constructor.builder.error.caret.position"), project, editor); return; } final PsiMethod[] constructors = psiClass.getConstructors(); if (constructors.length == 0) { showErrorMessage(JavaRefactoringBundle.message("replace.constructor.builder.error.no.constructors"), project, editor); return; } new ReplaceConstructorWithBuilderDialog(project, constructors).show(); }