Search in sources :

Example 1 with AbstractResourceDescriptionsData

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;
}
Also used : ResourceDescriptions2(com.avaloq.tools.ddk.xtext.extensions.ResourceDescriptions2) IResourceDescriptions2(com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptions2) AbstractResourceDescriptionsData(com.avaloq.tools.ddk.xtext.extensions.AbstractResourceDescriptionsData) IResourceDescriptions2(com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptions2)

Example 2 with AbstractResourceDescriptionsData

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();
}
Also used : IResourceDescriptionsData(com.avaloq.tools.ddk.xtext.extensions.IResourceDescriptionsData) ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) NullResourceDescriptionsData(com.avaloq.tools.ddk.xtext.builder.layered.NullResourceDescriptionsData) AbstractResourceDescriptionsData(com.avaloq.tools.ddk.xtext.extensions.AbstractResourceDescriptionsData) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) Delta(org.eclipse.xtext.resource.IResourceDescription.Delta) DefaultResourceDescriptionDelta(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionDelta) Delta(org.eclipse.xtext.resource.IResourceDescription.Delta) SubMonitor(org.eclipse.core.runtime.SubMonitor) AbstractResourceDescriptionsData(com.avaloq.tools.ddk.xtext.extensions.AbstractResourceDescriptionsData) URI(org.eclipse.emf.common.util.URI) ResourceDescriptionChangeEvent(org.eclipse.xtext.resource.impl.ResourceDescriptionChangeEvent)

Example 3 with AbstractResourceDescriptionsData

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();
    }
}
Also used : AbstractResourceDescriptionsData(com.avaloq.tools.ddk.xtext.extensions.AbstractResourceDescriptionsData) NullResourceDescriptionsData(com.avaloq.tools.ddk.xtext.builder.layered.NullResourceDescriptionsData) ResourceDescriptionChangeEvent(org.eclipse.xtext.resource.impl.ResourceDescriptionChangeEvent)

Example 4 with AbstractResourceDescriptionsData

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();
}
Also used : IResourceDescriptionsData(com.avaloq.tools.ddk.xtext.extensions.IResourceDescriptionsData) ResourceDescriptionsData(org.eclipse.xtext.resource.impl.ResourceDescriptionsData) NullResourceDescriptionsData(com.avaloq.tools.ddk.xtext.builder.layered.NullResourceDescriptionsData) AbstractResourceDescriptionsData(com.avaloq.tools.ddk.xtext.extensions.AbstractResourceDescriptionsData) Delta(org.eclipse.xtext.resource.IResourceDescription.Delta) DefaultResourceDescriptionDelta(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionDelta) SubMonitor(org.eclipse.core.runtime.SubMonitor) AbstractResourceDescriptionsData(com.avaloq.tools.ddk.xtext.extensions.AbstractResourceDescriptionsData) ResourceDescriptionChangeEvent(org.eclipse.xtext.resource.impl.ResourceDescriptionChangeEvent)

Aggregations

AbstractResourceDescriptionsData (com.avaloq.tools.ddk.xtext.extensions.AbstractResourceDescriptionsData)4 NullResourceDescriptionsData (com.avaloq.tools.ddk.xtext.builder.layered.NullResourceDescriptionsData)3 ResourceDescriptionChangeEvent (org.eclipse.xtext.resource.impl.ResourceDescriptionChangeEvent)3 IResourceDescriptionsData (com.avaloq.tools.ddk.xtext.extensions.IResourceDescriptionsData)2 SubMonitor (org.eclipse.core.runtime.SubMonitor)2 Delta (org.eclipse.xtext.resource.IResourceDescription.Delta)2 DefaultResourceDescriptionDelta (org.eclipse.xtext.resource.impl.DefaultResourceDescriptionDelta)2 ResourceDescriptionsData (org.eclipse.xtext.resource.impl.ResourceDescriptionsData)2 ResourceDescriptions2 (com.avaloq.tools.ddk.xtext.extensions.ResourceDescriptions2)1 IResourceDescriptions2 (com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptions2)1 URI (org.eclipse.emf.common.util.URI)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1