org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor Java Examples
The following examples show how to use
org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PartialSerializer.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public void serialize(ITextRegionDiffBuilder result) { ISemanticSequencer semantic = semanticSequencerProvider.get(); ISyntacticSequencer syntactic = syntacticSequencerProvider.get(); IHiddenTokenSequencer hidden = hiddenTokenSequencerProvider.get(); semantic.init((ISemanticSequenceAcceptor) syntactic, errorAcceptor); syntactic.init(context, root, (ISyntacticSequenceAcceptor) hidden, errorAcceptor); ISequenceAcceptor acceptor; if (insertAt instanceof IHiddenRegion) { IHiddenRegion h = (IHiddenRegion) insertAt; acceptor = result.replaceSequence(h, h, context, root); } else { IHiddenRegion originalFirst = insertAt.getPreviousHiddenRegion(); IHiddenRegion originalLast = insertAt.getNextHiddenRegion(); acceptor = result.replaceSequence(originalFirst, originalLast, context, root); } hidden.init(context, root, acceptor, errorAcceptor); if (acceptor instanceof TokenStreamSequenceAdapter) ((TokenStreamSequenceAdapter) acceptor).init(context); semantic.createSequence(context, root); }
Example #2
Source File: HiddenTokenSequencerTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
private void testSequence(String stringModel) throws Exception { EObject model = getModel(stringModel); ISerializationContext context = nmSequencer.findContexts(model, true, null).iterator().next(); DebugSequenceAcceptor actual = new NoEnterNodesDebugSequenceAcceptor(false); ISemanticSequencer semanticSequencer = semanticSequencerProvider.get(); ISyntacticSequencer syntacticSequencer = syntacticSequencerProvider.get(); IHiddenTokenSequencer hiddenTokenSequencer = hiddenTokenSequencerProvider.get(); semanticSequencer .init((ISemanticSequenceAcceptor) syntacticSequencer, ISerializationDiagnostic.STDERR_ACCEPTOR); syntacticSequencer.init(context, model, (ISyntacticSequenceAcceptor) hiddenTokenSequencer, ISerializationDiagnostic.STDERR_ACCEPTOR); hiddenTokenSequencer.init(context, model, actual, ISerializationDiagnostic.STDERR_ACCEPTOR); semanticSequencer.createSequence(context, model); // System.out.println(actual); // System.out.println(NodeModelUtils.compactDump(NodeModelUtils.findActualNodeFor(model), true)); assertEquals(Joiner.on("\n").join(getNodeSequence(model)), Joiner.on("\n").join(actual.getColumn(4))); }
Example #3
Source File: Serializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * @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); }
Example #4
Source File: SyntacticSequencerTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
private void testSequence(EObject inObj, String outModel) throws Exception { EObject outObj = getModel(outModel); ISerializationContext context = nmSequencer.findContexts(inObj, 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, inObj, actual, ISerializationDiagnostic.STDERR_ACCEPTOR); semanticSeq.createSequence(context, inObj); assertEquals(Joiner.on("\n").join(getNodeSequence(outObj)), Joiner.on("\n").join(actual.getResult())); }
Example #5
Source File: SyntacticSequencerTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
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())); }
Example #6
Source File: FormatterTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
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); }
Example #7
Source File: SerializerTestHelper.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
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 ""; } }
Example #8
Source File: Serializer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
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); }
Example #9
Source File: SerializerTester.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.3 */ 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 ""; } }
Example #10
Source File: AbstractSemanticSequencer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void init(ISemanticSequencer sequencer, ISemanticSequenceAcceptor sequenceAcceptor, ISerializationDiagnostic.Acceptor errorAcceptor) { this.masterSequencer = sequencer; this.sequenceAcceptor = sequenceAcceptor; this.errorAcceptor = errorAcceptor; }
Example #11
Source File: SerializerTester.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.3 */ 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 ""; } }
Example #12
Source File: AbstractDelegatingSemanticSequencer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public void init(ISemanticSequencer sequencer, ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) { super.init(sequencer, sequenceAcceptor, errorAcceptor); this.genericSequencer = genericSequencerProvider.get(); this.genericSequencer.init(sequencer, sequenceAcceptor, errorAcceptor); }
Example #13
Source File: AbstractSemanticSequencer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Override public void init(ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) { init(this, sequenceAcceptor, errorAcceptor); }
Example #14
Source File: ISemanticSequencer.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
void init(ISemanticSequencer sequencer, ISemanticSequenceAcceptor sequenceAcceptor, ISerializationDiagnostic.Acceptor errorAcceptor);
Example #15
Source File: AssertStructureAcceptor.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public AssertStructureAcceptor(ISemanticSequenceAcceptor delegate) { super(delegate); }
Example #16
Source File: DebugSequenceAcceptor.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public DebugSequenceAcceptor(ISemanticSequenceAcceptor delegate) { this(delegate, false); }
Example #17
Source File: DebugSequenceAcceptor.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public DebugSequenceAcceptor(ISemanticSequenceAcceptor delegate, boolean printInstantly) { super(delegate); this.printInstantly = printInstantly; }
Example #18
Source File: AssertNodeModelAcceptor.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public AssertNodeModelAcceptor(ISemanticSequenceAcceptor delegate) { super(delegate); }
Example #19
Source File: AssertNodeModelAcceptor.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public AssertNodeModelAcceptor(ISemanticSequenceAcceptor delegate) { super(delegate); }
Example #20
Source File: DebugSequenceAcceptor.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.3 */ public DebugSequenceAcceptor(ISemanticSequenceAcceptor delegate, boolean printInstantly) { super(delegate); this.printInstantly = printInstantly; }
Example #21
Source File: DebugSequenceAcceptor.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.3 */ public DebugSequenceAcceptor(ISemanticSequenceAcceptor delegate) { this(delegate, false); }
Example #22
Source File: AssertStructureAcceptor.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public AssertStructureAcceptor(ISemanticSequenceAcceptor delegate) { super(delegate); }
Example #23
Source File: ISemanticSequencer.java From xtext-core with Eclipse Public License 2.0 | votes |
void init(ISemanticSequenceAcceptor sequenceAcceptor, ISerializationDiagnostic.Acceptor errorAcceptor);