mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 16:58:56 +00:00
Discard derived state on an operation canceled exception during
installing derived state. Change-Id: Ida2102340f5643d3cb0528fccfc11848674f55a7 Signed-off-by: akosyakov <anton.kosyakov@itemis.de>
This commit is contained in:
parent
b7a00b96b7
commit
ca5808f354
1 changed files with 16 additions and 2 deletions
|
@ -20,6 +20,7 @@ import org.eclipse.xtext.resource.persistence.StorageAwareResource;
|
|||
import org.eclipse.xtext.util.IResourceScopeCache;
|
||||
import org.eclipse.xtext.util.OnChangeEvictingCache;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
|
@ -193,8 +194,21 @@ public class DerivedStateAwareResource extends StorageAwareResource {
|
|||
if (!fullyInitialized && !isInitializing && !isLoadedFromStorage()) {
|
||||
try {
|
||||
isInitializing = true;
|
||||
if (derivedStateComputer != null)
|
||||
derivedStateComputer.installDerivedState(this, preIndexingPhase);
|
||||
if (derivedStateComputer != null) {
|
||||
EList<EObject> roots = doGetContents();
|
||||
if (roots.size() > 1) {
|
||||
throw new IllegalStateException("The resource should have no more than one root element, but: " + roots);
|
||||
}
|
||||
try {
|
||||
derivedStateComputer.installDerivedState(this, preIndexingPhase);
|
||||
} catch (Throwable e) {
|
||||
if (operationCanceledManager.isOperationCanceledException(e)) {
|
||||
derivedStateComputer.discardDerivedState(this);
|
||||
operationCanceledManager.propagateAsErrorIfCancelException(e);
|
||||
}
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
fullyInitialized = true;
|
||||
} finally {
|
||||
isInitializing = false;
|
||||
|
|
Loading…
Reference in a new issue