Search in sources :

Example 1 with RecordingDocumentBuilder

use of org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder in project mylyn.docs by eclipse.

the class MediaWikiLanguageTest method testTableIncomplete2.

@Test
public void testTableIncomplete2() {
    final RecordingDocumentBuilder builder = new RecordingDocumentBuilder();
    parser.setBuilder(builder);
    final String content = "{|\n" + "| foo |\n" + "|}";
    parser.parse(content);
    for (RecordingDocumentBuilder.Event event : builder.getEvents()) {
        if (event.text != null) {
            int start = event.locator.getDocumentOffset();
            int end = event.locator.getLineSegmentEndOffset() + event.locator.getLineDocumentOffset();
            assertEquals(event.text.length(), end - start);
            assertTrue(end >= start);
            assertEquals(content.substring(start, end), event.text);
        }
    }
}
Also used : RecordingDocumentBuilder(org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest) Test(org.junit.Test)

Example 2 with RecordingDocumentBuilder

use of org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder in project mylyn.docs by eclipse.

the class MediaWikiLanguageTest method testTableWithSyntax.

@Test
public void testTableWithSyntax() {
    final RecordingDocumentBuilder builder = new RecordingDocumentBuilder();
    parser.setBuilder(builder);
    String content = "{|\n" + "| <nowiki>'''''bold italic'''''</nowiki> || '''''bold italic''''' ||\n" + "|}";
    parser.parse(content);
    for (RecordingDocumentBuilder.Event event : builder.getEvents()) {
        if (event.text != null) {
            int start = event.locator.getDocumentOffset();
            int end = event.locator.getLineSegmentEndOffset() + event.locator.getLineDocumentOffset();
            assertTrue(end >= start);
        }
    }
}
Also used : RecordingDocumentBuilder(org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest) Test(org.junit.Test)

Example 3 with RecordingDocumentBuilder

use of org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder in project mylyn.docs by eclipse.

the class MediaWikiLanguageTest method testTableLexicalOffsets.

@Test
public void testTableLexicalOffsets() {
    final RecordingDocumentBuilder builder = new RecordingDocumentBuilder();
    parser.setBuilder(builder);
    final String content = "{|\n" + "|  Orange    ||   Apple   ||   more\n" + "|-\n" + "|   Bread    ||   Pie     ||   more\n" + "|-\n" + "|   Butter   || Ice cream ||  and more\n" + "|}\n";
    parser.parse(content);
    for (RecordingDocumentBuilder.Event event : builder.getEvents()) {
        if (event.text != null) {
            int start = event.locator.getDocumentOffset();
            int end = event.locator.getLineSegmentEndOffset() + event.locator.getLineDocumentOffset();
            assertEquals(event.text.length(), end - start);
            assertTrue(end >= start);
            assertEquals(content.substring(start, end), event.text);
        }
    }
}
Also used : RecordingDocumentBuilder(org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest) Test(org.junit.Test)

Example 4 with RecordingDocumentBuilder

use of org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder in project mylyn.docs by eclipse.

the class TextileLanguageTest method testFootnoteReferenceLexicalPosition.

@Test
public void testFootnoteReferenceLexicalPosition() {
    RecordingDocumentBuilder builder = new RecordingDocumentBuilder();
    parser.setBuilder(builder);
    parser.parse("a footnote reference[1] more text");
    List<Event> events = builder.getEvents();
    for (Event event : events) {
        if (event.spanType == SpanType.SUPERSCRIPT) {
            assertEquals(20, event.locator.getLineCharacterOffset());
            assertEquals(23, event.locator.getLineSegmentEndOffset());
            return;
        }
    }
    fail("expected to find superscript span");
}
Also used : Event(org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder.Event) RecordingDocumentBuilder(org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder) Test(org.junit.Test) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)

Example 5 with RecordingDocumentBuilder

use of org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder in project mylyn.docs by eclipse.

the class TextileLanguageTest method testNestedPhraseModifiersLexicalPosition.

@Test
public void testNestedPhraseModifiersLexicalPosition() {
    RecordingDocumentBuilder builder = new RecordingDocumentBuilder();
    parser.setBuilder(builder);
    parser.parse("a _sample *bold -sdf-*_");
    List<Event> events = builder.getEvents();
    int found = 0;
    for (Event event : events) {
        if (event.spanType == SpanType.EMPHASIS) {
            ++found;
            assertEquals(2, event.locator.getLineCharacterOffset());
            assertEquals(23, event.locator.getLineSegmentEndOffset());
        } else if (event.spanType == SpanType.STRONG) {
            ++found;
            assertEquals(10, event.locator.getLineCharacterOffset());
            assertEquals(22, event.locator.getLineSegmentEndOffset());
        } else if (event.spanType == SpanType.DELETED) {
            ++found;
            assertEquals(16, event.locator.getLineCharacterOffset());
            assertEquals(21, event.locator.getLineSegmentEndOffset());
        }
    }
    assertEquals(3, found);
}
Also used : Event(org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder.Event) RecordingDocumentBuilder(org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder) Test(org.junit.Test) AbstractMarkupGenerationTest(org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)

Aggregations

RecordingDocumentBuilder (org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder)11 Test (org.junit.Test)9 AbstractMarkupGenerationTest (org.eclipse.mylyn.wikitext.toolkit.AbstractMarkupGenerationTest)8 Event (org.eclipse.mylyn.wikitext.toolkit.RecordingDocumentBuilder.Event)4 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)1