List<PsiReferenceExpression> (@NotNull PsiLocalVariable variable) { PsiElement outerCodeBlock = PsiUtil.getVariableCodeBlock(variable, null); if (outerCodeBlock == null) return emptyList(); List<PsiReferenceExpression> references = new SmartList<>(); outerCodeBlock.accept(new JavaRecursiveElementVisitor() { @Override public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) { super.visitReferenceExpression(expression); if (ExpressionUtils.isReferenceTo(expression, variable)) { references.add(expression); } } }); return references; }