Search in sources :

Example 6 with WorkspaceLanguageSettings

use of com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings in project intellij by bazelbuild.

the class BlazeAndroidJavaSyncAugmenter method addJarsForSourceTarget.

@Override
public void addJarsForSourceTarget(WorkspaceLanguageSettings workspaceLanguageSettings, ProjectViewSet projectViewSet, TargetIdeInfo target, Collection<BlazeJarLibrary> jars, Collection<BlazeJarLibrary> genJars) {
    if (!workspaceLanguageSettings.isLanguageActive(LanguageClass.ANDROID)) {
        return;
    }
    AndroidIdeInfo androidIdeInfo = target.androidIdeInfo;
    if (androidIdeInfo == null) {
        return;
    }
    LibraryArtifact idlJar = androidIdeInfo.idlJar;
    if (idlJar != null) {
        genJars.add(new BlazeJarLibrary(idlJar));
    }
    Set<String> whitelistedGenResourcePaths = projectViewSet.listItems(GeneratedAndroidResourcesSection.KEY).stream().map(genfilesPath -> genfilesPath.relativePath).collect(Collectors.toSet());
    if (BlazeAndroidWorkspaceImporter.shouldGenerateResources(androidIdeInfo) && !BlazeAndroidWorkspaceImporter.shouldGenerateResourceModule(androidIdeInfo, whitelistedGenResourcePaths)) {
        // Add blaze's output unless it's a top level rule.
        // In these cases the resource jar contains the entire
        // transitive closure of R classes. It's unlikely this is wanted to resolve in the IDE.
        boolean discardResourceJar = target.kindIsOneOf(Kind.ANDROID_BINARY, Kind.ANDROID_TEST);
        if (!discardResourceJar) {
            LibraryArtifact resourceJar = androidIdeInfo.resourceJar;
            if (resourceJar != null) {
                jars.add(new BlazeJarLibrary(resourceJar));
            }
        }
    }
}
Also used : LanguageClass(com.google.idea.blaze.base.model.primitives.LanguageClass) GeneratedAndroidResourcesSection(com.google.idea.blaze.android.projectview.GeneratedAndroidResourcesSection) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact) Collection(java.util.Collection) Set(java.util.Set) BlazeAndroidWorkspaceImporter(com.google.idea.blaze.android.sync.importer.BlazeAndroidWorkspaceImporter) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Collectors(java.util.stream.Collectors) BlazeJavaSyncAugmenter(com.google.idea.blaze.java.sync.BlazeJavaSyncAugmenter) AndroidIdeInfo(com.google.idea.blaze.base.ideinfo.AndroidIdeInfo) Kind(com.google.idea.blaze.base.model.primitives.Kind) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) AndroidIdeInfo(com.google.idea.blaze.base.ideinfo.AndroidIdeInfo) LibraryArtifact(com.google.idea.blaze.base.ideinfo.LibraryArtifact)

Example 7 with WorkspaceLanguageSettings

use of com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings in project intellij by bazelbuild.

the class BlazeGoRootsProviderTest method testPackageToTargetMap.

@Test
public void testPackageToTargetMap() {
    TargetMap targetMap = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setBuildFile(src("foo/bar/BUILD")).setLabel("//foo/bar:binary").setKind("go_binary").addSource(src("foo/bar/binary.go")).addDependency("//one/two:library").setGoInfo(GoIdeInfo.builder().addSources(ImmutableList.of(src("foo/bar/binary.go"))).setImportPath("prefix/foo/bar/binary"))).addTarget(TargetIdeInfo.builder().setBuildFile(src("one/two/BUILD")).setLabel("//one/two:library").setKind("go_library").addSource(src("one/two/library.go")).addSource(src("one/two/three/library.go")).setGoInfo(GoIdeInfo.builder().addSources(ImmutableList.of(src("one/two/library.go"), src("one/two/three/library.go"))).setImportPath("prefix/one/two/library"))).build();
    registerProjectService(BlazeProjectDataManager.class, new MockBlazeProjectDataManager(new BlazeProjectData(0L, targetMap, null, null, null, null, new WorkspaceLanguageSettings(WorkspaceType.GO, ImmutableSet.of(LanguageClass.GO)), null, null)));
    assertThat(BlazeGoRootsProvider.getPackageToTargetMap(getProject())).containsExactly("prefix/foo/bar/binary", TargetKey.forPlainTarget(Label.create("//foo/bar:binary")), "prefix/one/two/library", TargetKey.forPlainTarget(Label.create("//one/two:library")));
}
Also used : BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) MockBlazeProjectDataManager(com.google.idea.blaze.base.model.MockBlazeProjectDataManager) Test(org.junit.Test)

