in java/io/bazel/rules/closure/webfiles/Webset.java [61:105]
public static Webset load(Map<Path, WebfileManifestInfo> manifests, WebpathInterner interner) {
int webfileCapacity = 0;
int unlinkCapacity = 16; // LinkedHashMultimap#DEFAULT_KEY_CAPACITY
for (WebfileManifestInfo manifest : manifests.values()) {
webfileCapacity += manifest.getWebfileCount();
unlinkCapacity = Math.max(unlinkCapacity, manifest.getUnlinkCount());
}
Map<Webpath, Webfile> webfiles = Maps.newLinkedHashMapWithExpectedSize(webfileCapacity);
Multimap<Webpath, Webpath> links = LinkedHashMultimap.create(webfileCapacity, 4);
Multimap<Webpath, Webpath> unlinks = LinkedHashMultimap.create(unlinkCapacity, 4);
for (Map.Entry<Path, WebfileManifestInfo> entry : manifests.entrySet()) {
Path manifestPath = entry.getKey();
Path zipPath = WebfilesUtils.getIncrementalZipPath(manifestPath);
WebfileManifestInfo manifest = entry.getValue();
String label = manifest.getLabel();
for (WebfileInfo info : manifest.getWebfileList()) {
Webpath webpath = interner.get(info.getWebpath());
webfiles.put(webpath, Webfile.create(webpath, zipPath, label, info));
}
for (MultimapInfo mapping : manifest.getLinkList()) {
Webpath from = interner.get(mapping.getKey());
for (Webpath to : Iterables.transform(mapping.getValueList(), interner)) {
// When compiling web_library rules, if the strict dependency checking invariant holds
// true, we can choose to only load adjacent manifests, rather than transitive ones. The
// adjacent manifests may contain links to transitive web files which will not be in the
// webfiles map.
if (webfiles.containsKey(to)) {
links.put(from, to);
checkArgument(!unlinks.containsEntry(from, to),
"Has a use case for resurrected links been discovered? %s -> %s", from, to);
}
}
}
for (MultimapInfo mapping : manifest.getUnlinkList()) {
unlinks.putAll(
interner.get(mapping.getKey()),
Collections2.transform(mapping.getValueList(), interner));
}
}
for (Map.Entry<Webpath, Webpath> entry : unlinks.entries()) {
links.remove(entry.getKey(), entry.getValue());
}
unlinks.clear();
return new AutoValue_Webset(webfiles, links, interner);
}