IDEA-191797 Fix bug when evaluation doesnt work in lambda code block

This commit is contained in:
Vitaliy.Bibaev
2018-05-12 16:19:01 +03:00
parent 8ee73e66e4
commit a9be351ccb
@@ -127,8 +127,11 @@ public class ExtractLightMethodObjectHandler {
// expand lambda to code block if needed
PsiElement containingMethod = PsiTreeUtil.getParentOfType(originalAnchor, PsiMember.class, PsiLambdaExpression.class);
if (containingMethod instanceof PsiLambdaExpression) {
PsiCodeBlock newBody = RefactoringUtil.expandExpressionLambdaToCodeBlock((PsiLambdaExpression)containingMethod);
originalAnchor = newBody.getStatements()[0];
PsiLambdaExpression lambdaExpression = (PsiLambdaExpression)containingMethod;
if (lambdaExpression.getBody() instanceof PsiExpression) {
PsiCodeBlock newBody = RefactoringUtil.expandExpressionLambdaToCodeBlock(lambdaExpression);
originalAnchor = newBody.getStatements()[0];
}
}
PsiElement anchor = RefactoringUtil.getParentStatement(originalAnchor, false);