use of com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry in project intellij by bazelbuild.
the class ProjectViewParserTest method testImport.
@Test
public void testImport() {
projectViewStorageManager.add("/parent.blazeproject", "directories:", " parent", "");
projectViewStorageManager.add(".blazeproject", "import parent.blazeproject", "directories:", " child", "");
projectViewParser.parseProjectView(new File(".blazeproject"));
errorCollector.assertNoIssues();
ProjectViewSet projectViewSet = projectViewParser.getResult();
assertThat(projectViewSet.getProjectViewFiles()).hasSize(2);
Collection<DirectoryEntry> entries = projectViewSet.listItems(DirectorySection.KEY);
assertThat(entries).containsExactly(new DirectoryEntry(new WorkspacePath("parent"), true), new DirectoryEntry(new WorkspacePath("child"), true));
}
use of com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry in project intellij by bazelbuild.
the class ProjectViewParserTest method testMultipleImports.
@Test
public void testMultipleImports() {
projectViewStorageManager.add("/grandparent.blazeproject", "directories:", " grandparent");
projectViewStorageManager.add("/mother.blazeproject", "import grandparent.blazeproject", "directories:", " mother");
projectViewStorageManager.add("/father.blazeproject", "import grandparent.blazeproject", "directories:", " father");
projectViewStorageManager.add("/child.blazeproject", "import mother.blazeproject", "directories:", " child1", "import father.blazeproject", "directories:", " child2");
projectViewParser.parseProjectView(new File("/child.blazeproject"));
errorCollector.assertNoIssues();
ProjectViewSet projectViewSet = projectViewParser.getResult();
// Ensures we don't parse grandfather twice
assertThat(projectViewSet.getProjectViewFiles()).hasSize(4);
Collection<DirectoryEntry> entries = projectViewSet.listItems(DirectorySection.KEY);
// All imports' contributions appear before the children, no matter where they appear
assertThat(entries).containsExactly(new DirectoryEntry(new WorkspacePath("grandparent"), true), new DirectoryEntry(new WorkspacePath("mother"), true), new DirectoryEntry(new WorkspacePath("father"), true), new DirectoryEntry(new WorkspacePath("child1"), true), new DirectoryEntry(new WorkspacePath("child2"), true)).inOrder();
}
use of com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry 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.projectview.section.sections.DirectoryEntry 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.projectview.section.sections.DirectoryEntry in project intellij by bazelbuild.
the class AddLibraryTargetDirectoryToProjectViewAction method addDirectoriesToProjectView.
static void addDirectoriesToProjectView(Project project, List<Library> libraries) {
Set<WorkspacePath> workspacePaths = Sets.newHashSet();
for (Library library : libraries) {
WorkspacePath workspacePath = getDirectoryToAddForLibrary(project, library);
if (workspacePath != null) {
workspacePaths.add(workspacePath);
}
}
ProjectViewEdit edit = ProjectViewEdit.editLocalProjectView(project, builder -> {
ListSection<DirectoryEntry> existingSection = builder.getLast(DirectorySection.KEY);
ListSection.Builder<DirectoryEntry> directoryBuilder = ListSection.update(DirectorySection.KEY, existingSection);
for (WorkspacePath workspacePath : workspacePaths) {
directoryBuilder.add(new DirectoryEntry(workspacePath, true));
}
builder.replace(existingSection, directoryBuilder);
return true;
});
if (edit == null) {
Messages.showErrorDialog("Could not modify project view. Check for errors in your project view and try again", "Error");
return;
}
edit.apply();
BlazeSyncManager.getInstance(project).requestProjectSync(new BlazeSyncParams.Builder("Adding Library", BlazeSyncParams.SyncMode.INCREMENTAL).addProjectViewTargets(true).addWorkingSet(BlazeUserSettings.getInstance().getExpandSyncToWorkingSet()).build());
}
Aggregations