@Override public Result exec(final State state, final CancelIndicator cancelIndicator) throws Exception { if (state == null) { return defaultResult.get(); } return work.exec(state); } }
@Override public <Result extends Object> Result execute(final IUnitOfWork<Result, ? super JavaResource> unit) throws Exception { synchronized (this.getLock()) { return unit.exec(this); } }
/** * {@inheritDoc} * * @since 2.4 */ /* @Nullable */ @Override public <Result> Result execute(/* @NonNull */ IUnitOfWork<Result, ? super TypeResource> unit) throws Exception { synchronized (getLock()) { return unit.exec(this); } }
public R exec(XtextResource state) throws Exception { ResourceSet localContext = state.getResourceSet(); if (localContext != null) return work.exec(localContext); return null; } });
/** * {@inheritDoc} * * @since 2.4 */ /* @Nullable */ @Override public <Result> Result execute(/* @NonNull */ IUnitOfWork<Result, ? super BatchLinkableResource> unit) throws Exception { synchronized (getLock()) { return unit.exec(this); } }
public <R> R readOnly(URI targetURI, IUnitOfWork<R, ResourceSet> work) { try { return work.exec(resourceSet); } catch(Exception exc) { throw new WrappedException(exc); } }
public T exec(XtextResource resource) throws Exception { if(resource != null && !resource.getContents().isEmpty()) { work.exec(resource.getContents().get(0)); } return null; } });
/** * {@inheritDoc} * * @since 2.4 */ @Nullable public <Result> Result execute(@NonNull IUnitOfWork<Result, ? super SynchronizedXtextResourceSet> unit) throws Exception { synchronized (getLock()) { return unit.exec(this); } }
/** * {@inheritDoc} * * @since 2.4 */ @Nullable public <Result> Result execute(@NonNull IUnitOfWork<Result, ? super TypeResource> unit) throws Exception { synchronized (getLock()) { return unit.exec(this); } }
/** * The transaction will be executed with caching enabled. However, all newly cached values will be discarded as soon * as the transaction is over. * @since 2.1 */ public <Result, Param extends Resource> Result execWithTemporaryCaching(Param resource, IUnitOfWork<Result, Param> transaction) throws WrappedException { CacheAdapter cacheAdapter = getOrCreate(resource); IgnoreValuesMemento memento = cacheAdapter.ignoreNewValues(); try { return transaction.exec(resource); } catch (Exception e) { throw new WrappedException(e); } finally { memento.done(); } }
/** * The transaction will be executed with caching enabled. However, all newly cached values will be discarded as soon * as the transaction is over. * @since 2.1 */ public <Result, Param extends Resource> Result execWithTemporaryCaching(Param resource, IUnitOfWork<Result, Param> transaction) throws WrappedException { CacheAdapter cacheAdapter = getOrCreate(resource); IgnoreValuesMemento memento = cacheAdapter.ignoreNewValues(); try { return transaction.exec(resource); } catch (Exception e) { throw new WrappedException(e); } finally { memento.done(); } }
protected <R extends Object> R readOnly(final URI objectURI, final IUnitOfWork<R, EObject> work) { final IUnitOfWork<R, ResourceSet> _function = (ResourceSet resourceSet) -> { final EObject targetObject = resourceSet.getEObject(objectURI, true); return work.exec(targetObject); }; return this.getResourceAccess().<R>readOnly(objectURI, _function); }
@Override 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 { if ((resource == null)) { return null; } return work.exec(resource.getResourceSet()); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }; return this.workspaceManager.<R>doRead(targetURI, _function); }
public <R> R readOnly(URI targetURI, IUnitOfWork<R, ResourceSet> work) { Iterable<Pair<IStorage, IProject>> storages = storage2UriMapper.getStorages(targetURI.trimFragment()); Iterator<Pair<IStorage, IProject>> iterator = storages.iterator(); while(iterator.hasNext()) { Pair<IStorage, IProject> pair = iterator.next(); IProject project = pair.getSecond(); if (project != null) { ResourceSet resourceSet = resourceSetProvider.get(project); if(resourceSet != null) resourceSet.getResource(targetURI, true); try { return work.exec(resourceSet); } catch (Exception e) { throw new WrappedException(e); } } } return null; } }
public <R> R readOnly(URI targetURI, IUnitOfWork<R, ResourceSet> work) { URI resourceURI = targetURI.trimFragment(); Iterable<Pair<IStorage, IProject>> storages = storage2UriMapper.getStorages(resourceURI); Iterator<Pair<IStorage, IProject>> iterator = storages.iterator(); ResourceSet resourceSet = fallBackResourceSet; while(iterator.hasNext()) { Pair<IStorage, IProject> pair = iterator.next(); IProject project = pair.getSecond(); if (project != null) { resourceSet = getResourceSet(project); break; } } if(resourceSet != null) { resourceSet.getResource(resourceURI, true); try { return work.exec(resourceSet); } catch (Exception e) { throw new WrappedException(e); } } return null; }
/** * The transaction will be executed. While it is running, any semantic state change * in the given resource will be ignored and the cache will not be cleared. */ public <Result, Param extends Resource> Result execWithoutCacheClear(Param resource, IUnitOfWork<Result, Param> transaction) throws WrappedException { CacheAdapter cacheAdapter = getOrCreate(resource); try { cacheAdapter.ignoreNotifications(); return transaction.exec(resource); } catch (Exception e) { throw new WrappedException(e); } finally { cacheAdapter.listenToNotifications(); } }
/** * The transaction will be executed. While it is running, any semantic state change * in the given resource will be ignored and the cache will not be cleared. */ public <Result, Param extends Resource> Result execWithoutCacheClear(Param resource, IUnitOfWork<Result, Param> transaction) throws WrappedException { CacheAdapter cacheAdapter = getOrCreate(resource); try { cacheAdapter.ignoreNotifications(); return transaction.exec(resource); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new WrappedException(e); } finally { cacheAdapter.listenToNotifications(); } }
public <T> T readOnly(IUnitOfWork<T, P> work) { acquireReadLock(); try { P state = getState(); beforeReadOnly(state, work); T exec = work.exec(state); afterReadOnly(state, exec, work); return exec; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new WrappedException(e); } finally { releaseReadLock(); } }
@Override public <Result> Result readOnly(IUnitOfWork<Result, State> work) { acquireReadLock(); try { State state = getState(); beforeReadOnly(state, work); Result exec = work.exec(state); afterReadOnly(state, exec, work); return exec; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new WrappedException(e); } finally { releaseReadLock(); } }
public <Result> Result useTemporaryResource( ResourceSet resourceSet, Grammar language, AbstractRule rootRule, String content, IUnitOfWork<Result, XtextResource> runnable) { XtextResource resource = languageRegistry.createTemporaryResourceIn(language, resourceSet); if (rootRule != null) PartialParser.assignRootRule(resource, (ParserRule) rootRule); try { resource.load(new StringInputStream(content, resource.getEncoding()), null); return runnable.exec(resource); } catch(Exception e) { throw new RuntimeException(e); } finally { if (resource != null) { if (resource.isLoaded()) resource.unload(); resourceSet.getResources().remove(resource); } } }