Search in sources :

Example 1 with DebugSequenceAcceptor

use of org.eclipse.xtext.testing.serializer.DebugSequenceAcceptor in project xtext-core by eclipse.

the class AbstractSemanticSequencerTest method testSequence.

private EObject testSequence(String stringModel) throws Exception {
    DebugSequenceAcceptor genericActual = new DebugSequenceAcceptor();
    DebugSequenceAcceptor generatedActual = new DebugSequenceAcceptor();
    DebugSequenceAcceptor expected = new DebugSequenceAcceptor();
    ISemanticSequencer generatedSequencer = generatedSequencerProvider.get();
    ISemanticSequencer genericSequencer = getGenericSemanticSequencer();
    assertTrue(generatedSequencer instanceof SequencerTestLanguageSemanticSequencer);
    generatedSequencer.init(generatedActual, ISerializationDiagnostic.STDERR_ACCEPTOR);
    genericSequencer.init(genericActual, ISerializationDiagnostic.STDERR_ACCEPTOR);
    nmSequencer.init(expected, ISerializationDiagnostic.STDERR_ACCEPTOR);
    EObject model = getModel(stringModel).eContents().get(0);
    ISerializationContext context = nmSequencer.findContexts(model, true, null).iterator().next();
    generatedSequencer.createSequence(context, model);
    genericSequencer.createSequence(context, model);
    nmSequencer.createSequence(context, model);
    assertEquals(expected.toString(), genericActual.toString());
    assertEquals(expected.toString(), generatedActual.toString());
    return model;
}
Also used : SequencerTestLanguageSemanticSequencer(org.eclipse.xtext.serializer.serializer.SequencerTestLanguageSemanticSequencer) EObject(org.eclipse.emf.ecore.EObject) DebugSequenceAcceptor(org.eclipse.xtext.testing.serializer.DebugSequenceAcceptor) ISemanticSequencer(org.eclipse.xtext.serializer.sequencer.ISemanticSequencer)

Example 2 with DebugSequenceAcceptor

use of org.eclipse.xtext.testing.serializer.DebugSequenceAcceptor in project xtext-core by eclipse.

the class HiddenTokenSequencerTest method testSequence.

private void testSequence(String stringModel) throws Exception {
    EObject model = getModel(stringModel);
    ISerializationContext context = nmSequencer.findContexts(model, true, null).iterator().next();
    DebugSequenceAcceptor actual = new NoEnterNodesDebugSequenceAcceptor(false);
    ISemanticSequencer semanticSequencer = semanticSequencerProvider.get();
    ISyntacticSequencer syntacticSequencer = syntacticSequencerProvider.get();
    IHiddenTokenSequencer hiddenTokenSequencer = hiddenTokenSequencerProvider.get();
    semanticSequencer.init((ISemanticSequenceAcceptor) syntacticSequencer, ISerializationDiagnostic.STDERR_ACCEPTOR);
    syntacticSequencer.init(context, model, (ISyntacticSequenceAcceptor) hiddenTokenSequencer, ISerializationDiagnostic.STDERR_ACCEPTOR);
    hiddenTokenSequencer.init(context, model, actual, ISerializationDiagnostic.STDERR_ACCEPTOR);
    semanticSequencer.createSequence(context, model);
    // System.out.println(actual);
    // System.out.println(NodeModelUtils.compactDump(NodeModelUtils.findActualNodeFor(model), true));
    assertEquals(Joiner.on("\n").join(getNodeSequence(model)), Joiner.on("\n").join(actual.getColumn(4)));
}
Also used : ISyntacticSequencer(org.eclipse.xtext.serializer.sequencer.ISyntacticSequencer) IHiddenTokenSequencer(org.eclipse.xtext.serializer.sequencer.IHiddenTokenSequencer) EObject(org.eclipse.emf.ecore.EObject) DebugSequenceAcceptor(org.eclipse.xtext.testing.serializer.DebugSequenceAcceptor) ISemanticSequencer(org.eclipse.xtext.serializer.sequencer.ISemanticSequencer)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)2 ISemanticSequencer (org.eclipse.xtext.serializer.sequencer.ISemanticSequencer)2 DebugSequenceAcceptor (org.eclipse.xtext.testing.serializer.DebugSequenceAcceptor)2 IHiddenTokenSequencer (org.eclipse.xtext.serializer.sequencer.IHiddenTokenSequencer)1 ISyntacticSequencer (org.eclipse.xtext.serializer.sequencer.ISyntacticSequencer)1 SequencerTestLanguageSemanticSequencer (org.eclipse.xtext.serializer.serializer.SequencerTestLanguageSemanticSequencer)1