use of org.eclipse.mylyn.wikitext.parser.builder.NoOpDocumentBuilder in project mylyn.docs by eclipse.
the class HtmlParserTest method assertParseEventOrder.
private void assertParseEventOrder(String content, Object... expectedEventTypes) {
final List<Object> actualEventTypes = new ArrayList<>();
DocumentBuilder builder = new NoOpDocumentBuilder() {
@Override
public void beginBlock(BlockType type, Attributes attributes) {
actualEventTypes.add(type);
}
@Override
public void beginSpan(SpanType type, Attributes attributes) {
actualEventTypes.add(type);
}
@Override
public void characters(String text) {
actualEventTypes.add(text);
}
@Override
public void endBlock() {
actualEventTypes.add(END_BLOCK);
}
@Override
public void endSpan() {
actualEventTypes.add(END_SPAN);
}
};
parse(content, builder);
assertEquals(ImmutableList.copyOf(expectedEventTypes), actualEventTypes);
}
use of org.eclipse.mylyn.wikitext.parser.builder.NoOpDocumentBuilder in project mylyn.docs by eclipse.
the class SourceBlocks method calculateSourceBlocks.
public List<SourceBlock> calculateSourceBlocks(final ProcessingContext context, LineSequence lineSequence, Predicate<BlockContext> predicate) {
final List<SourceBlock> sourceBlocks = new ArrayList<>();
final NoOpDocumentBuilder builder = new NoOpDocumentBuilder();
process(lineSequence, new SourceBlockRunnable() {
@Override
public void run(LineSequence lineSequence, SourceBlock sourceBlock) {
sourceBlocks.add(sourceBlock);
sourceBlock.process(context, builder, lineSequence);
}
}, predicate);
return sourceBlocks;
}
use of org.eclipse.mylyn.wikitext.parser.builder.NoOpDocumentBuilder in project mylyn.docs by eclipse.
the class TextileLanguage method processContent.
@Override
public void processContent(MarkupParser parser, String markupContent, boolean asDocument) {
if (preprocessFootnotes) {
boolean previousBlocksOnly = isBlocksOnly();
boolean previousFilterGenerativeContents = isFilterGenerativeContents();
setBlocksOnly(true);
setFilterGenerativeContents(true);
DocumentBuilder builder = parser.getBuilder();
parser.setBuilder(new NoOpDocumentBuilder());
currentState = new TextileContentState();
TextileContentState preprocessingState = currentState;
super.processContent(parser, markupContent, asDocument);
setBlocksOnly(previousBlocksOnly);
setFilterGenerativeContents(previousFilterGenerativeContents);
currentState = new TextileContentState();
currentState.setFootnoteNumbers(preprocessingState.getFootnoteNumbers());
parser.setBuilder(builder);
super.processContent(parser, markupContent, asDocument);
currentState = null;
} else {
currentState = null;
super.processContent(parser, markupContent, asDocument);
}
}
use of org.eclipse.mylyn.wikitext.parser.builder.NoOpDocumentBuilder in project mylyn.docs by eclipse.
the class InlineParser method toStringContent.
static String toStringContent(List<Inline> contents) {
final StringBuilder stringBuilder = new StringBuilder();
DocumentBuilder altDocumentBuilder = new NoOpDocumentBuilder() {
@Override
public void characters(String text) {
stringBuilder.append(text);
}
@Override
public void entityReference(String entity) {
stringBuilder.append(Objects.firstNonNull(EntityReferences.instance().equivalentString(entity), ""));
}
};
for (Inline inline : contents) {
inline.emit(altDocumentBuilder);
}
return stringBuilder.toString();
}
use of org.eclipse.mylyn.wikitext.parser.builder.NoOpDocumentBuilder in project mylyn.docs by eclipse.
the class MultiplexingDocumentBuilderTest method flush.
@Test
public void flush() {
final AtomicBoolean flushed = new AtomicBoolean();
DocumentBuilder delegate = new NoOpDocumentBuilder() {
@Override
public void flush() {
flushed.set(true);
}
};
multiplexer = new MultiplexingDocumentBuilder(delegate);
multiplexer.flush();
assertTrue(flushed.get());
}
Aggregations