unused return value inspection: method reference awareness (IDEA-134991)

This commit is contained in:
Anna Kozlova
2015-01-07 11:37:44 +01:00
parent 49a192f27f
commit 49f82c1948
4 changed files with 38 additions and 1 deletions

View File

@@ -211,6 +211,14 @@ public class RefJavaUtilImpl extends RefJavaUtil{
PsiMethod psiMethod = (PsiMethod)psiResolved;
RefMethodImpl refMethod = (RefMethodImpl)refResolved;
if (refExpression instanceof PsiMethodReferenceExpression) {
PsiType returnType = psiMethod.getReturnType();
if (!psiMethod.isConstructor() && returnType != PsiType.VOID) {
refMethod.setReturnValueUsed(true);
addTypeReference(psiFrom, returnType, refFrom.getRefManager());
}
return;
}
PsiMethodCallExpression call = PsiTreeUtil.getParentOfType(
refExpression,
PsiMethodCallExpression.class