PsiVariable (@Nullable PsiExpression expression) { PsiExpression nakedExpression = skipParenthesizedExprDown(expression); PsiReferenceExpression referenceExpression = tryCast(nakedExpression, PsiReferenceExpression.class); if (referenceExpression == null) return null; PsiElement resolvedExpr = referenceExpression.resolve(); PsiLocalVariable localVariable = tryCast(resolvedExpr, PsiLocalVariable.class); if (localVariable != null) return localVariable; return tryCast(resolvedExpr, PsiParameter.class); }