Search in sources :

Example 6 with ProjectView

use of com.google.idea.blaze.base.projectview.ProjectView 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 7 with ProjectView

use of com.google.idea.blaze.base.projectview.ProjectView 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)

Example 8 with ProjectView

use of com.google.idea.blaze.base.projectview.ProjectView in project intellij by bazelbuild.

the class ProjectViewParserTest method testListParserAcceptsWhitespace.

@Test
public void testListParserAcceptsWhitespace() throws Exception {
    String text = Joiner.on('\n').join("directories:", "  dir0", "  ", "", "  dir1", "  ", "  ", "# comment", "  dir2", "", "  # commented out dir", "  ", "# comment", "# comment");
    projectViewStorageManager.add(".blazeproject", text);
    projectViewParser.parseProjectView(new File(".blazeproject"));
    errorCollector.assertNoIssues();
    ProjectViewSet projectViewSet = projectViewParser.getResult();
    ProjectViewSet.ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
    assert projectViewFile != null;
    ProjectView projectView = projectViewFile.projectView;
    assertThat(projectView).isEqualTo(ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("dir0"))).add(TextBlock.of("  ")).add(TextBlock.of("")).add(DirectoryEntry.include(new WorkspacePath("dir1"))).add(TextBlock.of("  ", "  ")).add(TextBlock.of("# comment")).add(DirectoryEntry.include(new WorkspacePath("dir2"))).add(TextBlock.of("")).add(TextBlock.of("  # commented out dir")).add(TextBlock.of("  "))).add(TextBlockSection.of(TextBlock.of("# comment", "# comment"))).build());
    String outputString = ProjectViewParser.projectViewToString(projectView);
    assertThat(outputString).isEqualTo(text);
}
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) File(java.io.File) Test(org.junit.Test)

Example 9 with ProjectView

use of com.google.idea.blaze.base.projectview.ProjectView in project intellij by bazelbuild.

the class ProjectViewParserTest method testCommentsAndWhitespacePreserved.

@Test
public void testCommentsAndWhitespacePreserved() throws Exception {
    String text = Joiner.on('\n').join("", "# comment", "  ", "  ", "directories:", "  # another comment", "  java/com/google", "  # comment", "#unindented comment", "  java/com/google/android", "", "  # needlessly indented comment", "", "directories:", "  java/com/google", "  # trailing comment", "directories:", "  java/com/google");
    projectViewStorageManager.add(".blazeproject", text);
    projectViewParser.parseProjectView(new File(".blazeproject"));
    errorCollector.assertNoIssues();
    ProjectViewSet projectViewSet = projectViewParser.getResult();
    ProjectViewSet.ProjectViewFile projectViewFile = projectViewSet.getTopLevelProjectViewFile();
    ProjectView projectView = projectViewFile.projectView;
    String outputString = ProjectViewParser.projectViewToString(projectView);
    assertThat(outputString).isEqualTo(text);
}
Also used : ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) File(java.io.File) Test(org.junit.Test)

Example 10 with ProjectView

use of com.google.idea.blaze.base.projectview.ProjectView in project intellij by bazelbuild.

the class BlazeJavaWorkspaceImporterTest method testTargetWithOnlySourceJarAsSourceAddedAsLibrary.

@Test
public void testTargetWithOnlySourceJarAsSourceAddedAsLibrary() {
    ProjectView projectView = ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("import")))).build();
    TargetMapBuilder response = TargetMapBuilder.builder().addTarget(TargetIdeInfo.builder().setLabel("//import:lib").setBuildFile(source("import/BUILD")).setKind("android_library").addSource(source("import/Lib.java")).setJavaInfo(JavaIdeInfo.builder()).addDependency("//import:import").addDependency("//import:import_android")).addTarget(TargetIdeInfo.builder().setLabel("//import:import").setBuildFile(source("import/BUILD")).setKind("java_library").addSource(gen("import/gen-src.jar")).setJavaInfo(JavaIdeInfo.builder().addJar(LibraryArtifact.builder().setInterfaceJar(gen("import/import.jar")).setClassJar(gen("import/import.jar")))));
    BlazeJavaImportResult result = importWorkspace(workspaceRoot, response, projectView);
    errorCollector.assertNoIssues();
    assertThat(findLibrary(result.libraries, "import.jar")).isNotNull();
}
Also used : WorkspacePath(com.google.idea.blaze.base.model.primitives.WorkspacePath) TargetMapBuilder(com.google.idea.blaze.base.ideinfo.TargetMapBuilder) BlazeJavaImportResult(com.google.idea.blaze.java.sync.model.BlazeJavaImportResult) ProjectView(com.google.idea.blaze.base.projectview.ProjectView) Test(org.junit.Test)

Aggregations

ProjectView (com.google.idea.blaze.base.projectview.ProjectView)87 Test (org.junit.Test)81 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)55 TargetMapBuilder (com.google.idea.blaze.base.ideinfo.TargetMapBuilder)45 BlazeJavaImportResult (com.google.idea.blaze.java.sync.model.BlazeJavaImportResult)40 TargetMap (com.google.idea.blaze.base.ideinfo.TargetMap)33 BlazeAndroidImportResult (com.google.idea.blaze.android.sync.model.BlazeAndroidImportResult)13 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)12 File (java.io.File)12 BlazeScalaImportResult (com.google.idea.blaze.scala.sync.model.BlazeScalaImportResult)9 DirectoryEntry (com.google.idea.blaze.base.projectview.section.sections.DirectoryEntry)8 AndroidAarIdeInfo (com.google.idea.blaze.base.ideinfo.AndroidAarIdeInfo)7 BlazeJarLibrary (com.google.idea.blaze.java.sync.model.BlazeJarLibrary)6 WorkingSet (com.google.idea.blaze.base.sync.workspace.WorkingSet)5 JavaWorkingSet (com.google.idea.blaze.java.sync.workingset.JavaWorkingSet)5 ImmutableList (com.google.common.collect.ImmutableList)4 GenfilesPath (com.google.idea.blaze.android.projectview.GenfilesPath)4 BlazeAndroidLibrarySource (com.google.idea.blaze.android.sync.BlazeAndroidLibrarySource)4 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)4 DirectorySection (com.google.idea.blaze.base.projectview.section.sections.DirectorySection)4