use of org.eclipse.xtext.serializer.acceptor.StringBufferSequenceAcceptor in project xtext-core by eclipse.
the class SerializerTestHelper method serialize.
protected String serialize(EObject semanticObject, DelegatingSequenceAcceptor... acceptors) {
ISequenceAcceptor debug = null;
try {
ISerializationDiagnostic.Acceptor errors = ISerializationDiagnostic.EXCEPTION_THROWING_ACCEPTOR;
ISemanticSequencer semantic = semanticSequencerProvider.get();
ISyntacticSequencer syntactic = syntacticSequencerProvider.get();
IHiddenTokenSequencer hidden = hiddenTokenSequencerProvider.get();
ISequenceAcceptor result = new StringBufferSequenceAcceptor();
ISequenceAcceptor out = result;
for (DelegatingSequenceAcceptor delegate : acceptors) {
delegate.setDelegate(out);
out = delegate;
}
out = debug = new DebugSequenceAcceptor(out);
semantic.init((ISemanticSequenceAcceptor) syntactic, errors);
ISerializationContext context = getContext(semanticObject);
syntactic.init(context, semanticObject, (ISyntacticSequenceAcceptor) hidden, errors);
hidden.init(context, semanticObject, out, errors);
semantic.createSequence(context, semanticObject);
return result.toString();
} catch (Exception t) {
if (debug != null) {
System.out.println("Serializer debug output:");
System.out.println(debug.toString());
}
Exceptions.sneakyThrow(t);
return "";
}
}
Aggregations