use of org.eclipse.xtext.resource.persistence.ResourceStorageProviderAdapter in project xtext-core by eclipse.
the class ResourceStorageFacade method getOrCreateResourceStorageLoadable.
/**
* Finds or creates a ResourceStorageLoadable for the given resource.
* Clients should first call shouldLoadFromStorage to check whether there exists a storage version
* of the given resource.
*
* @return an IResourceStorageLoadable
*/
@Override
public ResourceStorageLoadable getOrCreateResourceStorageLoadable(final StorageAwareResource resource) {
try {
final ResourceStorageProviderAdapter stateProvider = IterableExtensions.<ResourceStorageProviderAdapter>head(Iterables.<ResourceStorageProviderAdapter>filter(resource.getResourceSet().eAdapters(), ResourceStorageProviderAdapter.class));
if ((stateProvider != null)) {
final ResourceStorageLoadable inputStream = stateProvider.getResourceStorageLoadable(resource);
if ((inputStream != null)) {
return inputStream;
}
}
InputStream _xifexpression = null;
boolean _exists = resource.getResourceSet().getURIConverter().exists(this.getBinaryStorageURI(resource.getURI()), CollectionLiterals.<Object, Object>emptyMap());
if (_exists) {
_xifexpression = resource.getResourceSet().getURIConverter().createInputStream(this.getBinaryStorageURI(resource.getURI()));
} else {
InputStream _xblockexpression = null;
{
final AbstractFileSystemAccess2 fsa = this.getFileSystemAccess(resource);
final String outputRelativePath = this.computeOutputPath(resource);
_xblockexpression = fsa.readBinaryFile(outputRelativePath);
}
_xifexpression = _xblockexpression;
}
final InputStream inputStream_1 = _xifexpression;
return this.createResourceStorageLoadable(inputStream_1);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.resource.persistence.ResourceStorageProviderAdapter in project xtext-core by eclipse.
the class ResourceStorageFacade method doesStorageExist.
/**
* @return whether a stored resource state exists for the given resource
*/
protected boolean doesStorageExist(final StorageAwareResource resource) {
final ResourceStorageProviderAdapter stateProvider = IterableExtensions.<ResourceStorageProviderAdapter>head(Iterables.<ResourceStorageProviderAdapter>filter(resource.getResourceSet().eAdapters(), ResourceStorageProviderAdapter.class));
if (((stateProvider != null) && (stateProvider.getResourceStorageLoadable(resource) != null))) {
return true;
}
boolean _exists = resource.getResourceSet().getURIConverter().exists(this.getBinaryStorageURI(resource.getURI()), CollectionLiterals.<Object, Object>emptyMap());
if (_exists) {
return true;
}
boolean _isArchive = resource.getURI().isArchive();
if (_isArchive) {
return false;
}
final AbstractFileSystemAccess2 fsa = this.getFileSystemAccess(resource);
final String outputRelativePath = this.computeOutputPath(resource);
final URI uri = fsa.getURI(outputRelativePath);
return ((uri != null) && resource.getResourceSet().getURIConverter().exists(uri, null));
}
Aggregations