PsiLocalVariable (@NotNull PsiElement declaration) { if (!(declaration instanceof PsiDeclarationStatement)) return null; final PsiElement[] declaredElements = ((PsiDeclarationStatement)declaration).getDeclaredElements(); if (declaredElements.length != 1) return null; return ObjectUtils.tryCast(declaredElements[0], PsiLocalVariable.class); }