use of org.eclipse.mylyn.wikitext.util.LocatorImpl in project mylyn.docs by eclipse.
the class RecordingDocumentBuilder method add.
private void add(Event event) {
event.locator = new LocatorImpl(getLocator());
events.add(event);
}
use of org.eclipse.mylyn.wikitext.util.LocatorImpl in project mylyn.docs by eclipse.
the class RecordingDocumentBuilder method add.
private void add(Event event) {
event.locator = new LocatorImpl(getLocator());
events.add(event);
}
use of org.eclipse.mylyn.wikitext.util.LocatorImpl in project mylyn.docs by eclipse.
the class CommonMarkLanguageDocumentOffsetsTest method assertSpanOffsets.
private void assertSpanOffsets(int offset, int length, String expectedHtml, String markup) {
final AtomicReference<Locator> spanLocator = new AtomicReference<Locator>();
CommonMarkLanguage language = new CommonMarkLanguage();
MarkupParser parser = new MarkupParser(language);
StringWriter out = new StringWriter();
HtmlDocumentBuilder builder = new HtmlDocumentBuilder(out) {
@Override
public void beginSpan(SpanType type, Attributes attributes) {
assertNull(spanLocator.get());
spanLocator.set(new LocatorImpl(getLocator()));
super.beginSpan(type, attributes);
}
};
builder.setEmitAsDocument(false);
parser.setBuilder(builder);
parser.parse(markup);
assertEquals(expectedHtml, out.toString());
Locator locator = spanLocator.get();
assertNotNull(locator);
assertEquals(offset, locator.getDocumentOffset());
int actualLength = locator.getLineSegmentEndOffset() - locator.getLineCharacterOffset();
assertEquals(length, actualLength);
}
Aggregations