From 80551f41620a134aeddde1f4476800f4e0659e87 Mon Sep 17 00:00:00 2001 From: Sven Efftinge Date: Fri, 2 Jan 2015 14:02:47 +0100 Subject: [PATCH] [storage] Make standalone compiler and xtend batch compiler optionally write storage resource data. Change-Id: I628cb357cc7c65fe70706aa83eb9a489a708605c --- .../persistence/ResourceStorageFacade.xtend | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/persistence/ResourceStorageFacade.xtend b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/persistence/ResourceStorageFacade.xtend index 0d9d8af41..f4809d066 100644 --- a/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/persistence/ResourceStorageFacade.xtend +++ b/plugins/org.eclipse.xtext/src/org/eclipse/xtext/resource/persistence/ResourceStorageFacade.xtend @@ -55,8 +55,8 @@ class ResourceStorageFacade implements IResourceStorageFacade { if (inputStream != null) return inputStream } - val inputStream = if (resource.resourceSet.URIConverter.exists(resource.URI.getBinaryStrorageURI, emptyMap)) { - resource.resourceSet.URIConverter.createInputStream(resource.URI.getBinaryStrorageURI) + val inputStream = if (resource.resourceSet.URIConverter.exists(resource.URI.getBinaryStorageURI, emptyMap)) { + resource.resourceSet.URIConverter.createInputStream(resource.URI.getBinaryStorageURI) } else { val fsa = getFileSystemAccess(resource); val outputRelativePath = computeOutputPath(resource) @@ -89,7 +89,7 @@ class ResourceStorageFacade implements IResourceStorageFacade { if (stateProvider!=null && stateProvider.getResourceStorageLoadable(resource) != null) return true; // check for next to original location, i.e. jars - if (resource.resourceSet.URIConverter.exists(resource.URI.getBinaryStrorageURI, emptyMap)) { + if (resource.resourceSet.URIConverter.exists(resource.URI.getBinaryStorageURI, emptyMap)) { return true } @@ -108,17 +108,21 @@ class ResourceStorageFacade implements IResourceStorageFacade { } protected def computeOutputPath(StorageAwareResource resource) { - val uri = resource.URI.getBinaryStrorageURI - val srcFolderPath = uri.trimFileExtension.trimSegments(uri.segmentCount-3).toString - val outputRelativePath = uri.toString.substring(srcFolderPath.length+1) + val srcContainerURI = getSourceContainerURI(resource) + val uri = resource.URI.getBinaryStorageURI + val outputRelativePath = uri.deresolve(srcContainerURI, false, false, true).path return outputRelativePath } - override hasStorageFor(URI uri) { - new ExtensibleURIConverterImpl().exists(getBinaryStrorageURI(uri), emptyMap()) + def protected getSourceContainerURI(StorageAwareResource resource) { + resource.URI.trimFileExtension.trimSegments(1).appendSegment("") } - protected def getBinaryStrorageURI(URI sourceURI) { + override hasStorageFor(URI uri) { + new ExtensibleURIConverterImpl().exists(getBinaryStorageURI(uri), emptyMap()) + } + + protected def getBinaryStorageURI(URI sourceURI) { return sourceURI.trimSegments(1).appendSegment("."+sourceURI.lastSegment+'bin') }