use of com.google.devtools.intellij.model.ProjectData.LocalFileOrOutputArtifact in project intellij by bazelbuild.
the class BlazeIdeInterfaceState method fromProto.
public static BlazeIdeInterfaceState fromProto(ProjectData.BlazeIdeInterfaceState proto) {
ImmutableMap<String, TargetKey> targets = ProtoWrapper.map(proto.getFileToTargetMap(), ArtifactState::migrateOldKeyFormat, TargetKey::fromProto);
ImmutableMap.Builder<String, ArtifactState> artifacts = ImmutableMap.builder();
for (LocalFileOrOutputArtifact output : proto.getIdeInfoFilesList()) {
ArtifactState state = ArtifactStateProtoConverter.fromProto(output);
if (state == null) {
continue;
}
artifacts.put(state.getKey(), state);
}
return new BlazeIdeInterfaceState(artifacts.build(), ImmutableBiMap.copyOf(targets));
}
use of com.google.devtools.intellij.model.ProjectData.LocalFileOrOutputArtifact in project intellij by bazelbuild.
the class ArtifactMetadata method forArtifact.
/**
* Returns the relevant metadata for an {@code artifact} that needs to be persisted.
*
* @throws ArtifactNotFoundException if the artifact is not present.
*/
public static ArtifactMetadata forArtifact(OutputArtifact artifact) throws ArtifactNotFoundException {
ArtifactState artifactState = artifact.toArtifactState();
if (artifactState == null) {
throw new ArtifactNotFoundException(artifact);
}
// Serialize to proto to make grabbing the fields easier
LocalFileOrOutputArtifact serializedArtifact = artifactState.serializeToProto();
if (serializedArtifact.hasArtifact()) {
ProjectData.OutputArtifact o = serializedArtifact.getArtifact();
return new ArtifactMetadata(o.getRelativePath(), o.getId());
} else {
LocalFile o = serializedArtifact.getLocalFile();
String relativePath = o.getRelativePath().isEmpty() ? o.getPath() : o.getRelativePath();
return new ArtifactMetadata(relativePath, Long.toString(o.getTimestamp()));
}
}
Aggregations