lambda return value: do not check containing method name against lambda return value

This commit is contained in:
Anna Kozlova
2014-11-18 18:36:30 +01:00
parent a86746b8d0
commit 7ccff9a7e8
2 changed files with 15 additions and 3 deletions
@@ -156,10 +156,10 @@ public class SuspiciousNameCombinationInspectionBase extends BaseJavaBatchLocalI
@Override
public void visitReturnStatement(final PsiReturnStatement statement) {
final PsiExpression returnValue = statement.getReturnValue();
PsiMethod containingMethod = PsiTreeUtil.getParentOfType(returnValue, PsiMethod.class);
if (returnValue instanceof PsiReferenceExpression && containingMethod != null) {
PsiElement containingMethod = PsiTreeUtil.getParentOfType(returnValue, PsiMethod.class, PsiLambdaExpression.class);
if (returnValue instanceof PsiReferenceExpression && containingMethod instanceof PsiMethod) {
final String refName = ((PsiReferenceExpression)returnValue).getReferenceName();
checkCombination(returnValue, containingMethod.getName(), refName, "suspicious.name.return");
checkCombination(returnValue, ((PsiMethod)containingMethod).getName(), refName, "suspicious.name.return");
}
}
@@ -3,4 +3,16 @@ public class ReturnValue {
int y=0;
return y;
}
interface I {
int m();
}
public int getY() {
I i = () -> {
int x = 0;
return x;
}
return i.m();
}
}