Search in sources :

Example 16 with DirectoryEntry

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));
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

Example 17 with DirectoryEntry

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();
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

Example 18 with DirectoryEntry

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"));
}
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 19 with DirectoryEntry

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();
}
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 20 with DirectoryEntry

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());
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ListSection(com.google.idea.blaze.base.projectview.section.ListSection) ProjectViewEdit(com.google.idea.blaze.base.projectview.ProjectViewEdit) BlazeJarLibrary(com.google.idea.blaze.java.sync.model.BlazeJarLibrary) Library(com.intellij.openapi.roots.libraries.Library) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry)

Aggregations

DirectoryEntry (com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry)20 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)19 Test (org.junit.Test)16 File (java.io.File)10 ImportRoots (com.google.idea.blaze.base.sync.projectview.ImportRoots)9 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)7 ProjectView (com.google.idea.blaze.base.projectview.ProjectView)4 ProjectViewFile (com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile)3 FileOperationProvider (com.google.idea.blaze.base.io.FileOperationProvider)2 ListSection (com.google.idea.blaze.base.projectview.section.ListSection)2 IssueOutput (com.google.idea.blaze.base.scope.output.IssueOutput)2 Lists (com.google.common.collect.Lists)1 ProjectViewEdit (com.google.idea.blaze.base.projectview.ProjectViewEdit)1 SectionParser (com.google.idea.blaze.base.projectview.section.SectionParser)1 DirectorySection (com.google.idea.blaze.base.projectview.section.sections.DirectorySection)1 Sections (com.google.idea.blaze.base.projectview.section.sections.Sections)1 TextBlock (com.google.idea.blaze.base.projectview.section.sections.TextBlock)1 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)1 BlazeSyncPlugin (com.google.idea.blaze.base.sync.BlazeSyncPlugin)1 LanguageSupport (com.google.idea.blaze.base.sync.projectview.LanguageSupport)1