use of org.eclipse.xtext.resource.persistence.SerializableResourceDescription in project xtext-core by eclipse.
the class SerializableResourceDescriptionTest method testSerialization.
@Test
public void testSerialization() {
try {
final URI uri = URI.createURI("file:/foo/bar.baz.foo");
SerializableResourceDescription _serializableResourceDescription = new SerializableResourceDescription();
final Procedure1<SerializableResourceDescription> _function = (SerializableResourceDescription it) -> {
it.setURI(uri);
SerializableReferenceDescription _serializableReferenceDescription = new SerializableReferenceDescription();
final Procedure1<SerializableReferenceDescription> _function_1 = (SerializableReferenceDescription it_1) -> {
it_1.setSourceEObjectUri(uri.appendFragment("foo"));
it_1.setTargetEObjectUri(uri.appendFragment("hubble"));
it_1.setContainerEObjectURI(uri.appendFragment("baz"));
it_1.setEReference(EcorePackage.eINSTANCE.getEAnnotation_Contents());
it_1.setIndexInList(1);
};
SerializableReferenceDescription _doubleArrow = ObjectExtensions.<SerializableReferenceDescription>operator_doubleArrow(_serializableReferenceDescription, _function_1);
SerializableReferenceDescription _serializableReferenceDescription_1 = new SerializableReferenceDescription();
final Procedure1<SerializableReferenceDescription> _function_2 = (SerializableReferenceDescription it_1) -> {
it_1.setSourceEObjectUri(uri.appendFragment("foo2"));
it_1.setTargetEObjectUri(uri.appendFragment("hubble2"));
it_1.setContainerEObjectURI(uri.appendFragment("baz2"));
it_1.setEReference(EcorePackage.eINSTANCE.getEAnnotation_Contents());
it_1.setIndexInList(2);
};
SerializableReferenceDescription _doubleArrow_1 = ObjectExtensions.<SerializableReferenceDescription>operator_doubleArrow(_serializableReferenceDescription_1, _function_2);
it.setReferences(Collections.<SerializableReferenceDescription>unmodifiableList(CollectionLiterals.<SerializableReferenceDescription>newArrayList(_doubleArrow, _doubleArrow_1)));
SerializableEObjectDescription _serializableEObjectDescription = new SerializableEObjectDescription();
final Procedure1<SerializableEObjectDescription> _function_3 = (SerializableEObjectDescription it_1) -> {
it_1.setEObjectURI(uri.appendFragment("baz"));
it_1.qualifiedName = QualifiedName.create("foo", "baz");
it_1.setEClass(EcorePackage.eINSTANCE.getEAttribute());
Pair<String, String> _mappedTo = Pair.<String, String>of("myKey", "myValue");
it_1.userData = CollectionLiterals.<String, String>newHashMap(_mappedTo);
};
SerializableEObjectDescription _doubleArrow_2 = ObjectExtensions.<SerializableEObjectDescription>operator_doubleArrow(_serializableEObjectDescription, _function_3);
it.setDescriptions(Collections.<SerializableEObjectDescription>unmodifiableList(CollectionLiterals.<SerializableEObjectDescription>newArrayList(_doubleArrow_2)));
QualifiedName _create = QualifiedName.create("foo");
QualifiedName _create_1 = QualifiedName.create("foo", "bar");
it.setImportedNames(Collections.<QualifiedName>unmodifiableList(CollectionLiterals.<QualifiedName>newArrayList(_create, _create_1)));
};
final SerializableResourceDescription before = ObjectExtensions.<SerializableResourceDescription>operator_doubleArrow(_serializableResourceDescription, _function);
final ByteArrayOutputStream bout = new ByteArrayOutputStream();
final ObjectOutputStream objectOut = new ObjectOutputStream(bout);
objectOut.writeObject(before);
byte[] _byteArray = bout.toByteArray();
ByteArrayInputStream _byteArrayInputStream = new ByteArrayInputStream(_byteArray);
final ObjectInputStream in = new ObjectInputStream(_byteArrayInputStream);
Object _readObject = in.readObject();
final SerializableResourceDescription after = ((SerializableResourceDescription) _readObject);
this.assertDescriptionsEqual(before, after);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.resource.persistence.SerializableResourceDescription in project xtext-core by eclipse.
the class ResourceStorageLoadable method readResourceDescription.
protected void readResourceDescription(final StorageAwareResource resource, final InputStream inputStream) throws IOException {
try {
final ObjectInputStream objectIn = new ObjectInputStream(inputStream);
Object _readObject = objectIn.readObject();
final SerializableResourceDescription description = ((SerializableResourceDescription) _readObject);
description.updateResourceURI(resource.getURI());
resource.setResourceDescription(description);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.resource.persistence.SerializableResourceDescription in project xtext-core by eclipse.
the class ResourceStorageWritable method writeResourceDescription.
protected void writeResourceDescription(final StorageAwareResource resource, final OutputStream outputStream) throws IOException {
final IResourceDescription description = resource.getResourceServiceProvider().getResourceDescriptionManager().getResourceDescription(resource);
final SerializableResourceDescription serializableDescription = SerializableResourceDescription.createCopy(description);
this.convertExternalURIsToPortableURIs(serializableDescription, resource);
final ObjectOutputStream out = new ObjectOutputStream(outputStream);
try {
out.writeObject(serializableDescription);
} finally {
out.flush();
}
}
use of org.eclipse.xtext.resource.persistence.SerializableResourceDescription in project xtext-core by eclipse.
the class SerializableResourceDescriptionTest method testNullSafeSerialization.
@Test
public void testNullSafeSerialization() {
try {
final URI uri = URI.createURI("file:/foo/bar.baz.foo");
SerializableResourceDescription _serializableResourceDescription = new SerializableResourceDescription();
final Procedure1<SerializableResourceDescription> _function = (SerializableResourceDescription it) -> {
it.setURI(uri);
SerializableReferenceDescription _serializableReferenceDescription = new SerializableReferenceDescription();
final Procedure1<SerializableReferenceDescription> _function_1 = (SerializableReferenceDescription it_1) -> {
it_1.setSourceEObjectUri(uri.appendFragment("foo"));
it_1.setTargetEObjectUri(null);
it_1.setContainerEObjectURI(uri.appendFragment("baz"));
it_1.setEReference(EcorePackage.eINSTANCE.getEAnnotation_Contents());
it_1.setIndexInList(1);
};
SerializableReferenceDescription _doubleArrow = ObjectExtensions.<SerializableReferenceDescription>operator_doubleArrow(_serializableReferenceDescription, _function_1);
SerializableReferenceDescription _serializableReferenceDescription_1 = new SerializableReferenceDescription();
final Procedure1<SerializableReferenceDescription> _function_2 = (SerializableReferenceDescription it_1) -> {
it_1.setSourceEObjectUri(null);
it_1.setTargetEObjectUri(uri.appendFragment("hubble2"));
it_1.setContainerEObjectURI(uri.appendFragment("baz2"));
it_1.setEReference(EcorePackage.eINSTANCE.getEAnnotation_Contents());
it_1.setIndexInList(2);
};
SerializableReferenceDescription _doubleArrow_1 = ObjectExtensions.<SerializableReferenceDescription>operator_doubleArrow(_serializableReferenceDescription_1, _function_2);
SerializableReferenceDescription _serializableReferenceDescription_2 = new SerializableReferenceDescription();
final Procedure1<SerializableReferenceDescription> _function_3 = (SerializableReferenceDescription it_1) -> {
it_1.setSourceEObjectUri(uri.appendFragment("foo"));
it_1.setTargetEObjectUri(uri.appendFragment("hubble2"));
it_1.setContainerEObjectURI(null);
it_1.setEReference(EcorePackage.eINSTANCE.getEAnnotation_Contents());
it_1.setIndexInList(2);
};
SerializableReferenceDescription _doubleArrow_2 = ObjectExtensions.<SerializableReferenceDescription>operator_doubleArrow(_serializableReferenceDescription_2, _function_3);
SerializableReferenceDescription _serializableReferenceDescription_3 = new SerializableReferenceDescription();
final Procedure1<SerializableReferenceDescription> _function_4 = (SerializableReferenceDescription it_1) -> {
it_1.setSourceEObjectUri(uri.appendFragment("foo"));
it_1.setTargetEObjectUri(null);
it_1.setContainerEObjectURI(null);
it_1.setEReference(EcorePackage.eINSTANCE.getEAnnotation_Contents());
it_1.setIndexInList(2);
};
SerializableReferenceDescription _doubleArrow_3 = ObjectExtensions.<SerializableReferenceDescription>operator_doubleArrow(_serializableReferenceDescription_3, _function_4);
SerializableReferenceDescription _serializableReferenceDescription_4 = new SerializableReferenceDescription();
final Procedure1<SerializableReferenceDescription> _function_5 = (SerializableReferenceDescription it_1) -> {
it_1.setSourceEObjectUri(null);
it_1.setTargetEObjectUri(null);
it_1.setContainerEObjectURI(null);
it_1.setEReference(EcorePackage.eINSTANCE.getEAnnotation_Contents());
it_1.setIndexInList(2);
};
SerializableReferenceDescription _doubleArrow_4 = ObjectExtensions.<SerializableReferenceDescription>operator_doubleArrow(_serializableReferenceDescription_4, _function_5);
it.setReferences(Collections.<SerializableReferenceDescription>unmodifiableList(CollectionLiterals.<SerializableReferenceDescription>newArrayList(_doubleArrow, _doubleArrow_1, _doubleArrow_2, _doubleArrow_3, _doubleArrow_4)));
SerializableEObjectDescription _serializableEObjectDescription = new SerializableEObjectDescription();
final Procedure1<SerializableEObjectDescription> _function_6 = (SerializableEObjectDescription it_1) -> {
it_1.setEObjectURI(uri.appendFragment("baz"));
it_1.qualifiedName = QualifiedName.create("foo", "baz");
it_1.setEClass(EcorePackage.eINSTANCE.getEAttribute());
Pair<String, String> _mappedTo = Pair.<String, String>of("myKey", "myValue");
it_1.userData = CollectionLiterals.<String, String>newHashMap(_mappedTo);
};
SerializableEObjectDescription _doubleArrow_5 = ObjectExtensions.<SerializableEObjectDescription>operator_doubleArrow(_serializableEObjectDescription, _function_6);
it.setDescriptions(Collections.<SerializableEObjectDescription>unmodifiableList(CollectionLiterals.<SerializableEObjectDescription>newArrayList(_doubleArrow_5)));
QualifiedName _create = QualifiedName.create("foo");
QualifiedName _create_1 = QualifiedName.create("foo", "bar");
it.setImportedNames(Collections.<QualifiedName>unmodifiableList(CollectionLiterals.<QualifiedName>newArrayList(_create, _create_1)));
};
final SerializableResourceDescription before = ObjectExtensions.<SerializableResourceDescription>operator_doubleArrow(_serializableResourceDescription, _function);
final ByteArrayOutputStream bout = new ByteArrayOutputStream();
final ObjectOutputStream objectOut = new ObjectOutputStream(bout);
objectOut.writeObject(before);
byte[] _byteArray = bout.toByteArray();
ByteArrayInputStream _byteArrayInputStream = new ByteArrayInputStream(_byteArray);
final ObjectInputStream in = new ObjectInputStream(_byteArrayInputStream);
Object _readObject = in.readObject();
final SerializableResourceDescription after = ((SerializableResourceDescription) _readObject);
this.assertDescriptionsEqual(before, after);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations