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));
}
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));
}
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);
}
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);
}
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();
}
Aggregations