use of org.eclipse.xtext.serializer.sequencer.ISyntacticSequencer 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);
}
use of org.eclipse.xtext.serializer.sequencer.ISyntacticSequencer 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()));
}
Aggregations