use of org.eclipse.xtext.serializer.acceptor.TokenStreamSequenceAdapter in project xtext-core by eclipse.
the class Serializer method serialize.
protected void serialize(ISerializationContext context, EObject semanticObject, ISequenceAcceptor tokens, ISerializationDiagnostic.Acceptor errors) {
ISemanticSequencer semantic = semanticSequencerProvider.get();
ISyntacticSequencer syntactic = syntacticSequencerProvider.get();
IHiddenTokenSequencer hidden = hiddenTokenSequencerProvider.get();
semantic.init((ISemanticSequenceAcceptor) syntactic, errors);
syntactic.init(context, semanticObject, (ISyntacticSequenceAcceptor) hidden, errors);
hidden.init(context, semanticObject, tokens, errors);
if (tokens instanceof TokenStreamSequenceAdapter)
((TokenStreamSequenceAdapter) tokens).init(context);
semantic.createSequence(context, semanticObject);
}
use of org.eclipse.xtext.serializer.acceptor.TokenStreamSequenceAdapter in project xtext-core by eclipse.
the class Serializer method serialize.
/**
* @deprecated use {@link #serialize(ISerializationContext, EObject, ISequenceAcceptor, ISerializationDiagnostic.Acceptor)}
*/
@Deprecated
protected void serialize(EObject semanticObject, EObject context, ISequenceAcceptor tokens, ISerializationDiagnostic.Acceptor errors) {
ISemanticSequencer semantic = semanticSequencerProvider.get();
ISyntacticSequencer syntactic = syntacticSequencerProvider.get();
IHiddenTokenSequencer hidden = hiddenTokenSequencerProvider.get();
semantic.init((ISemanticSequenceAcceptor) syntactic, errors);
syntactic.init(context, semanticObject, (ISyntacticSequenceAcceptor) hidden, errors);
hidden.init(context, semanticObject, tokens, errors);
if (tokens instanceof TokenStreamSequenceAdapter)
((TokenStreamSequenceAdapter) tokens).init(context);
semantic.createSequence(context, semanticObject);
}
use of org.eclipse.xtext.serializer.acceptor.TokenStreamSequenceAdapter in project xtext-core by eclipse.
the class Serializer method serialize.
protected void serialize(EObject obj, ITokenStream tokenStream, SaveOptions options) throws IOException {
ISerializationDiagnostic.Acceptor errors = ISerializationDiagnostic.EXCEPTION_THROWING_ACCEPTOR;
ITokenStream formatterTokenStream;
if (formatter instanceof IFormatterExtension)
formatterTokenStream = ((IFormatterExtension) formatter).createFormatterStream(obj, null, tokenStream, !options.isFormatting());
else
formatterTokenStream = formatter.createFormatterStream(null, tokenStream, !options.isFormatting());
ISerializationContext context = getIContext(obj);
ISequenceAcceptor acceptor = new TokenStreamSequenceAdapter(formatterTokenStream, grammar.getGrammar(), errors);
serialize(context, obj, acceptor, errors);
formatterTokenStream.flush();
}
use of org.eclipse.xtext.serializer.acceptor.TokenStreamSequenceAdapter 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);
}
Aggregations