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);
}
}
}
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);
}
}
}
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);
}
}
}
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");
}
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);
}
Aggregations