void (Map<VirtualFile, PackageAnnotator.PackageCoverageInfo> flattenDirectories, Annotator annotator, Set<VirtualFile> sourceRoots) { Map<VirtualFile, PackageAnnotator.DirCoverageInfo> directories = new HashMap<>(); for (var entry : flattenDirectories.entrySet()) { var info = entry.getValue(); VirtualFile dir = entry.getKey(); while (dir != null) { directories.computeIfAbsent(dir, PackageAnnotator.DirCoverageInfo::new).append(info); if (sourceRoots.contains(dir)) break; dir = dir.getParent(); } } for (PackageAnnotator.DirCoverageInfo dir : directories.values()) { annotator.annotateSourceDirectory(dir.sourceRoot, dir); } }