PsiElement (Project project, Editor editor, PsiElement anchorStatement) { if (anchorStatement == null) { String message = JavaRefactoringBundle.message("refactoring.is.not.supported.in.the.current.context", getRefactoringName()); showErrorMessage(project, editor, message); return null; } if (checkAnchorBeforeThisOrSuper(project, editor, anchorStatement, getRefactoringName(), HelpID.INTRODUCE_VARIABLE)) return null; final PsiElement tempContainer = anchorStatement.getParent(); if (!(tempContainer instanceof PsiCodeBlock) && !CommonJavaRefactoringUtil.isLoopOrIf(tempContainer) && !(tempContainer instanceof PsiLambdaExpression) && (tempContainer.getParent() instanceof PsiLambdaExpression)) { String message = JavaRefactoringBundle.message("refactoring.is.not.supported.in.the.current.context", getRefactoringName()); showErrorMessage(project, editor, message); return null; } return tempContainer; }