Search in sources :

Example 26 with ISerializationContext

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

the class SerializationContext method equals.

@Override
public boolean equals(Object obj) {
    if (obj == null || !(obj instanceof ISerializationContext))
        return false;
    if (obj == this)
        return true;
    ISerializationContext other = (ISerializationContext) obj;
    boolean eq1 = equalsInternal(other);
    // System.out.println("Foo");
    return eq1;
}
Also used : ISerializationContext(org.eclipse.xtext.serializer.ISerializationContext)

Example 27 with ISerializationContext

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

the class SequencerDiagnosticProvider method createBacktrackingFailedDiagnostic.

@Override
@Deprecated
public ISerializationDiagnostic createBacktrackingFailedDiagnostic(SerializableObject semanticObject, EObject context, Nfa<ISemState> nfa) {
    ISerializationContext ctx = SerializationContext.fromEObject(context, semanticObject.getEObject());
    SerializationContextMap<IConstraint> constraints = grammarConstraints.getConstraints(grammarAccess.getGrammar());
    return createBacktrackingFailedDiagnostic(semanticObject, ctx, constraints.get(ctx));
}
Also used : ISerializationContext(org.eclipse.xtext.serializer.ISerializationContext) IConstraint(org.eclipse.xtext.serializer.analysis.IGrammarConstraintProvider.IConstraint)

Example 28 with ISerializationContext

use of org.eclipse.xtext.serializer.ISerializationContext 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();
}
Also used : ISerializationDiagnostic(org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic) ITokenStream(org.eclipse.xtext.parsetree.reconstr.ITokenStream) ISerializationContext(org.eclipse.xtext.serializer.ISerializationContext) IFormatterExtension(org.eclipse.xtext.formatting.IFormatterExtension) ISequenceAcceptor(org.eclipse.xtext.serializer.acceptor.ISequenceAcceptor) TokenStreamSequenceAdapter(org.eclipse.xtext.serializer.acceptor.TokenStreamSequenceAdapter)

Example 29 with ISerializationContext

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

the class AbstractSyntacticSequencer method enterAssignedAction.

@Override
public boolean enterAssignedAction(Action action, EObject semanticChild, ICompositeNode node) {
    navigateToAbsorber(action, node);
    boolean shouldEnter = delegate.enterAssignedAction(action, semanticChild, node);
    if (shouldEnter) {
        ISerializationContext child = SerializationContext.forChild(contexts.peek().context, action, semanticChild);
        ISynAbsorberState pda = syntacticSequencerPDAs.get(child);
        if (pda == null)
            throw new IllegalStateException();
        SyntacticalContext j = new SyntacticalContext(child, semanticChild, pda, node);
        contexts.push(j);
    }
    return shouldEnter;
}
Also used : ISynAbsorberState(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState) ISerializationContext(org.eclipse.xtext.serializer.ISerializationContext)

Example 30 with ISerializationContext

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

the class AbstractSyntacticSequencer method enterAssignedParserRuleCall.

@Override
public boolean enterAssignedParserRuleCall(RuleCall rc, EObject semanticChild, ICompositeNode node) {
    navigateToAbsorber(rc, node);
    boolean shouldEnter = delegate.enterAssignedParserRuleCall(rc, semanticChild, node);
    if (shouldEnter) {
        ISerializationContext child = SerializationContext.forChild(contexts.peek().context, rc, semanticChild);
        ISynAbsorberState pda = syntacticSequencerPDAs.get(child);
        if (pda == null)
            throw new IllegalStateException();
        SyntacticalContext j = new SyntacticalContext(child, semanticChild, pda, node);
        contexts.push(j);
    }
    return shouldEnter;
}
Also used : ISynAbsorberState(org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState) ISerializationContext(org.eclipse.xtext.serializer.ISerializationContext)

Aggregations

ISerializationContext (org.eclipse.xtext.serializer.ISerializationContext)39 EClass (org.eclipse.emf.ecore.EClass)12 IConstraint (org.eclipse.xtext.serializer.analysis.IGrammarConstraintProvider.IConstraint)8 EObject (org.eclipse.emf.ecore.EObject)7 RuleCall (org.eclipse.xtext.RuleCall)7 Parameter (org.eclipse.xtext.Parameter)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 Pda (org.eclipse.xtext.util.formallang.Pda)5 Collection (java.util.Collection)4 ISerializationDiagnostic (org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic)4 Map (java.util.Map)3 Action (org.eclipse.xtext.Action)3 ISynAbsorberState (org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynAbsorberState)3 SerializationContextMap (org.eclipse.xtext.serializer.analysis.SerializationContextMap)3 LinkedHashMultimap (com.google.common.collect.LinkedHashMultimap)2 EReference (org.eclipse.emf.ecore.EReference)2 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)2