private EObject testSequence(String stringModel) throws Exception { DebugSequenceAcceptor genericActual = new DebugSequenceAcceptor(); DebugSequenceAcceptor generatedActual = new DebugSequenceAcceptor(); DebugSequenceAcceptor expected = new DebugSequenceAcceptor(); ISemanticSequencer generatedSequencer = generatedSequencerProvider.get(); ISemanticSequencer genericSequencer = getGenericSemanticSequencer(); assertTrue(generatedSequencer instanceof SequencerTestLanguageSemanticSequencer); generatedSequencer.init(generatedActual, ISerializationDiagnostic.STDERR_ACCEPTOR); genericSequencer.init(genericActual, ISerializationDiagnostic.STDERR_ACCEPTOR); nmSequencer.init(expected, ISerializationDiagnostic.STDERR_ACCEPTOR); EObject model = getModel(stringModel).eContents().get(0); ISerializationContext context = nmSequencer.findContexts(model, true, null).iterator().next(); generatedSequencer.createSequence(context, model); genericSequencer.createSequence(context, model); nmSequencer.createSequence(context, model); assertEquals(expected.toString(), genericActual.toString()); assertEquals(expected.toString(), generatedActual.toString()); return model; }
@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); }
@Override public Set<Binding> getGuiceBindingsRt(final Grammar grammar) { final BindFactory bf = new BindFactory(); bf.addTypeToType(ISemanticSequencer.class.getName(), this.names.getSemanticSequencer().getQualifiedName()); bf.addTypeToType(ISyntacticSequencer.class.getName(), this.names.getSyntacticSequencer().getQualifiedName()); bf.addTypeToType(ISerializer.class.getName(), Serializer.class.getName()); return bf.getBindings(); }
/** * @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 ""; } }
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())); }
protected SequenceFeeder(Provider provider, ISerializationContext context, EObject semanticObject, INodesForEObjectProvider nodes, ISemanticSequencer masterSequencer, ISemanticSequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) { super(); if (semanticObject == null || nodes == null || sequenceAcceptor == null) throw new NullPointerException(); this.context = context; this.provider = provider; this.semanticObject = semanticObject; this.nodes = nodes; this.masterSequencer = masterSequencer; this.sequenceAcceptor = sequenceAcceptor; this.errorAcceptor = errorAcceptor; }
/** * @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); }
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); }
@Override public void generate() { new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef(ISemanticSequencer.class), this.getSemanticSequencerClass(this.getGrammar())).addTypeToType(TypeReference.typeRef(ISyntacticSequencer.class), this.getSyntacticSequencerClass(this.getGrammar())).addTypeToType(TypeReference.typeRef(ISerializer.class), TypeReference.typeRef(Serializer.class)).contributeTo(this.getLanguage().getRuntimeGenModule()); ManifestAccess _manifest = this.getProjectConfig().getRuntime().getManifest(); boolean _tripleNotEquals = (_manifest != null); if (_tripleNotEquals) { Set<String> _exportedPackages = this.getProjectConfig().getRuntime().getManifest().getExportedPackages(); String _serializerBasePackage = this.getSerializerBasePackage(this.getGrammar()); _exportedPackages.add(_serializerBasePackage); Set<String> _requiredBundles = this.getProjectConfig().getRuntime().getManifest().getRequiredBundles(); String _xbaseLibVersionLowerBound = this.getProjectConfig().getRuntime().getXbaseLibVersionLowerBound(); String _plus = ("org.eclipse.xtext.xbase.lib;bundle-version=\"" + _xbaseLibVersionLowerBound); String _plus_1 = (_plus + "\""); _requiredBundles.add(_plus_1); } this.generateAbstractSemanticSequencer(); this.generateAbstractSyntacticSequencer(); boolean _isGenerateStub = this.isGenerateStub(); if (_isGenerateStub) { this.generateSemanticSequencer(); this.generateSyntacticSequencer(); } if (this.generateDebugData) { this.generateGrammarConstraints(); Iterable<Pair<String, String>> _generateDebugGraphs = this.debugGraphGenerator.generateDebugGraphs(); for (final Pair<String, String> fileToContent : _generateDebugGraphs) { this.getProjectConfig().getRuntime().getSrcGen().generateFile(fileToContent.getKey(), fileToContent.getValue()); } } }
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 ""; } }
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())); }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return PkmntcgoSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return TypeExpressionsSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return TypesSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return UnicodeSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return RegularExpressionSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return N4JSSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return N4MFSemanticSequencer.class; }
@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); }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return MyDslSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return BromiumSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return DSLPoliciesSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return LcDslSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return DslSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return RestauranteSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return OCCISemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return InheritanceTest2LanguageSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return XbaseSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return FowlerDslTestLanguageSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return BacktrackingLexerTestLanguageSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return InheritanceTest3LanguageSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return ImportUriTestLanguageSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return Bug305397SemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return SyntacticSequencerTestLanguageSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return BuilderTestLanguageSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return Bug462047LangSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return XImportSectionTestLangSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return EnumAndReferenceTestLanguageSemanticSequencer.class; }
public Class<? extends ISemanticSequencer> bindISemanticSequencer() { return XtextGrammarTestLanguageSemanticSequencer.class; }