use of com.avaloq.tools.ddk.xtext.extensions.AbstractResourceDescriptionsData in project dsl-devkit by dsldevkit.
the class MonitoredClusteringBuilderState method setResourceDescriptionsData.
/**
* Set the resource descriptions data, unless cancellation has been requested.
*
* @param newData
* the new resource descriptions data
* @param monitor
* the monitor to check for cancellation
*/
protected void setResourceDescriptionsData(final ResourceDescriptionsData newData, final IProgressMonitor monitor) {
checkForCancellation(monitor);
rawData = newData;
if (newData instanceof IResourceDescriptions2) {
myData = (IResourceDescriptions2) newData;
} else {
myData = new ResourceDescriptions2(newData);
}
super.setResourceDescriptionsData(newData);
if (isLoaded && newData instanceof AbstractResourceDescriptionsData) {
((AbstractResourceDescriptionsData) newData).commitChanges();
}
isLoaded = true;
}
use of com.avaloq.tools.ddk.xtext.extensions.AbstractResourceDescriptionsData in project dsl-devkit by dsldevkit.
the class MonitoredClusteringBuilderState method clean.
@Override
public synchronized ImmutableList<IResourceDescription.Delta> clean(final Set<URI> toBeRemoved, final IProgressMonitor monitor) {
ensureLoaded();
Set<URI> toBeRemovedCopy = ensureNotNull(toBeRemoved);
SubMonitor subMonitor = SubMonitor.convert(monitor, org.eclipse.xtext.builder.builderState.Messages.AbstractBuilderState_0, 2);
subMonitor.subTask(org.eclipse.xtext.builder.builderState.Messages.AbstractBuilderState_0);
if (toBeRemovedCopy.isEmpty()) {
return ImmutableList.of();
}
checkForCancellation(monitor);
Collection<IResourceDescription.Delta> deltas = doClean(toBeRemovedCopy, subMonitor.newChild(1));
final ResourceDescriptionsData newData = getCopiedResourceDescriptionsData();
ResourceDescriptionChangeEvent event = null;
try {
checkForCancellation(monitor);
for (IResourceDescription.Delta delta : deltas) {
newData.removeDescription(delta.getOld().getURI());
}
event = new ResourceDescriptionChangeEvent(deltas);
checkForCancellation(monitor);
updateDeltas(event.getDeltas(), null, subMonitor.newChild(1));
// update the reference
setResourceDescriptionsData(newData, monitor);
// CHECKSTYLE:CHECK-OFF IllegalCatch
} catch (Throwable t) {
// CHECKSTYLE:CHEKC-ON IllegalCatch
if (newData instanceof AbstractResourceDescriptionsData) {
((AbstractResourceDescriptionsData) newData).rollbackChanges();
}
throw t;
}
notifyListeners(event);
return event.getDeltas();
}
use of com.avaloq.tools.ddk.xtext.extensions.AbstractResourceDescriptionsData in project dsl-devkit by dsldevkit.
the class MonitoredClusteringBuilderState method platformChanged.
/**
* {@inheritDoc} Schedules a full clean build if the target platform changes.
*/
@Override
public void platformChanged(final IResourceDescriptionsData newPlatform, final Collection<Delta> deltas, final boolean mustRebuild) {
if (newPlatform == null) {
// Hmmm... context deactivated. Events for removing the project from the index will be generated anyway, so no build necessary.
// TODO: check!
setResourceDescriptionsData(new NullResourceDescriptionsData());
return;
}
// Deltas?
if (isLoaded()) {
// AbstractXtextTargetPlatformManager if it was the initial load?
if (newPlatform instanceof AbstractResourceDescriptionsData) {
((AbstractResourceDescriptionsData) newPlatform).beginChanges();
}
setResourceDescriptionsData((ResourceDescriptionsData) newPlatform);
ResourceDescriptionChangeEvent event = new ResourceDescriptionChangeEvent(deltas);
notifyListeners(event);
}
if (mustRebuild) {
buildTrigger.scheduleFullBuild();
}
}
use of com.avaloq.tools.ddk.xtext.extensions.AbstractResourceDescriptionsData in project dsl-devkit by dsldevkit.
the class MonitoredClusteringBuilderState method update.
@Override
@SuppressWarnings("PMD.AvoidInstanceofChecksInCatchClause")
public synchronized ImmutableList<Delta> update(final BuildData buildData, final IProgressMonitor monitor) {
ensureLoaded();
final SubMonitor subMonitor = SubMonitor.convert(monitor, org.eclipse.xtext.builder.builderState.Messages.AbstractBuilderState_0, 1);
subMonitor.subTask(org.eclipse.xtext.builder.builderState.Messages.AbstractBuilderState_0);
checkForCancellation(monitor);
final ResourceDescriptionsData newData = getCopiedResourceDescriptionsData();
Collection<IResourceDescription.Delta> result = null;
try {
result = doUpdate(buildData, newData, subMonitor.newChild(1));
// update the reference
setResourceDescriptionsData(newData, monitor);
// CHECKSTYLE:CHECK-OFF IllegalCatch
} catch (Throwable t) {
// CHECKSTYLE:CHECK-ON IllegalCatch
if (!operationCanceledManager.isOperationCanceledException(t)) {
// $NON-NLS-1$
LOGGER.error("Failed to update index. Executing rollback.", t);
}
if (newData instanceof AbstractResourceDescriptionsData) {
((AbstractResourceDescriptionsData) newData).rollbackChanges();
}
throw t;
}
final ResourceDescriptionChangeEvent event = new ResourceDescriptionChangeEvent(result);
notifyListeners(event);
return event.getDeltas();
}
Aggregations