use of org.eclipse.xtext.parsetree.reconstr.IParseTreeConstructor.TreeConstructionReport in project xtext-core by eclipse.
the class Serializer method serialize.
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;
}
Aggregations