Search in sources :

Example 1 with AndroidSdkIdeInfo

use of com.google.idea.blaze.base.ideinfo.AndroidSdkIdeInfo in project intellij by bazelbuild.

the class BlazeAndroidLiteSyncPlugin method getSdkLibrary.

@Nullable
private static BlazeLibrary getSdkLibrary(BlazeProjectData blazeProjectData) {
    List<AndroidSdkIdeInfo> sdkTargets = androidSdkTargets(blazeProjectData.targetMap);
    if (sdkTargets.isEmpty()) {
        return null;
    }
    // for now, just add the first one found
    // TODO: warn if there's more than one
    ArtifactLocation sdk = sdkTargets.stream().map(info -> info.androidJar).filter(Objects::nonNull).findFirst().orElse(null);
    return sdk != null ? new BlazeJarLibrary(new LibraryArtifact(null, sdk, ImmutableList.of())) : null;
}
Also used : BlazeSyncPlugin(com.google.idea.blaze.base.sync.BlazeSyncPlugin) LanguageClass(com.google.idea.blaze.base.model.primitives.LanguageClass) ImmutableSet(com.google.common.collect.ImmutableSet) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) BlazeLibrary(com.google.idea.blaze.base.model.BlazeLibrary) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact) LibrarySource(com.google.idea.blaze.base.sync.libraries.LibrarySource) Set(java.util.Set) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) WorkspaceType(com.google.idea.blaze.base.model.primitives.WorkspaceType) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) AndroidSdkIdeInfo(com.google.idea.blaze.base.ideinfo.AndroidSdkIdeInfo) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) Nullable(javax.annotation.Nullable) Objects(java.util.Objects) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) AndroidSdkIdeInfo(com.google.idea.blaze.base.ideinfo.AndroidSdkIdeInfo) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact) Nullable(javax.annotation.Nullable)

Example 2 with AndroidSdkIdeInfo

use of com.google.idea.blaze.base.ideinfo.AndroidSdkIdeInfo in project intellij by bazelbuild.

the class IdeInfoFromProtobuf method makeTargetIdeInfo.

