use of com.google.idea.blaze.base.filecache.ArtifactStateProtoConverter in project intellij by bazelbuild.
the class JdepsState method fromProto.
private static JdepsState fromProto(ProjectData.JdepsState proto) {
if (proto.getFileToTargetCount() == 0) {
return fromNewProto(proto.getTargetToJdeps());
}
// migrate from the old proto format
ImmutableMap<TargetKey, String> targetToArtifactKey = proto.getFileToTargetMap().entrySet().stream().collect(toImmutableMap(e -> TargetKey.fromProto(e.getValue()), Map.Entry::getKey, (a, b) -> a));
ImmutableMap<String, ArtifactState> artifacts = proto.getJdepsFilesList().stream().map(ArtifactStateProtoConverter::fromProto).filter(Objects::nonNull).collect(toImmutableMap(ArtifactState::getKey, s -> s, (a, b) -> a));
ImmutableList.Builder<JdepsData> data = ImmutableList.builder();
for (ProjectData.TargetToJdepsMap.Entry e : proto.getTargetToJdeps().getEntriesList()) {
TargetKey key = TargetKey.fromProto(e.getKey());
ImmutableList<String> jdeps = ProtoWrapper.internStrings(e.getValueList());
String artifactKey = targetToArtifactKey.get(key);
ArtifactState file = artifactKey != null ? artifacts.get(artifactKey) : null;
if (file != null) {
data.add(JdepsData.create(key, jdeps, file));
}
}
return new JdepsState(data.build());
}
Aggregations