use of org.eclipse.xtext.resource.IResourceDescription.Delta in project xtext-eclipse by eclipse.
the class XtextBuilder method doClean.
/**
* @param monitor the progress monitor to use for reporting progress to the user. It is the caller's responsibility
* to call done() on the given monitor. Accepts null, indicating that no progress should be
* reported and that the operation cannot be cancelled.
*/
protected void doClean(ToBeBuilt toBeBuilt, IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, 2);
ImmutableList<Delta> deltas = builderState.clean(toBeBuilt.getToBeDeleted(), progress.newChild(1));
if (participant != null) {
Set<URI> sourceURIs = new SourceLevelURICache().getSourcesFrom(toBeBuilt.getToBeDeleted(), resourceServiceProvideRegistry);
participant.build(new BuildContext(this, getResourceSetProvider().get(getProject()), deltas, sourceURIs, BuildType.CLEAN), progress.newChild(1));
} else {
progress.worked(1);
}
}
use of org.eclipse.xtext.resource.IResourceDescription.Delta in project n4js by eclipse.
the class N4JSGenerateImmediatelyBuilderState method doUpdate.
/**
* {@inheritDoc}
*
* Initializes an adapter which is attached to the builder's resource set. This adapter will be used later on to
* process each delta after the corresponding resource was validated.
*
* @param buildData
* the data that should be considered for the update
* @param newData
* the new resource descriptions as they are to be persisted (the new index after the build). Initially
* contains the old resource descriptions.
* @param monitor
* The progress monitor
* @return A list of deltas describing all changes made by the build.
*/
@Override
protected Collection<Delta> doUpdate(BuildData buildData, ResourceDescriptionsData newData, IProgressMonitor monitor) {
builderStateLogger.log("N4JSGenerateImmediatelyBuilderState.doUpdate() >>>");
logBuildData(buildData, " of before #doUpdate");
IProject project = getProject(buildData);
try (ClosableMeasurement m = dcBuild.getClosableMeasurement("build " + Instant.now())) {
BuildType buildType = N4JSBuildTypeTracker.getBuildType(project);
IBuildParticipantInstruction instruction;
if (buildType == null) {
instruction = IBuildParticipantInstruction.NOOP;
} else {
instruction = findJSBuilderParticipant().prepareBuild(project, buildType);
}
// removed after the build automatically;
// the resource set is discarded afterwards, anyway
buildData.getResourceSet().eAdapters().add(instruction);
} catch (CoreException e) {
handleCoreException(e);
}
Collection<Delta> modifiedDeltas = super.doUpdate(buildData, newData, monitor);
logBuildData(buildData, " of after #doUpdate");
builderStateLogger.log("Modified deltas: " + modifiedDeltas);
builderStateLogger.log("N4JSGenerateImmediatelyBuilderState.doUpdate() <<<");
return modifiedDeltas;
}
use of org.eclipse.xtext.resource.IResourceDescription.Delta in project n4js by eclipse.
the class BuildInstruction method finish.
@Override
public void finish(List<Delta> deltas, IProgressMonitor progressMonitor) throws CoreException {
for (Delta delta : deltas) {
if (delta.getNew() == null) {
String uri = delta.getUri().toString();
recordDerivedResources(uri);
deleteObsoleteResources(uri, progressMonitor);
}
}
deleteEmptyDirectories(progressMonitor);
}
use of org.eclipse.xtext.resource.IResourceDescription.Delta 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 org.eclipse.xtext.resource.IResourceDescription.Delta 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