IDEA-177191 Compiling evaluator fails inside a one-line lambda

This commit is contained in:
Egor.Ushakov
2017-08-07 15:47:29 +03:00
parent 2d94c4ad80
commit 83c582b83e
@@ -114,6 +114,18 @@ public class ExtractLightMethodObjectHandler {
return null;
}
// expand lambda to code block if needed
PsiElement containingMethod = PsiTreeUtil.getParentOfType(originalAnchor, PsiMember.class, PsiLambdaExpression.class);
if (containingMethod instanceof PsiLambdaExpression) {
PsiElement body = ((PsiLambdaExpression)containingMethod).getBody();
if (body instanceof PsiExpression) {
PsiElement newBody = ((PsiLambdaExpression)RefactoringUtil.expandExpressionLambdaToCodeBlock(body)).getBody();
if (newBody instanceof PsiCodeBlock) {
originalAnchor = ((PsiCodeBlock)newBody).getStatements()[0];
}
}
}
PsiElement anchor = RefactoringUtil.getParentStatement(originalAnchor, false);
if (anchor == null) {
if (PsiTreeUtil.getParentOfType(originalAnchor, PsiCodeBlock.class) != null) {