Java 类org.eclipse.xtext.validation.IConcreteSyntaxValidator 实例源码

项目:xtext-core    文件:Serializer.java   
public TreeConstructionReport serialize(EObject obj, ITokenStream tokenStream, SaveOptions options)
        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);
    }
    ITokenStream formatterTokenStream;
    if(formatter instanceof IFormatterExtension)
        formatterTokenStream = ((IFormatterExtension) formatter).createFormatterStream(obj, null, tokenStream, !options.isFormatting());
    else 
        formatterTokenStream = formatter.createFormatterStream(null, tokenStream, !options.isFormatting());
    TreeConstructionReport report = parseTreeReconstructor.serializeSubtree(obj, formatterTokenStream);
    formatterTokenStream.flush();
    return report;
}
项目: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-core    文件:XtextResource.java   
public List<org.eclipse.emf.common.util.Diagnostic> validateConcreteSyntax() {
    List<org.eclipse.emf.common.util.Diagnostic> diagnostics = new ArrayList<org.eclipse.emf.common.util.Diagnostic>();
    IDiagnosticAcceptor acceptor = new IConcreteSyntaxValidator.DiagnosticListAcceptor(diagnostics);
    for (EObject obj : getContents())
        validator.validateRecursive(obj, acceptor, new HashMap<Object, Object>());
    return diagnostics;
}
项目:xtext-core    文件:XtextResource.java   
public IConcreteSyntaxValidator getConcreteSyntaxValidator() {
    return validator;
}
项目:xtext-core    文件:Serializer.java   
@Inject
public Serializer(IParseTreeConstructor ptc, IFormatter fmt, IConcreteSyntaxValidator val) {
    this.parseTreeReconstructor = ptc;
    this.formatter = fmt;
    this.validator = val;
}
项目:xtext-core    文件:Serializer.java   
protected IConcreteSyntaxValidator getValidator() {
    return validator;
}
项目:xtext-core    文件:DefaultRuntimeModule.java   
public Class<? extends IConcreteSyntaxValidator> bindConcreteSyntaxValidator() {
    return ConcreteSyntaxValidator.class;
}
项目:xtext-core    文件:ConcreteSyntaxValidatorTest.java   
@Override
protected IConcreteSyntaxValidator getValidator() {
    return validator;
}