boolean (final Project project, PsiLocalVariable localVariable, final Editor editor) { final PsiElement parent = localVariable.getParent(); if (!(parent instanceof PsiDeclarationStatement)) { String message = RefactoringBundle.getCannotRefactorMessage(JavaRefactoringBundle.message("error.wrong.caret.position.local.or.expression.name")); CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringNameText(), getHelpID()); return false; } LocalToFieldHandler localToFieldHandler = new LocalToFieldHandler(project, false){ @Override protected Settings showRefactoringDialog(PsiClass aClass, PsiLocalVariable local, PsiExpression[] occurences, boolean isStatic) { final PsiStatement statement = PsiTreeUtil.getParentOfType(local, PsiStatement.class); return IntroduceFieldHandler.this.showRefactoringDialog(project, editor, aClass, local.getInitializer(), local.getType(), occurences, local, statement); } @Override protected int getChosenClassIndex(List<PsiClass> classes) { return IntroduceFieldHandler.this.getChosenClassIndex(classes); } }; return localToFieldHandler.convertLocalToField(localVariable, editor); }