List<PsiReference> (@NotNull PsiFile file) { final List<PsiReference> referencesList = new ArrayList<>(); file.accept(new PsiElementVisitor() { @Override public void visitElement(@NotNull PsiElement element) { referencesList.addAll(Arrays.asList(element.getReferences())); element.acceptChildren(this); } }); Collections.sort(referencesList, Comparator.comparingInt(o -> o.getElement().getTextRange().getStartOffset())); return referencesList; }