List<UsageInfo> (final PsiElement aClass, GlobalSearchScope searchScope) { List<UsageInfo> results = new ArrayList<>(); for (PsiReference usage : ReferencesSearch.search(aClass, searchScope, false)) { results.add(new UsageInfo(usage)); } results.sort(Comparator.<UsageInfo, String>comparing(u -> { VirtualFile file = u.getVirtualFile(); return file == null ? null : file.getName(); }).thenComparingInt(u->{ Segment range = u.getNavigationRange(); return range == null ? 0 : range.getStartOffset(); })); return results; }