Java 类org.eclipse.xtext.serializer.acceptor.ISequenceAcceptor 实例源码

项目: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, context, root);
    }
    hidden.init(context, root, acceptor, errorAcceptor);
    if (acceptor instanceof TokenStreamSequenceAdapter)
        ((TokenStreamSequenceAdapter) acceptor).init(context);
    semantic.createSequence(context, root);
}
项目:dsl-devkit    文件:IndentingSerializer.java   
/**
 * Serialize the given object into tokenStream using save options.
 * The initial indentation is passed on to the formatter.
 * This implementation is based on {@link Serializer#serialize(EObject, ITokenStream, SaveOptions)}.
 *
 * @param obj
 *          the obj
 * @param tokenStream
 *          the token stream
 * @param options
 *          the options
 * @param initialIndentation
 *          the initial indentation
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 */
protected void serialize(final EObject obj, final ITokenStream tokenStream, final SaveOptions options, final String initialIndentation) throws IOException {
  if (options.isValidating()) {
    List<Diagnostic> diagnostics = new ArrayList<Diagnostic>();
    validator.validateRecursive(obj, new IConcreteSyntaxValidator.DiagnosticListAcceptor(diagnostics), new HashMap<Object, Object>());
    if (!diagnostics.isEmpty()) {
      throw new IConcreteSyntaxValidator.InvalidConcreteSyntaxException("These errors need to be fixed before the model can be serialized.", diagnostics); //$NON-NLS-1$
    }
  }

  ISerializationDiagnostic.Acceptor errors = ISerializationDiagnostic.EXCEPTION_THROWING_ACCEPTOR;
  ITokenStream formatterTokenStream;
  if (formatter instanceof IFormatterExtension) {
    formatterTokenStream = ((IFormatterExtension) formatter).createFormatterStream(obj, initialIndentation, tokenStream, !options.isFormatting());
  } else {
    formatterTokenStream = formatter.createFormatterStream(initialIndentation, tokenStream, !options.isFormatting());
  }
  EObject context = getContext(obj);
  ISequenceAcceptor acceptor = new TokenStreamSequenceAdapter(formatterTokenStream, errors);
  serialize(obj, context, acceptor, errors);
  formatterTokenStream.flush();
}
项目: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, (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 "";
    }
}
项目:xtext-core    文件:HiddenTokenSequencer.java   
@Override
@Deprecated
public void init(EObject context, EObject semanticObject, ISequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
    this.delegate = sequenceAcceptor;
    this.lastNode = NodeModelUtils.findActualNodeFor(semanticObject);
    this.rootNode = lastNode;
    if (rootNode != null) {
        this.rootOffset = rootNode.getTotalOffset();
        this.rootEndOffset = rootNode.getTotalEndOffset();
    }
}
项目:xtext-core    文件:HiddenTokenSequencer.java   
@Override
public void init(ISerializationContext context, EObject semanticObject, ISequenceAcceptor sequenceAcceptor, Acceptor errorAcceptor) {
    this.delegate = sequenceAcceptor;
    this.lastNode = NodeModelUtils.findActualNodeFor(semanticObject);
    this.rootNode = lastNode;
    if (rootNode != null) {
        this.rootOffset = rootNode.getTotalOffset();
        this.rootEndOffset = rootNode.getTotalEndOffset();
    }
}
项目: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, semanticObject, (ISyntacticSequenceAcceptor) hidden, errors);
    hidden.init(context, semanticObject, 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, 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);
}
项目:xtext-core    文件:Serializer.java   
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();
}
项目:xtext-core    文件:StringBasedTextRegionAccessDiffBuilder.java   
@Override
public ISequenceAcceptor replaceSequence(IHiddenRegion originalFirst, IHiddenRegion originalLast,
        ISerializationContext ctx, EObject root) {
    checkOriginal(originalFirst);
    checkOriginal(originalLast);
    TextRegionAccessBuildingSequencer sequenceAcceptor = new TextRegionAccessBuildingSequencer();
    addInsert(new SequenceRewriteAction(originalFirst, originalLast, sequenceAcceptor));
    return sequenceAcceptor.withRoot(ctx, root);
}
项目:xtext-core    文件:SerializerTestHelper.java   
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 "";
    }
}
项目:dsl-devkit    文件:ReorderingHiddenTokenSequencer.java   
@Override
public void init(final EObject context, final EObject semanticObject, final ISequenceAcceptor sequenceAcceptor, final Acceptor errorAcceptor) {
  this.delegate = sequenceAcceptor;
  this.lastNode = NodeModelUtils.findActualNodeFor(semanticObject);
  this.rootNode = lastNode;
  if (rootNode != null) {
    this.rootOffset = rootNode.getTotalOffset();
    this.rootEndOffset = rootNode.getTotalEndOffset();
  }
}
项目:xtext-core    文件:IHiddenTokenSequencer.java   
/**
 * @deprecated use {@link #init(ISerializationContext, EObject, ISequenceAcceptor, ISerializationDiagnostic.Acceptor)}
 */
@Deprecated
void init(EObject context, EObject semanticObject, ISequenceAcceptor sequenceAcceptor,
        ISerializationDiagnostic.Acceptor errorAcceptor);
项目:xtext-core    文件:IHiddenTokenSequencer.java   
void init(ISerializationContext context, EObject semanticObject, ISequenceAcceptor sequenceAcceptor,
ISerializationDiagnostic.Acceptor errorAcceptor);
项目:xtext-core    文件:TextRegionAccessBuilder.java   
public ISequenceAcceptor forSequence(ISerializationContext ctx, EObject root) {
    return this.fromSequencer = new TextRegionAccessBuildingSequencer().withRoot(ctx, root);
}
项目:xtext-core    文件:ITextRegionDiffBuilder.java   
ISequenceAcceptor replaceSequence(IHiddenRegion first, IHiddenRegion last, ISerializationContext ctx, EObject root);