List<UsageGroup> (@NotNull Usage usage, UsageTarget @NotNull [] targets) { if (!(usage instanceof UsageInFile usageInFile)) { return Collections.emptyList(); } List<UsageGroup> result = new ArrayList<>(); VirtualFile file = usageInFile.getFile(); if (file == null) { return Collections.emptyList(); } if (file instanceof VirtualFileWindow) { file = ((VirtualFileWindow)file).getDelegate(); } VirtualFile dir = file.getParent(); if (compactMiddleDirectories) { UsageGroup group = myDirectoryGroupingRule.getGroupForFile(dir); result.add(group); } else { VirtualFile baseDir = ProjectUtil.guessProjectDir(myProject); while (dir != null && !dir.equals(baseDir)) { UsageGroup group = myDirectoryGroupingRule.getGroupForFile(dir); result.add(group); dir = dir.getParent(); } } Collections.reverse(result); return result; }