[ls/resourceAccess] fail if the resource set is null

Signed-off-by: Anton Kosiakov <anton.kosyakov@typefox.io>
This commit is contained in:
Anton Kosiakov 2017-06-18 12:03:17 +02:00
parent 2cfbea4021
commit 2782bd4e8c
3 changed files with 5 additions and 11 deletions

View file

@ -25,11 +25,10 @@ class WorkspaceResourceAccess implements IResourceAccess {
override <R> readOnly(URI targetURI, IUnitOfWork<R, ResourceSet> work) {
return workspaceManager.doRead(targetURI) [ document, resource |
val resourceSet = resource?.resourceSet
if (resourceSet === null) {
if (resource === null) {
return null
}
return work.exec(resourceSet)
return work.exec(resource.resourceSet)
]
}

View file

@ -31,15 +31,10 @@ public class WorkspaceResourceAccess implements IReferenceFinder.IResourceAccess
public <R extends Object> R readOnly(final URI targetURI, final IUnitOfWork<R, ResourceSet> work) {
final Function2<Document, XtextResource, R> _function = (Document document, XtextResource resource) -> {
try {
ResourceSet _resourceSet = null;
if (resource!=null) {
_resourceSet=resource.getResourceSet();
}
final ResourceSet resourceSet = _resourceSet;
if ((resourceSet == null)) {
if ((resource == null)) {
return null;
}
return work.exec(resourceSet);
return work.exec(resource.getResourceSet());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}

View file

@ -45,7 +45,7 @@ public interface IReferenceFinder {
* Provides safe read access to a resource set for searching local references or references in a demand-created or
* shared resource set.
*
* Return `null` if a resource set cannot be provided for the given target URI.
* Return <code>null</code> if a resource set cannot be provided for the given target URI.
*/
interface IResourceAccess {
<R> R readOnly(URI targetURI, IUnitOfWork<R, ResourceSet> work);