项目:xtext-core
文件:HiddenTokenSequencerTest.java
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,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)));
}
项目:xtext-core
文件:PartialSerializer.java
@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,root);
}
hidden.init(context,acceptor,errorAcceptor);
if (acceptor instanceof TokenStreamSequenceAdapter)
((TokenStreamSequenceAdapter) acceptor).init(context);
semantic.createSequence(context,root);
}
项目:xtext-extras
文件:SerializerTester.java
/**
* @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,errors);
hidden.init(context,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 "";
}
}
项目:xtext-core
文件:Serializer.java
/**
* @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,errors);
hidden.init(context,tokens,errors);
if (tokens instanceof TokenStreamSequenceAdapter)
((TokenStreamSequenceAdapter) tokens).init(context);
semantic.createSequence(context,semanticObject);
}
项目:xtext-core
文件:Serializer.java
protected void serialize(ISerializationContext context,EObject semanticObject,semanticObject);
}
项目:xtext-core
文件:SerializerTestHelper.java
项目:xtext-core
文件:FormatterTest.java
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,tokenstream,errors);
tokenstream.init(context);
semantic.createSequence(context,semanticObject);
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。