Search in sources :

Example 1 with DocumentBuilderEvent

use of org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent in project mylyn.docs by eclipse.

the class DocumentBuilderEventsTest method createsWithProvidedEvents.

@Test
public void createsWithProvidedEvents() {
    BeginDocumentEvent event = new BeginDocumentEvent();
    List<DocumentBuilderEvent> allEvents = Lists.<DocumentBuilderEvent>newArrayList(event);
    DocumentBuilderEvents events = new DocumentBuilderEvents(allEvents);
    assertEquals(allEvents, events.getEvents());
}
Also used : DocumentBuilderEvent(org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent) DocumentBuilderEvents(org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvents) BeginDocumentEvent(org.eclipse.mylyn.wikitext.parser.builder.event.BeginDocumentEvent) Test(org.junit.Test)

Example 2 with DocumentBuilderEvent

use of org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent in project mylyn.docs by eclipse.

the class SubstitutionWithoutCssSpanStrategyTest method test.

@Test
public void test() {
    SubstitutionWithoutCssSpanStrategy strategy = new SubstitutionWithoutCssSpanStrategy(SpanType.BOLD);
    EventDocumentBuilder builder = new EventDocumentBuilder();
    strategy.beginSpan(builder, SpanType.ITALIC, new Attributes("1", "class", "style", "lang"));
    List<DocumentBuilderEvent> events = builder.getDocumentBuilderEvents().getEvents();
    assertEquals(ImmutableList.of(new BeginSpanEvent(SpanType.BOLD, new Attributes("1", "class", null, "lang"))), events);
}
Also used : DocumentBuilderEvent(org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent) EventDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) BeginSpanEvent(org.eclipse.mylyn.wikitext.parser.builder.event.BeginSpanEvent) SubstitutionWithoutCssSpanStrategy(org.eclipse.mylyn.wikitext.html.internal.SubstitutionWithoutCssSpanStrategy) Test(org.junit.Test)

Example 3 with DocumentBuilderEvent

use of org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent in project mylyn.docs by eclipse.

the class SourceBlocksTest method process.

@Test
public void process() {
    EventDocumentBuilder builder = new EventDocumentBuilder();
    sourceBlocks.process(ProcessingContext.builder().build(), builder, LineSequence.create("one\nb2\nmore\n\nb1 and\n\n\nb2"));
    ImmutableList<DocumentBuilderEvent> expectedEvents = // 
    ImmutableList.of(// 
    new BeginBlockEvent(BlockType.PARAGRAPH, new Attributes()), // 
    new CharactersEvent("b2"), // 
    new CharactersEvent("more"), // 
    new EndBlockEvent(), // 
    new BeginBlockEvent(BlockType.QUOTE, new Attributes()), // 
    new CharactersEvent("b1 and"), // 
    new EndBlockEvent(), // 
    new BeginBlockEvent(BlockType.PARAGRAPH, new Attributes()), // 
    new CharactersEvent("b2"), new EndBlockEvent());
    assertEquals(Joiner.on("\n").join(builder.getDocumentBuilderEvents().getEvents()), expectedEvents, builder.getDocumentBuilderEvents().getEvents());
}
Also used : DocumentBuilderEvent(org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent) CharactersEvent(org.eclipse.mylyn.wikitext.parser.builder.event.CharactersEvent) EventDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder) EndBlockEvent(org.eclipse.mylyn.wikitext.parser.builder.event.EndBlockEvent) BeginBlockEvent(org.eclipse.mylyn.wikitext.parser.builder.event.BeginBlockEvent) Attributes(org.eclipse.mylyn.wikitext.parser.Attributes) Test(org.junit.Test)

Example 4 with DocumentBuilderEvent

use of org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent in project mylyn.docs by eclipse.

the class CommonMarkLanguageTest method assertEvents.

private void assertEvents(String content, boolean asDocument, DocumentBuilderEvent... events) {
    MarkupParser parser = new MarkupParser(language);
    EventDocumentBuilder builder = new EventDocumentBuilder();
    parser.setBuilder(builder);
    parser.parse(content, asDocument);
    List<DocumentBuilderEvent> expectedEvents = Arrays.asList(events);
    List<DocumentBuilderEvent> actualEvents = builder.getDocumentBuilderEvents().getEvents();
    assertEquals(format("Expected {0} but got {1}", toMessage(expectedEvents), toMessage(actualEvents)), expectedEvents, actualEvents);
}
Also used : DocumentBuilderEvent(org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent) EventDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder) MarkupParser(org.eclipse.mylyn.wikitext.parser.MarkupParser)

Example 5 with DocumentBuilderEvent

use of org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent in project mylyn.docs by eclipse.

the class EventDocumentBuilderTest method assertEvents.

private void assertEvents(DocumentBuilderEvent... events) {
    List<DocumentBuilderEvent> expectedEvents = Arrays.asList(events);
    assertEquals(expectedEvents, builder.getDocumentBuilderEvents().getEvents());
    EventDocumentBuilder builder2 = new EventDocumentBuilder();
    for (DocumentBuilderEvent event : events) {
        event.invoke(builder2);
    }
    assertEquals(expectedEvents, builder2.getDocumentBuilderEvents().getEvents());
}
Also used : DocumentBuilderEvent(org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent) EventDocumentBuilder(org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder)

Aggregations

DocumentBuilderEvent (org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvent)5 EventDocumentBuilder (org.eclipse.mylyn.wikitext.parser.builder.EventDocumentBuilder)4 Test (org.junit.Test)3 Attributes (org.eclipse.mylyn.wikitext.parser.Attributes)2 SubstitutionWithoutCssSpanStrategy (org.eclipse.mylyn.wikitext.html.internal.SubstitutionWithoutCssSpanStrategy)1 MarkupParser (org.eclipse.mylyn.wikitext.parser.MarkupParser)1 BeginBlockEvent (org.eclipse.mylyn.wikitext.parser.builder.event.BeginBlockEvent)1 BeginDocumentEvent (org.eclipse.mylyn.wikitext.parser.builder.event.BeginDocumentEvent)1 BeginSpanEvent (org.eclipse.mylyn.wikitext.parser.builder.event.BeginSpanEvent)1 CharactersEvent (org.eclipse.mylyn.wikitext.parser.builder.event.CharactersEvent)1 DocumentBuilderEvents (org.eclipse.mylyn.wikitext.parser.builder.event.DocumentBuilderEvents)1 EndBlockEvent (org.eclipse.mylyn.wikitext.parser.builder.event.EndBlockEvent)1