use of org.eclipse.xtext.nodemodel.impl.SerializableNodeModel in project xtext-core by eclipse.
the class ResourceStorageLoadable method readNodeModel.
protected void readNodeModel(final StorageAwareResource resource, final InputStream inputStream) throws IOException {
final SerializableNodeModel serializableNodeModel = new SerializableNodeModel(resource);
boolean _exists = resource.getResourceSet().getURIConverter().exists(resource.getURI(), resource.getResourceSet().getLoadOptions());
boolean _not = (!_exists);
if (_not) {
URI _uRI = resource.getURI();
String _plus = ("Skipping loading node model for synthetic resource " + _uRI);
ResourceStorageLoadable.LOG.info(_plus);
return;
}
final InputStream stream = resource.getResourceSet().getURIConverter().createInputStream(resource.getURI());
String _encoding = resource.getEncoding();
final InputStreamReader in = new InputStreamReader(stream, _encoding);
final String completeContent = CharStreams.toString(in);
final DeserializationConversionContext deserializationContext = new DeserializationConversionContext(resource, completeContent);
final DataInputStream dataIn = new DataInputStream(inputStream);
serializableNodeModel.readObjectData(dataIn, deserializationContext);
EObject _head = IterableExtensions.<EObject>head(resource.getContents());
boolean _hasErrors = deserializationContext.hasErrors();
ParseResult _parseResult = new ParseResult(_head, serializableNodeModel.root, _hasErrors);
resource.setParseResult(_parseResult);
}
use of org.eclipse.xtext.nodemodel.impl.SerializableNodeModel in project xtext-core by eclipse.
the class ResourceStorageWritable method writeNodeModel.
protected void writeNodeModel(final StorageAwareResource resource, final OutputStream outputStream) throws IOException {
final DataOutputStream out = new DataOutputStream(outputStream);
final SerializableNodeModel serializableNodeModel = new SerializableNodeModel(resource);
final SerializationConversionContext conversionContext = new SerializationConversionContext(resource);
serializableNodeModel.writeObjectData(out, conversionContext);
out.flush();
}
Aggregations