PsiElement[] (@NotNull PsiCodeBlock body, @NotNull PsiVariable def, @NotNull PsiElement ref, boolean rethrow) { try { RefsDefs refsDefs = new RefsDefs(body) { final PsiManager psiManager = def.getManager(); @Override protected int nNext(int index) { return instructions.get(index).nNext(); } @Override protected int getNext(int index, int no) { return instructions.get(index).getNext(index, no); } @Override protected boolean defs() { return false; } @Override protected void processInstruction(@NotNull final Set<? super PsiElement> res, @NotNull final Instruction instruction, int index) { if (instruction instanceof ReadVariableInstruction) { ReadVariableInstruction instructionR = (ReadVariableInstruction)instruction; if (psiManager.areElementsEquivalent(instructionR.variable, def)) { final PsiElement element = flow.getElement(index); element.accept(new JavaRecursiveElementWalkingVisitor() { @Override public void visitReferenceExpression(@NotNull PsiReferenceExpression ref) { if (ref.isReferenceTo(def)) { res.add(ref); } } }); } } } }; return refsDefs.get(def, ref); } catch (AnalysisCanceledException e) { if (rethrow) { ExceptionUtil.rethrowAllAsUnchecked(e); } return PsiElement.EMPTY_ARRAY; } }