@Nullable
public static TargetIdeInfo makeTargetIdeInfo(IntellijIdeInfo.TargetIdeInfo message) {
    Kind kind = getKind(message);
    if (kind == null) {
        return null;
    }
    TargetKey key = getKey(message);
    ArtifactLocation buildFile = getBuildFile(message);
    final Collection<Dependency> dependencies;
    if (message.getDepsCount() > 0) {
        dependencies = message.getDepsList().stream().map(IdeInfoFromProtobuf::makeDependency).collect(toList());
    } else {
        dependencies = Lists.newArrayListWithCapacity(message.getDependenciesCount() + message.getRuntimeDepsCount());
        dependencies.addAll(makeDependencyListFromLabelList(message.getDependenciesList(), DependencyType.COMPILE_TIME));
        dependencies.addAll(makeDependencyListFromLabelList(message.getRuntimeDepsList(), DependencyType.RUNTIME));
    }
    Collection<String> tags = ImmutableList.copyOf(message.getTagsList());
    Collection<ArtifactLocation> sources = Lists.newArrayList();
    CIdeInfo cIdeInfo = null;
    if (message.hasCIdeInfo()) {
        cIdeInfo = makeCIdeInfo(message.getCIdeInfo());
        sources.addAll(cIdeInfo.sources);
        sources.addAll(cIdeInfo.headers);
        sources.addAll(cIdeInfo.textualHeaders);
    }
    CToolchainIdeInfo cToolchainIdeInfo = null;
    if (message.hasCToolchainIdeInfo()) {
        cToolchainIdeInfo = makeCToolchainIdeInfo(message.getCToolchainIdeInfo());
    }
    JavaIdeInfo javaIdeInfo = null;
    if (message.hasJavaIdeInfo()) {
        javaIdeInfo = makeJavaIdeInfo(message.getJavaIdeInfo());
        Collection<ArtifactLocation> javaSources = makeArtifactLocationList(message.getJavaIdeInfo().getSourcesList());
        sources.addAll(javaSources);
    }
    AndroidIdeInfo androidIdeInfo = null;
    if (message.hasAndroidIdeInfo()) {
        androidIdeInfo = makeAndroidIdeInfo(message.getAndroidIdeInfo());
    }
    AndroidSdkIdeInfo androidSdkIdeInfo = null;
    if (message.hasAndroidSdkIdeInfo()) {
        androidSdkIdeInfo = makeAndroidSdkIdeInfo(message.getAndroidSdkIdeInfo());
    }
    AndroidAarIdeInfo androidAarIdeInfo = null;
    if (message.hasAndroidAarIdeInfo()) {
        androidAarIdeInfo = makeAndroidAarIdeInfo(message.getAndroidAarIdeInfo());
    }
    PyIdeInfo pyIdeInfo = null;
    if (message.hasPyIdeInfo()) {
        pyIdeInfo = makePyIdeInfo(message.getPyIdeInfo());
        sources.addAll(pyIdeInfo.sources);
    }
    GoIdeInfo goIdeInfo = null;
    if (message.hasGoIdeInfo()) {
        goIdeInfo = makeGoIdeInfo(message.getGoIdeInfo());
        sources.addAll(goIdeInfo.sources);
    }
    JsIdeInfo jsIdeInfo = null;
    if (message.hasJsIdeInfo()) {
        jsIdeInfo = makeJsIdeInfo(message.getJsIdeInfo());
        sources.addAll(jsIdeInfo.sources);
    }
    TsIdeInfo tsIdeInfo = null;
    if (message.hasTsIdeInfo()) {
        tsIdeInfo = makeTsIdeInfo(message.getTsIdeInfo());
        sources.addAll(tsIdeInfo.sources);
    }
    DartIdeInfo dartIdeInfo = null;
    if (message.hasDartIdeInfo()) {
        dartIdeInfo = makeDartIdeInfo(message.getDartIdeInfo());
        sources.addAll(dartIdeInfo.sources);
    }
    TestIdeInfo testIdeInfo = null;
    if (message.hasTestInfo()) {
        testIdeInfo = makeTestIdeInfo(message.getTestInfo());
    }
    ProtoLibraryLegacyInfo protoLibraryLegacyInfo = null;
    if (message.hasProtoLibraryLegacyJavaIdeInfo()) {
        protoLibraryLegacyInfo = makeProtoLibraryLegacyInfo(message.getProtoLibraryLegacyJavaIdeInfo());
    }
    JavaToolchainIdeInfo javaToolchainIdeInfo = null;
    if (message.hasJavaToolchainIdeInfo()) {
        javaToolchainIdeInfo = makeJavaToolchainIdeInfo(message.getJavaToolchainIdeInfo());
    }
    return new TargetIdeInfo(key, kind, buildFile, dependencies, tags, sources, cIdeInfo, cToolchainIdeInfo, javaIdeInfo, androidIdeInfo, androidSdkIdeInfo, androidAarIdeInfo, pyIdeInfo, goIdeInfo, jsIdeInfo, tsIdeInfo, dartIdeInfo, testIdeInfo, protoLibraryLegacyInfo, javaToolchainIdeInfo);
}
Also used : TsIdeInfo(com.google.idea.blaze.base.ideinfo.TsIdeInfo) PyIdeInfo(com.google.idea.blaze.base.ideinfo.PyIdeInfo) JsIdeInfo(com.google.idea.blaze.base.ideinfo.JsIdeInfo) GoIdeInfo(com.google.idea.blaze.base.ideinfo.GoIdeInfo) Dependency(com.google.idea.blaze.base.ideinfo.Dependency) DartIdeInfo(com.google.idea.blaze.base.ideinfo.DartIdeInfo) TestIdeInfo(com.google.idea.blaze.base.ideinfo.TestIdeInfo) ProtoLibraryLegacyInfo(com.google.idea.blaze.base.ideinfo.ProtoLibraryLegacyInfo) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) JavaToolchainIdeInfo(com.google.idea.blaze.base.ideinfo.JavaToolchainIdeInfo) CToolchainIdeInfo(com.google.idea.blaze.base.ideinfo.CToolchainIdeInfo) AndroidAarIdeInfo(com.google.idea.blaze.base.ideinfo.AndroidAarIdeInfo) Kind(com.google.idea.blaze.base.model.primitives.Kind) ArtifactLocation(com.google.idea.blaze.base.ideinfo.ArtifactLocation) CIdeInfo(com.google.idea.blaze.base.ideinfo.CIdeInfo) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) JavaIdeInfo(com.google.idea.blaze.base.ideinfo.JavaIdeInfo) AndroidIdeInfo(com.google.idea.blaze.base.ideinfo.AndroidIdeInfo) AndroidSdkIdeInfo(com.google.idea.blaze.base.ideinfo.AndroidSdkIdeInfo) Nullable(javax.annotation.Nullable)

Aggregations

AndroidSdkIdeInfo (com.google.idea.blaze.base.ideinfo.AndroidSdkIdeInfo)2 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)2 Nullable (javax.annotation.Nullable)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 AndroidAarIdeInfo (com.google.idea.blaze.base.ideinfo.AndroidAarIdeInfo)1 AndroidIdeInfo (com.google.idea.blaze.base.ideinfo.AndroidIdeInfo)1 CIdeInfo (com.google.idea.blaze.base.ideinfo.CIdeInfo)1 CToolchainIdeInfo (com.google.idea.blaze.base.ideinfo.CToolchainIdeInfo)1 DartIdeInfo (com.google.idea.blaze.base.ideinfo.DartIdeInfo)1 Dependency (com.google.idea.blaze.base.ideinfo.Dependency)1 GoIdeInfo (com.google.idea.blaze.base.ideinfo.GoIdeInfo)1 JavaIdeInfo (com.google.idea.blaze.base.ideinfo.JavaIdeInfo)1 JavaToolchainIdeInfo (com.google.idea.blaze.base.ideinfo.JavaToolchainIdeInfo)1 JsIdeInfo (com.google.idea.blaze.base.ideinfo.JsIdeInfo)1 LibraryArtifact (com.google.idea.blaze.base.ideinfo.LibraryArtifact)1 ProtoLibraryLegacyInfo (com.google.idea.blaze.base.ideinfo.ProtoLibraryLegacyInfo)1 PyIdeInfo (com.google.idea.blaze.base.ideinfo.PyIdeInfo)1 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)1 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)1