void (PsiElement context, final PsiVariable variable, final List<? super PsiReferenceExpression> references) { context.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) { if (expression.resolve() == variable) references.add(expression); super.visitReferenceExpression(expression); } }); }