void (Map<String, PackageAnnotator.PackageCoverageInfo> flattenPackages, Annotator annotator) { Map<String, PackageAnnotator.PackageCoverageInfo> packages = new HashMap<>(); for (var entry : flattenPackages.entrySet()) { String packageFQName = entry.getKey(); var info = entry.getValue(); annotator.annotatePackage(packageFQName, info, true); while (!packageFQName.isEmpty()) { packages.computeIfAbsent(packageFQName, k -> new PackageAnnotator.PackageCoverageInfo()).append(info); final int index = packageFQName.lastIndexOf('.'); if (index < 0) break; packageFQName = packageFQName.substring(0, index); } packages.computeIfAbsent("", k -> new PackageAnnotator.PackageCoverageInfo()).append(info); } for (Map.Entry<String, PackageAnnotator.PackageCoverageInfo> entry : packages.entrySet()) { annotator.annotatePackage(entry.getKey(), entry.getValue()); } }