use of com.google.idea.blaze.base.projectview.section.Section in project intellij by bazelbuild.
the class ProjectViewParser method parseProjectView.
private void parseProjectView(ParseContext parseContext) {
ImmutableList.Builder<Section<?>> sections = ImmutableList.builder();
List<SectionParser> sectionParsers = Sections.getParsers();
while (!parseContext.atEnd()) {
Section section = null;
for (SectionParser sectionParser : sectionParsers) {
section = sectionParser.parse(this, parseContext);
if (section != null) {
sections.add(section);
break;
}
}
if (section == null) {
if (parseContext.current().indent != 0) {
parseContext.addError(String.format("Invalid indentation on line: '%s'", parseContext.current().text));
skipSection(parseContext);
} else {
parseContext.addError(String.format("Could not parse: '%s'", parseContext.current().text));
parseContext.consume();
// Skip past the entire section
skipSection(parseContext);
}
}
}
ProjectView projectView = new ProjectView(sections.build());
projectViewFiles.add(new ProjectViewSet.ProjectViewFile(projectView, parseContext.getProjectViewFile()));
}
use of com.google.idea.blaze.base.projectview.section.Section in project intellij by bazelbuild.
the class ProjectViewSetTest method testProjectViewSetSerializable.
@Test
public void testProjectViewSetSerializable() throws Exception {
ProjectViewSet projectViewSet = ProjectViewSet.builder().add(ProjectView.builder().add(ListSection.builder(DirectorySection.KEY).add(DirectoryEntry.include(new WorkspacePath("test")))).add(ListSection.builder(TargetSection.KEY).add(TargetExpression.fromStringSafe("//test:all"))).add(ScalarSection.builder(ImportSection.KEY).set(new WorkspacePath("test"))).add(ListSection.builder(TestSourceSection.KEY).add(new Glob("javatests/*"))).add(ListSection.builder(ExcludedSourceSection.KEY).add(new Glob("*.java"))).add(ListSection.builder(BuildFlagsSection.KEY).add("--android_sdk=abcd")).add(ListSection.builder(SyncFlagsSection.KEY).add("--config=arm")).add(ListSection.builder(ImportTargetOutputSection.KEY).add(Label.create("//test:test"))).add(ListSection.builder(ExcludeTargetSection.KEY).add(Label.create("//test:test"))).add(ScalarSection.builder(WorkspaceTypeSection.KEY).set(WorkspaceType.JAVA)).add(ListSection.builder(AdditionalLanguagesSection.KEY).add(LanguageClass.JAVA)).add(TextBlockSection.of(TextBlock.newLine())).add(ListSection.builder(RunConfigurationsSection.KEY).add(new WorkspacePath("test"))).add(ScalarSection.builder(ShardBlazeBuildsSection.KEY).set(false)).add(ScalarSection.builder(TargetShardSizeSection.KEY).set(500)).build()).build();
// Assert we have all sections
assert projectViewSet.getTopLevelProjectViewFile() != null;
ProjectView projectView = projectViewSet.getTopLevelProjectViewFile().projectView;
for (SectionParser parser : Sections.getParsers()) {
ImmutableList<Section<?>> sections = projectView.getSections();
assertThat(sections.stream().anyMatch(section -> section.isSectionType(parser.getSectionKey()))).isTrue();
}
TestUtils.assertIsSerializable(projectViewSet);
}
Aggregations