DeclarationInfo (@NotNull PsiVariable variable) { PsiElement varDeclarationStatement = CommonJavaRefactoringUtil.getParentStatement(variable, false); if (varDeclarationStatement == null) return null; PsiStatement nextStatement = PsiTreeUtil.getNextSiblingOfType(varDeclarationStatement, PsiStatement.class); PsiDeclarationStatement nextDeclarationStatement = tryCast(nextStatement, PsiDeclarationStatement.class); DeclarationInfo nextDeclaration = findExistingAnonymousClass(variable, nextDeclarationStatement, true); if (nextDeclaration != null) return nextDeclaration; PsiDeclarationStatement previousDeclarationStatement = PsiTreeUtil.getPrevSiblingOfType(varDeclarationStatement, PsiDeclarationStatement.class); return findExistingAnonymousClass(variable, previousDeclarationStatement, false); }