Search in sources :

Example 6 with ImportRoots

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

the class ImportRootsTest method testBazelArtifactDirectoriesExcluded.

@Test
public void testBazelArtifactDirectoriesExcluded() {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Bazel).add(new DirectoryEntry(new WorkspacePath(""), true)).build();
    ImmutableList<String> artifactDirs = BuildSystemProvider.getBuildSystemProvider(BuildSystem.Bazel).buildArtifactDirectories(workspaceRoot);
    assertThat(importRoots.rootDirectories()).containsExactly(new WorkspacePath(""));
    assertThat(importRoots.excludeDirectories().stream().map(WorkspacePath::relativePath).collect(Collectors.toList())).containsExactlyElementsIn(artifactDirs);
    assertThat(artifactDirs).contains("bazel-" + workspaceRoot.directory().getName());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) Test(org.junit.Test)

Example 7 with ImportRoots

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

the class ImportRootsTest method testContainsWorkspacePath_differentRoot.

@Test
public void testContainsWorkspacePath_differentRoot() throws Exception {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Blaze).add(DirectoryEntry.include(new WorkspacePath("root"))).build();
    assertThat(importRoots.containsWorkspacePath(new WorkspacePath("otherroot"))).isFalse();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) Test(org.junit.Test)

Example 8 with ImportRoots

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

the class ImportRootsTest method testContainsWorkspacePath_similarRoot.

@Test
public void testContainsWorkspacePath_similarRoot() throws Exception {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Blaze).add(DirectoryEntry.include(new WorkspacePath("root"))).build();
    assertThat(importRoots.containsWorkspacePath(new WorkspacePath("root2/subdir"))).isFalse();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) Test(org.junit.Test)

Example 9 with ImportRoots

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

the class ImportRootsTest method testNoAddedExclusionsForBlaze.

@Test
public void testNoAddedExclusionsForBlaze() {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Blaze).add(new DirectoryEntry(new WorkspacePath(""), true)).build();
    assertThat(importRoots.rootDirectories()).containsExactly(new WorkspacePath(""));
    assertThat(importRoots.excludeDirectories()).isEmpty();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) Test(org.junit.Test)

Example 10 with ImportRoots

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

the class AlwaysPresentPythonSyncPlugin method validate.

@Override
public boolean validate(Project project, BlazeContext context, BlazeProjectData blazeProjectData) {
    ImportRoots importRoots = ImportRoots.forProjectSafe(project);
    if (importRoots == null) {
        return true;
    }
    boolean hasPythonTarget = blazeProjectData.targetMap.targets().stream().filter(target -> importRoots.importAsSource(target.key.label)).anyMatch(target -> target.kindIsOneOf(Kind.allKindsForLanguage(LanguageClass.PYTHON)));
    if (!hasPythonTarget) {
        return true;
    }
    String pluginId = PythonPluginUtils.getPythonPluginId();
    if (!PluginUtils.isPluginEnabled(pluginId)) {
        IssueOutput.warn("Your project appears to contain Python targets. To enable Python support, " + "install/enable the JetBrains python plugin, then restart the IDE").navigatable(PluginUtils.installOrEnablePluginNavigable(pluginId)).submit(context);
        return false;
    }
    return true;
}
Also used : BlazeSyncPlugin(com.google.idea.blaze.base.sync.BlazeSyncPlugin) PythonPluginUtils(com.google.idea.blaze.python.PythonPluginUtils) LanguageClass(com.google.idea.blaze.base.model.primitives.LanguageClass) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) ImmutableSet(com.google.common.collect.ImmutableSet) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) PluginUtils(com.google.idea.blaze.base.plugin.PluginUtils) Collection(java.util.Collection) Set(java.util.Set) Kind(com.google.idea.blaze.base.model.primitives.Kind) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) WorkspaceType(com.google.idea.blaze.base.model.primitives.WorkspaceType) ImmutableList(com.google.common.collect.ImmutableList) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) Project(com.intellij.openapi.project.Project) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots)

Aggregations

ImportRoots (com.google.idea.blaze.base.sync.projectview.ImportRoots)29 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)25 Test (org.junit.Test)16 DirectoryEntry (com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry)11 File (java.io.File)11 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)7 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)7 ImmutableList (com.google.common.collect.ImmutableList)6 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)6 Project (com.intellij.openapi.project.Project)6 ImmutableSet (com.google.common.collect.ImmutableSet)5 Lists (com.google.common.collect.Lists)5 Kind (com.google.idea.blaze.base.model.primitives.Kind)5 List (java.util.List)5 Nullable (javax.annotation.Nullable)5 ArtifactLocation (com.google.idea.blaze.base.ideinfo.ArtifactLocation)4 LanguageClass (com.google.idea.blaze.base.model.primitives.LanguageClass)4 IssueOutput (com.google.idea.blaze.base.scope.output.IssueOutput)4 ArtifactLocationDecoder (com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder)4 Set (java.util.Set)4