Search in sources :

Example 6 with DirectoryEntry

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

the class ImportRootsTest method testBazelArtifactDirectoriesExcluded.

@Test
public void testBazelArtifactDirectoriesExcluded() {
    ImportRoots importRoots = ImportRoots.builder(workspaceRoot, BuildSystem.Bazel).add(new DirectoryEntry(new WorkspacePath(""), true)).build();
    ImmutableList<String> artifactDirs = BuildSystemProvider.getBuildSystemProvider(BuildSystem.Bazel).buildArtifactDirectories(workspaceRoot);
    assertThat(importRoots.rootDirectories()).containsExactly(new WorkspacePath(""));
    assertThat(importRoots.excludeDirectories().stream().map(WorkspacePath::relativePath).collect(Collectors.toList())).containsExactlyElementsIn(artifactDirs);
    assertThat(artifactDirs).contains("bazel-" + workspaceRoot.directory().getName());
}
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 7 with DirectoryEntry

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

the class ImportRootsTest method testNoAddedExclusionsForBlaze.

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

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

the class ProjectViewParserTest method testDirectoriesAndTargets.

@Test
public void testDirectoriesAndTargets() throws Exception {
    projectViewStorageManager.add(".blazeproject", "directories:", "  java/com/google", "  java/com/google/android", "  -java/com/google/android/notme", "", "targets:", "  //java/com/google:all", "  //java/com/google/...:all", "  -//java/com/google:thistarget");
    projectViewParser.parseProjectView(new File(".blazeproject"));
    errorCollector.assertNoIssues();
    ProjectViewSet projectViewSet = projectViewParser.getResult();
    ProjectViewSet.ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
    assertThat(projectViewFile).isNotNull();
    assertThat(projectViewFile.projectViewFile).isEqualTo(new File(".blazeproject"));
    assertThat(projectViewSet.getProjectViewFiles()).containsExactly(projectViewFile);
    ProjectView projectView = projectViewFile.projectView;
    assertThat(projectView.getSectionsOfType(DirectorySection.KEY).get(0).items()).containsExactly(new DirectoryEntry(new WorkspacePath("java/com/google"), true), new DirectoryEntry(new WorkspacePath("java/com/google/android"), true), new DirectoryEntry(new WorkspacePath("java/com/google/android/notme"), false));
    assertThat(projectView.getSectionsOfType(TargetSection.KEY).get(0).items()).containsExactly(TargetExpression.fromStringSafe("//java/com/google:all"), TargetExpression.fromStringSafe("//java/com/google/...:all"), TargetExpression.fromStringSafe("-//java/com/google:thistarget"));
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

Example 9 with DirectoryEntry

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

the class ProjectViewParserTest method testCanParseWithMissingCarriageReturnAtEndOfSection.

@Test
public void testCanParseWithMissingCarriageReturnAtEndOfSection() {
    projectViewStorageManager.add(".blazeproject", "directories:", "  java/com/google");
    projectViewParser.parseProjectView(new File(".blazeproject"));
    ProjectView projectView = projectViewParser.getResult().getTopLevelProjectViewFile().projectView;
    assertThat(projectView.getSectionsOfType(DirectorySection.KEY).get(0).items()).containsExactly(new DirectoryEntry(new WorkspacePath("java/com/google"), true));
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) File(java.io.File) Test(org.junit.Test)

Example 10 with DirectoryEntry

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

the class ProjectViewParserTest method testCommentsAreParsed.

@Test
public void testCommentsAreParsed() throws Exception {
    projectViewStorageManager.add(".blazeproject", "# comment", "directories:", "  # another comment", "  java/com/google", "  # comment", "  java/com/google/android", "");
    projectViewParser.parseProjectView(new File(".blazeproject"));
    errorCollector.assertNoIssues();
    ProjectViewSet projectViewSet = projectViewParser.getResult();
    ProjectViewSet.ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
    ProjectView projectView = projectViewFile.projectView;
    assertThat(projectView.getSectionsOfType(TextBlockSection.KEY).get(0).getTextBlock()).isEqualTo(new TextBlock(ImmutableList.of("# comment")));
    assertThat(projectView.getSectionsOfType(DirectorySection.KEY).get(0).items()).containsExactly(new DirectoryEntry(new WorkspacePath("java/com/google"), true), new DirectoryEntry(new WorkspacePath("java/com/google/android"), true));
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) DirectoryEntry(com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry) File(java.io.File) TextBlock(com.google.idea.blaze.base.projectview.section.sections.TextBlock) 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