boolean (PsiElement anchor, PsiVariable assignedVariable) { PsiDeclarationStatement declaration = tryCast(PsiTreeUtil.getPrevSiblingOfType(anchor, PsiStatement.class), PsiDeclarationStatement.class); if (declaration != null) { PsiElement[] elements = declaration.getDeclaredElements(); if (elements.length == 1) { PsiLocalVariable localVariable = tryCast(elements[0], PsiLocalVariable.class); if (localVariable != null && localVariable == assignedVariable) { return true; } } } return false; }