Search in sources :

Example 1 with LocatorImpl

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);
}
Also used : LocatorImpl(org.eclipse.mylyn.wikitext.util.LocatorImpl)

Example 2 with LocatorImpl

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);
}
Also used : LocatorImpl(org.eclipse.mylyn.wikitext.util.LocatorImpl)

Example 3 with LocatorImpl

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);
}
Also used : Locator(org.eclipse.mylyn.wikitext.parser.Locator) StringWriter(java.io.StringWriter) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) AtomicReference(java.util.concurrent.atomic.AtomicReference) LocatorImpl(org.eclipse.mylyn.wikitext.util.LocatorImpl) HtmlDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Aggregations

LocatorImpl (org.eclipse.mylyn.wikitext.util.LocatorImpl)3 StringWriter (java.io.StringWriter)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)1 Locator (org.eclipse.mylyn.wikitext.parser.Locator)1 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)1 HtmlDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.HtmlDocumentBuilder)1