Example 8 with WorkspaceLanguageSettings

use of com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings in project intellij by bazelbuild.

the class BlazeGoSyncPluginTest method testGoAdditionalLanguageSupported.

@Test
public void testGoAdditionalLanguageSupported() {
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.JAVA)).add(ListSection.builder(AdditionalLanguagesSection.KEY).add(LanguageClass.GO)).build()).build();
    WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
    LanguageSupport.validateLanguageSettings(context, workspaceLanguageSettings);
    errorCollector.assertNoIssues();
    assertThat(workspaceLanguageSettings.isLanguageActive(LanguageClass.GO)).isTrue();
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Test(org.junit.Test)

Example 9 with WorkspaceLanguageSettings

use of com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings in project intellij by bazelbuild.

the class BlazeJavascriptSyncPluginTest method testJavascriptLanguageAvailableForUltimateEdition.

@Test
public void testJavascriptLanguageAvailableForUltimateEdition() {
    TestUtils.setPlatformPrefix(testDisposable, PlatformUtils.IDEA_PREFIX);
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.JAVASCRIPT)).add(ListSection.builder(AdditionalLanguagesSection.KEY).add(LanguageClass.JAVASCRIPT)).build()).build();
    WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
    errorCollector.assertNoIssues();
    assertThat(workspaceLanguageSettings).isEqualTo(new WorkspaceLanguageSettings(WorkspaceType.JAVASCRIPT, ImmutableSet.of(LanguageClass.JAVASCRIPT, LanguageClass.GENERIC)));
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Test(org.junit.Test)

Example 10 with WorkspaceLanguageSettings

use of com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings in project intellij by bazelbuild.

the class BlazeTypescriptSyncPluginTest method testTypescriptNotLanguageAvailableInCommunityEdition.

@Test
public void testTypescriptNotLanguageAvailableInCommunityEdition() {
    TestUtils.setPlatformPrefix(testDisposable, PlatformUtils.IDEA_CE_PREFIX);
    ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.JAVA)).add(ListSection.builder(AdditionalLanguagesSection.KEY).add(LanguageClass.TYPESCRIPT)).build()).build();
    WorkspaceLanguageSettings workspaceLanguageSettings = LanguageSupport.createWorkspaceLanguageSettings(projectViewSet);
    LanguageSupport.validateLanguageSettings(context, workspaceLanguageSettings);
    errorCollector.assertIssues("Language 'typescript' is not supported by this plugin");
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Test(org.junit.Test)

Aggregations

WorkspaceLanguageSettings (com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings)33 Test (org.junit.Test)28 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)20 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)17 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)13 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)13 ImmutableList (com.google.common.collect.ImmutableList)7 ImmutableSet (com.google.common.collect.ImmutableSet)7 WorkspaceType (com.google.idea.blaze.base.model.primitives.WorkspaceType)7 MockBlazeProjectDataManager (com.google.idea.blaze.base.model.MockBlazeProjectDataManager)6 LanguageClass (com.google.idea.blaze.base.model.primitives.LanguageClass)6 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)6 WorkspacePathResolverImpl (com.google.idea.blaze.base.sync.workspace.WorkspacePathResolverImpl)6 TargetIdeInfo (com.google.idea.blaze.base.ideinfo.TargetIdeInfo)5 TargetKey (com.google.idea.blaze.base.ideinfo.TargetKey)5 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)5 GoFile (com.goide.psi.GoFile)4 LibraryArtifact (com.google.idea.blaze.base.ideinfo.LibraryArtifact)4 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)4 PrefetchService (com.google.idea.blaze.base.prefetch.PrefetchService)4