PsiLocalVariable (PsiElement element) { if (element instanceof PsiReferenceExpression referenceExpression) { if (referenceExpression.getQualifierExpression() == null) { return ObjectUtils.tryCast(referenceExpression.resolve(), PsiLocalVariable.class); } } return null; }