Search in sources :

Example 1 with SerializableNodeModel

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);
}
Also used : DeserializationConversionContext(org.eclipse.xtext.nodemodel.serialization.DeserializationConversionContext) InputStreamReader(java.io.InputStreamReader) ParseResult(org.eclipse.xtext.parser.ParseResult) DataInputStream(java.io.DataInputStream) BufferedInputStream(java.io.BufferedInputStream) ZipInputStream(java.util.zip.ZipInputStream) ObjectInputStream(java.io.ObjectInputStream) InputStream(java.io.InputStream) SerializableNodeModel(org.eclipse.xtext.nodemodel.impl.SerializableNodeModel) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) DataInputStream(java.io.DataInputStream) URI(org.eclipse.emf.common.util.URI)

Example 2 with SerializableNodeModel

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();
}
Also used : DataOutputStream(java.io.DataOutputStream) SerializableNodeModel(org.eclipse.xtext.nodemodel.impl.SerializableNodeModel) SerializationConversionContext(org.eclipse.xtext.nodemodel.serialization.SerializationConversionContext)

Aggregations

SerializableNodeModel (org.eclipse.xtext.nodemodel.impl.SerializableNodeModel)2 BufferedInputStream (java.io.BufferedInputStream)1 DataInputStream (java.io.DataInputStream)1 DataOutputStream (java.io.DataOutputStream)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 ObjectInputStream (java.io.ObjectInputStream)1 ZipInputStream (java.util.zip.ZipInputStream)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1 InternalEObject (org.eclipse.emf.ecore.InternalEObject)1 DeserializationConversionContext (org.eclipse.xtext.nodemodel.serialization.DeserializationConversionContext)1 SerializationConversionContext (org.eclipse.xtext.nodemodel.serialization.SerializationConversionContext)1 ParseResult (org.eclipse.xtext.parser.ParseResult)1