in base/src/com/google/idea/blaze/base/ideinfo/TargetIdeInfo.java [111:198]
public static TargetIdeInfo fromProto(
IntellijIdeInfo.TargetIdeInfo proto, @Nullable Instant syncTimeOverride) {
TargetKey key = proto.hasKey() ? TargetKey.fromProto(proto.getKey()) : null;
Kind kind = Kind.fromProto(proto);
if (key == null || kind == null) {
return null;
}
ImmutableSet.Builder<ArtifactLocation> sourcesBuilder = ImmutableSet.builder();
CIdeInfo cIdeInfo = null;
if (proto.hasCIdeInfo()) {
cIdeInfo = CIdeInfo.fromProto(proto.getCIdeInfo());
sourcesBuilder.addAll(cIdeInfo.getSources());
sourcesBuilder.addAll(cIdeInfo.getHeaders());
sourcesBuilder.addAll(cIdeInfo.getTextualHeaders());
}
JavaIdeInfo javaIdeInfo = null;
if (proto.hasJavaIdeInfo()) {
javaIdeInfo = JavaIdeInfo.fromProto(proto.getJavaIdeInfo());
sourcesBuilder.addAll(
ProtoWrapper.map(proto.getJavaIdeInfo().getSourcesList(), ArtifactLocation::fromProto));
}
PyIdeInfo pyIdeInfo = null;
if (proto.hasPyIdeInfo()) {
pyIdeInfo = PyIdeInfo.fromProto(proto.getPyIdeInfo());
sourcesBuilder.addAll(pyIdeInfo.getSources());
}
GoIdeInfo goIdeInfo = null;
if (proto.hasGoIdeInfo()) {
goIdeInfo = GoIdeInfo.fromProto(proto.getGoIdeInfo(), key.getLabel(), kind);
sourcesBuilder.addAll(goIdeInfo.getSources());
}
JsIdeInfo jsIdeInfo = null;
if (proto.hasJsIdeInfo()) {
jsIdeInfo = JsIdeInfo.fromProto(proto.getJsIdeInfo());
sourcesBuilder.addAll(jsIdeInfo.getSources());
}
TsIdeInfo tsIdeInfo = null;
if (proto.hasTsIdeInfo()) {
tsIdeInfo = TsIdeInfo.fromProto(proto.getTsIdeInfo());
sourcesBuilder.addAll(tsIdeInfo.getSources());
}
DartIdeInfo dartIdeInfo = null;
if (proto.hasDartIdeInfo()) {
dartIdeInfo = DartIdeInfo.fromProto(proto.getDartIdeInfo());
sourcesBuilder.addAll(dartIdeInfo.getSources());
}
Long syncTime =
syncTimeOverride != null
? Long.valueOf(syncTimeOverride.toEpochMilli())
: proto.getSyncTimeMillis() == 0 ? null : proto.getSyncTimeMillis();
return new TargetIdeInfo(
key,
kind,
proto.hasBuildFileArtifactLocation()
? ArtifactLocation.fromProto(proto.getBuildFileArtifactLocation())
: null,
ProtoWrapper.map(proto.getDepsList(), Dependency::fromProto),
ProtoWrapper.internStrings(proto.getTagsList()),
sourcesBuilder.build(),
cIdeInfo,
proto.hasCToolchainIdeInfo()
? CToolchainIdeInfo.fromProto(proto.getCToolchainIdeInfo())
: null,
javaIdeInfo,
proto.hasAndroidIdeInfo() ? AndroidIdeInfo.fromProto(proto.getAndroidIdeInfo()) : null,
proto.hasAndroidSdkIdeInfo()
? AndroidSdkIdeInfo.fromProto(proto.getAndroidSdkIdeInfo())
: null,
proto.hasAndroidAarIdeInfo()
? AndroidAarIdeInfo.fromProto(proto.getAndroidAarIdeInfo())
: null,
proto.hasAndroidInstrumentationInfo()
? AndroidInstrumentationInfo.fromProto(proto.getAndroidInstrumentationInfo())
: null,
pyIdeInfo,
goIdeInfo,
jsIdeInfo,
tsIdeInfo,
dartIdeInfo,
proto.hasTestInfo() ? TestIdeInfo.fromProto(proto.getTestInfo()) : null,
proto.hasJavaToolchainIdeInfo()
? JavaToolchainIdeInfo.fromProto(proto.getJavaToolchainIdeInfo())
: null,
proto.hasKtToolchainIdeInfo()
? KotlinToolchainIdeInfo.fromProto(proto.getKtToolchainIdeInfo())
: null,
syncTime);
}