Search in sources :

Example 21 with ImportRoots

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

the class ImportRootsTest method testNonOverlappingDirectoriesAreNotFilteredOut.

@Test
public void testNonOverlappingDirectoriesAreNotFilteredOut() {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Blaze).add(new DirectoryEntry(new WorkspacePath("root0/subdir0"), true)).add(new DirectoryEntry(new WorkspacePath("root0/subdir1"), true)).add(new DirectoryEntry(new WorkspacePath("root1"), true)).build();
    assertThat(importRoots.rootDirectories()).containsExactly(new WorkspacePath("root0/subdir0"), new WorkspacePath("root0/subdir1"), new WorkspacePath("root1"));
}
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 22 with ImportRoots

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

the class ImportRootsTest method testExternalWorkspaceLabelsNotIncludedUnderWorkspaceRoot.

@Test
public void testExternalWorkspaceLabelsNotIncludedUnderWorkspaceRoot() {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Blaze).add(new DirectoryEntry(new WorkspacePath(""), true)).build();
    assertThat(importRoots.importAsSource(Label.create("@lib//:target"))).isFalse();
}
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 23 with ImportRoots

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

the class ImportRootsTest method testContainsWorkspacePath_subdirectory.

@Test
public void testContainsWorkspacePath_subdirectory() throws Exception {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Blaze).add(DirectoryEntry.include(new WorkspacePath("root"))).build();
    assertThat(importRoots.containsWorkspacePath(new WorkspacePath("root/subdir"))).isTrue();
}
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 24 with ImportRoots

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

the class ImportRootsTest method testContainsWorkspacePath_excludedParentsAreHandled.

@Test
public void testContainsWorkspacePath_excludedParentsAreHandled() throws Exception {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Blaze).add(DirectoryEntry.include(new WorkspacePath("root"))).add(DirectoryEntry.exclude(new WorkspacePath("root/a"))).build();
    assertThat(importRoots.containsWorkspacePath(new WorkspacePath("root/a/b"))).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 25 with ImportRoots

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

the class NewBlazePackageAction method filterDirectories.

/**
 * Filter out directories that do not live under the project's directories.
 */
private static List<PsiDirectory> filterDirectories(Project project, PsiDirectory[] directories) {
    if (directories.length == 0) {
        return ImmutableList.of();
    }
    ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet();
    if (projectViewSet == null) {
        return ImmutableList.of();
    }
    WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, Blaze.getBuildSystem(project)).add(projectViewSet).build();
    return Lists.newArrayList(directories).stream().filter(directory -> isUnderProjectViewDirectory(workspaceRoot, importRoots, directory)).collect(Collectors.toList());
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalHistoryAction(com.intellij.history.LocalHistoryAction) Presentation(com.intellij.openapi.actionSystem.Presentation) StatusOutput(com.google.idea.blaze.base.scope.output.StatusOutput) ProjectViewManager(com.google.idea.blaze.base.projectview.ProjectViewManager) PsiManager(com.intellij.psi.PsiManager) BlazeProjectAction(com.google.idea.blaze.base.actions.BlazeProjectAction) BuildFileModifier(com.google.idea.blaze.base.buildmodifier.BuildFileModifier) Kind(com.google.idea.blaze.base.model.primitives.Kind) IdeView(com.intellij.ide.IdeView) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) Scope(com.google.idea.blaze.base.scope.Scope) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) WriteCommandAction(com.intellij.openapi.command.WriteCommandAction) Logger(com.intellij.openapi.diagnostic.Logger) DumbAware(com.intellij.openapi.project.DumbAware) Nullable(javax.annotation.Nullable) Blaze(com.google.idea.blaze.base.settings.Blaze) PlatformIcons(com.intellij.util.PlatformIcons) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) WorkspacePathUtil(com.google.idea.blaze.base.util.WorkspacePathUtil) IOException(java.io.IOException) PrintOutput(com.google.idea.blaze.base.scope.output.PrintOutput) Collectors(java.util.stream.Collectors) File(java.io.File) DirectoryChooserUtil(com.intellij.ide.util.DirectoryChooserUtil) List(java.util.List) Label(com.google.idea.blaze.base.model.primitives.Label) Result(com.intellij.openapi.application.Result) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) Optional(java.util.Optional) VfsUtil(com.intellij.openapi.vfs.VfsUtil) PsiDirectory(com.intellij.psi.PsiDirectory) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) LocalHistory(com.intellij.history.LocalHistory) LangDataKeys(com.intellij.openapi.actionSystem.LangDataKeys) NotNull(org.jetbrains.annotations.NotNull) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot)

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