Search in sources :

Example 1 with LocalFileOrOutputArtifact

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));
}
Also used : ArtifactState(com.google.idea.blaze.base.filecache.ArtifactState) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) LocalFileOrOutputArtifact(com.google.devtools.intellij.model.ProjectData.LocalFileOrOutputArtifact) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with LocalFileOrOutputArtifact

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()));
    }
}
Also used : LocalFile(com.google.devtools.intellij.model.ProjectData.LocalFile) ArtifactState(com.google.idea.blaze.base.filecache.ArtifactState) LocalFileOrOutputArtifact(com.google.devtools.intellij.model.ProjectData.LocalFileOrOutputArtifact) ProjectData(com.google.devtools.intellij.model.ProjectData)

Aggregations

LocalFileOrOutputArtifact (com.google.devtools.intellij.model.ProjectData.LocalFileOrOutputArtifact)2 ArtifactState (com.google.idea.blaze.base.filecache.ArtifactState)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 ProjectData (com.google.devtools.intellij.model.ProjectData)1 LocalFile (com.google.devtools.intellij.model.ProjectData.LocalFile)1 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)1