PsiVariable (@NotNull PsiReferenceExpression refExpr) { if (refExpr.isQualified()) return null; PsiElement refElement = refExpr.resolve(); if (refElement instanceof PsiLocalVariable || refElement instanceof PsiParameter) { if (!isVariableDeclaredInMethod((PsiVariable)refElement)) return null; return (PsiVariable)refElement; } return null; }