Search in sources :

Example 1 with DirectoryEntry

use of com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry in project intellij by bazelbuild.

the class ProjectViewVerifier method verifyIncludedPackagesAreNotExcluded.

private static boolean verifyIncludedPackagesAreNotExcluded(BlazeContext context, ProjectViewSet projectViewSet) {
    boolean ok = true;
    List<WorkspacePath> includedDirectories = projectViewSet.listItems(DirectorySection.KEY).stream().filter(entry -> entry.included).map(entry -> entry.directory).collect(toList());
    for (WorkspacePath includedDirectory : includedDirectories) {
        for (ProjectViewSet.ProjectViewFile projectViewFile : projectViewSet.getProjectViewFiles()) {
            List<DirectoryEntry> directoryEntries = Lists.newArrayList();
            for (ListSection<DirectoryEntry> section : projectViewFile.projectView.getSectionsOfType(DirectorySection.KEY)) {
                directoryEntries.addAll(section.items());
            }
            for (DirectoryEntry entry : directoryEntries) {
                if (entry.included) {
                    continue;
                }
                WorkspacePath excludedDirectory = entry.directory;
                if (FileUtil.isAncestor(excludedDirectory.relativePath(), includedDirectory.relativePath(), false)) {
                    IssueOutput.error(String.format("%s is included, but that contradicts %s which was excluded", includedDirectory.toString(), excludedDirectory.toString())).inFile(projectViewFile.projectViewFile).submit(context);
                    ok = false;
                }
            }
        }
    }
    return ok;
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ProjectViewFile(com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile) SectionParser(com.google.idea.blaze.base.projectview.section.SectionParser) BlazeSyncPlugin(com.google.idea.blaze.base.sync.BlazeSyncPlugin) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) LanguageSupport(com.google.idea.blaze.base.sync.projectview.LanguageSupport) DirectorySection(com.google.idea.blaze.base.projectview.section.sections.DirectorySection) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Sections(com.google.idea.blaze.base.projectview.section.sections.Sections) FileOperationProvider(com.google.idea.blaze.base.io.FileOperationProvider) File(java.io.File) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Lists(com.google.common.collect.Lists) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) Project(com.intellij.openapi.project.Project) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) WorkspacePathResolver(com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver) FileUtil(com.intellij.openapi.util.io.FileUtil) ListSection(com.google.idea.blaze.base.projectview.section.ListSection) Nullable(javax.annotation.Nullable) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) ProjectViewFile(com.google.idea.blaze.base.projectview.ProjectViewSet.ProjectViewFile)

Example 2 with DirectoryEntry

use of com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry in project intellij by bazelbuild.

the class ImportRootsTest method testNoAddedExclusionsWithoutWorkspaceRootInclusion.

@Test
public void testNoAddedExclusionsWithoutWorkspaceRootInclusion() {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Bazel).add(new DirectoryEntry(new WorkspacePath("foo/bar"), true)).build();
    assertThat(importRoots.rootDirectories()).containsExactly(new WorkspacePath("foo/bar"));
    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 3 with DirectoryEntry

use of com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry in project intellij by bazelbuild.

the class ImportRootsTest method testOverlappingDirectoriesAreFilteredOut.

@Test
public void testOverlappingDirectoriesAreFilteredOut() {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Blaze).add(new DirectoryEntry(new WorkspacePath("root"), true)).add(new DirectoryEntry(new WorkspacePath("root"), true)).add(new DirectoryEntry(new WorkspacePath("root/subdir"), true)).build();
    assertThat(importRoots.rootDirectories()).containsExactly(new WorkspacePath("root"));
}
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 4 with DirectoryEntry

use of com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry in project intellij by bazelbuild.

the class ImportRootsTest method testWorkspaceRootIsOnlyDirectoryLeft.

@Test
public void testWorkspaceRootIsOnlyDirectoryLeft() {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Blaze).add(new DirectoryEntry(new WorkspacePath("."), true)).add(new DirectoryEntry(new WorkspacePath("."), true)).add(new DirectoryEntry(new WorkspacePath("root/subdir"), true)).build();
    assertThat(importRoots.rootDirectories()).containsExactly(new WorkspacePath("."));
}
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 5 with DirectoryEntry

use of com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry in project intellij by bazelbuild.

the class ImportRootsTest method testOverlappingExcludesAreFiltered.

@Test
public void testOverlappingExcludesAreFiltered() {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Blaze).add(new DirectoryEntry(new WorkspacePath("root"), false)).add(new DirectoryEntry(new WorkspacePath("root"), false)).add(new DirectoryEntry(new WorkspacePath("root/subdir"), false)).build();
    assertThat(importRoots.excludeDirectories()).containsExactly(new WorkspacePath("root"));
}
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)

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