use of com.google.idea.blaze.base.projectview.section.sections.TextBlock 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.section.sections.TextBlock in project intellij by bazelbuild.
the class ListSectionParser method parse.
@Nullable
@Override
public final ListSection<T> parse(ProjectViewParser parser, ParseContext parseContext) {
if (parseContext.atEnd()) {
return null;
}
String name = getName();
if (!parseContext.current().text.equals(name + ':')) {
return null;
}
parseContext.consume();
ImmutableList.Builder<ItemOrTextBlock<T>> builder = ImmutableList.builder();
boolean correctIndentationRun = true;
List<ItemOrTextBlock<T>> savedTextBlocks = Lists.newArrayList();
while (!parseContext.atEnd()) {
boolean isIndented = parseContext.current().indent == SectionParser.INDENT;
if (!isIndented && correctIndentationRun) {
parseContext.savePosition();
}
correctIndentationRun = isIndented;
ItemOrTextBlock<T> itemOrTextBlock = null;
TextBlock textBlock = TextBlockSection.parseTextBlock(parseContext);
if (textBlock != null) {
itemOrTextBlock = new ItemOrTextBlock<>(textBlock);
} else if (isIndented) {
T item = parseItem(parser, parseContext);
if (item != null) {
parseContext.consume();
itemOrTextBlock = new ItemOrTextBlock<>(item);
}
}
if (itemOrTextBlock == null) {
break;
}
if (isIndented) {
builder.addAll(savedTextBlocks);
builder.add(itemOrTextBlock);
savedTextBlocks.clear();
parseContext.clearSavedPosition();
} else {
savedTextBlocks.add(new ItemOrTextBlock<>(textBlock));
}
}
parseContext.resetToSavedPosition();
ImmutableList<ItemOrTextBlock<T>> items = builder.build();
if (items.isEmpty()) {
parseContext.addError(String.format("Empty section: '%s'", name));
}
return new ListSection<>(key, items);
}
Aggregations