Search in sources :

Example 6 with ISemanticSequencer

use of org.eclipse.xtext.serializer.sequencer.ISemanticSequencer 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)

Example 7 with ISemanticSequencer

use of org.eclipse.xtext.serializer.sequencer.ISemanticSequencer in project xtext-core by eclipse.

the class FormatterTest method serializeToTokenBuffer.

protected void serializeToTokenBuffer(String model, ITokenStream out) throws Exception {
    EObject semanticObject = get(ParseHelper.class).parse(model);
    ISerializationDiagnostic.Acceptor errors = ISerializationDiagnostic.EXCEPTION_THROWING_ACCEPTOR;
    ISemanticSequencer semantic = get(ISemanticSequencer.class);
    ISyntacticSequencer syntactic = get(ISyntacticSequencer.class);
    IHiddenTokenSequencer hidden = get(IHiddenTokenSequencer.class);
    TokenStreamSequenceAdapter tokenstream = new TokenStreamSequenceAdapter(out, getGrammarAccess().getGrammar(), errors);
    semantic.init((ISemanticSequenceAcceptor) syntactic, errors);
    ISerializationContext context = new SerializationContext.RuleContext(null, (ParserRule) get(IGrammarAccess.class).getGrammar().getRules().get(0));
    syntactic.init(context, semanticObject, (ISyntacticSequenceAcceptor) hidden, errors);
    hidden.init(context, semanticObject, tokenstream, errors);
    tokenstream.init(context);
    semantic.createSequence(context, semanticObject);
}
Also used : ParseHelper(org.eclipse.xtext.testing.util.ParseHelper) ISerializationDiagnostic(org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic) ISyntacticSequencer(org.eclipse.xtext.serializer.sequencer.ISyntacticSequencer) IHiddenTokenSequencer(org.eclipse.xtext.serializer.sequencer.IHiddenTokenSequencer) IGrammarAccess(org.eclipse.xtext.IGrammarAccess) ISerializationContext(org.eclipse.xtext.serializer.ISerializationContext) EObject(org.eclipse.emf.ecore.EObject) ISemanticSequencer(org.eclipse.xtext.serializer.sequencer.ISemanticSequencer) TokenStreamSequenceAdapter(org.eclipse.xtext.serializer.acceptor.TokenStreamSequenceAdapter)

Example 8 with ISemanticSequencer

use of org.eclipse.xtext.serializer.sequencer.ISemanticSequencer in project xtext-core by eclipse.

the class SyntacticSequencerTest method testSequence.

private void testSequence(String stringModel) throws Exception {
    EObject model = getModel(stringModel);
    ISerializationContext context = nmSequencer.findContexts(model, true, null).iterator().next();
    Acceptor actual = new Acceptor();
    ISemanticSequencer semanticSeq = semanticSequencerProvider.get();
    ISyntacticSequencer syntacticSeq = syntacticSequencerProvider.get();
    semanticSeq.init((ISemanticSequenceAcceptor) syntacticSeq, ISerializationDiagnostic.STDERR_ACCEPTOR);
    syntacticSeq.init(context, model, actual, ISerializationDiagnostic.STDERR_ACCEPTOR);
    semanticSeq.createSequence(context, model);
    assertEquals(Joiner.on("\n").join(getNodeSequence(model)), Joiner.on("\n").join(actual.getResult()));
}
Also used : ISequenceAcceptor(org.eclipse.xtext.serializer.acceptor.ISequenceAcceptor) ISemanticSequenceAcceptor(org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor) ISyntacticSequencer(org.eclipse.xtext.serializer.sequencer.ISyntacticSequencer) EObject(org.eclipse.emf.ecore.EObject) ISemanticSequencer(org.eclipse.xtext.serializer.sequencer.ISemanticSequencer)

Aggregations

ISemanticSequencer (org.eclipse.xtext.serializer.sequencer.ISemanticSequencer)8 ISyntacticSequencer (org.eclipse.xtext.serializer.sequencer.ISyntacticSequencer)7 EObject (org.eclipse.emf.ecore.EObject)5 IHiddenTokenSequencer (org.eclipse.xtext.serializer.sequencer.IHiddenTokenSequencer)5 ISequenceAcceptor (org.eclipse.xtext.serializer.acceptor.ISequenceAcceptor)3 TokenStreamSequenceAdapter (org.eclipse.xtext.serializer.acceptor.TokenStreamSequenceAdapter)3 ISerializationContext (org.eclipse.xtext.serializer.ISerializationContext)2 ISemanticSequenceAcceptor (org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor)2 ISerializationDiagnostic (org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic)2 DebugSequenceAcceptor (org.eclipse.xtext.testing.serializer.DebugSequenceAcceptor)2 IGrammarAccess (org.eclipse.xtext.IGrammarAccess)1 DelegatingSequenceAcceptor (org.eclipse.xtext.serializer.acceptor.DelegatingSequenceAcceptor)1 StringBufferSequenceAcceptor (org.eclipse.xtext.serializer.acceptor.StringBufferSequenceAcceptor)1 SequencerTestLanguageSemanticSequencer (org.eclipse.xtext.serializer.serializer.SequencerTestLanguageSemanticSequencer)1 ParseHelper (org.eclipse.xtext.testing.util.ParseHelper)1