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"));
}
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();
}
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();
}
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();
}
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());
}
Aggregations