Search in sources :

Example 41 with ISerializationContext

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

Aggregations

ISerializationContext (org.eclipse.xtext.serializer.ISerializationContext)41 EClass (org.eclipse.emf.ecore.EClass)13 IConstraint (org.eclipse.xtext.serializer.analysis.IGrammarConstraintProvider.IConstraint)9 EObject (org.eclipse.emf.ecore.EObject)7 Parameter (org.eclipse.xtext.Parameter)6 RuleCall (org.eclipse.xtext.RuleCall)6 List (java.util.List)5 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)5 AbstractElement (org.eclipse.xtext.AbstractElement)5 ParserRule (org.eclipse.xtext.ParserRule)5 ISerializationDiagnostic (org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic)5 Collection (java.util.Collection)4 SerializationContextMap (org.eclipse.xtext.serializer.analysis.SerializationContextMap)4 Pda (org.eclipse.xtext.util.formallang.Pda)4 Map (java.util.Map)3 Action (org.eclipse.xtext.Action)3 ISynAbsorberState (org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState)3 LinkedHashMultimap (com.google.common.collect.LinkedHashMultimap)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2