PsiType (PsiMethodReferenceExpression expression) { final PsiTypeElement typeElement = expression.getQualifierType(); if (typeElement != null) { return typeElement.getType(); } else { PsiType qualifierType = null; final PsiElement qualifier = expression.getQualifier(); if (qualifier instanceof PsiExpression) { qualifierType = ((PsiExpression)qualifier).getType(); } if (qualifierType == null && qualifier instanceof PsiReferenceExpression) { return JavaPsiFacade.getElementFactory(expression.getProject()).createType((PsiReferenceExpression)qualifier); } return qualifierType; } }