Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
Builder: Improve Progress Reporting #433
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerschill authored and cdietrich committed Aug 30, 2018
1 parent 954d150 commit 23b6ed8
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public void build(final IBuildContext context, IProgressMonitor monitor) throws
IProject builtProject = context.getBuiltProject();
access.setProject(builtProject);
Map<String, OutputConfiguration> outputConfigurations = getOutputConfigurations(context);
refreshOutputFolders(context, outputConfigurations, subMonitor.newChild(1));
refreshOutputFolders(context, outputConfigurations, subMonitor.split(1));
if (subMonitor.isCanceled()) {
throw new OperationCanceledException();
}
Expand Down Expand Up @@ -289,7 +289,9 @@ protected void doBuild(List<IResourceDescription.Delta> deltas,
}
if (i % 10 == 0) {
subMonitor.subTask("Compiling chunk " + (i / MONITOR_CHUNK_SIZE + 1) + " of " + (numberOfDeltas / MONITOR_CHUNK_SIZE + 1));
currentMonitor = subMonitor.newChild(1);
// SUPPRESS_ALL_LABELS as File.create and File.refreshLocal would create a task that would
// be propagated to the parent see https://github.com/eclipse/xtext-eclipse/issues/433
currentMonitor = subMonitor.split(1, SubMonitor.SUPPRESS_ALL_LABELS);
access.setMonitor(currentMonitor);
}
if (logger.isDebugEnabled()) {
Expand Down Expand Up @@ -466,13 +468,13 @@ protected void refreshOutputFolders(IBuildContext ctx, Map<String, OutputConfigu
IProgressMonitor monitor) throws CoreException {
SubMonitor subMonitor = SubMonitor.convert(monitor, outputConfigurations.size());
for (OutputConfiguration config : outputConfigurations.values()) {
SubMonitor child = subMonitor.newChild(1);
SubMonitor split = subMonitor.split(1);
final IProject project = ctx.getBuiltProject();
for (IContainer container : getOutputs(project, config)) {
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
sync(container, IResource.DEPTH_INFINITE, child);
sync(container, IResource.DEPTH_INFINITE, split);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ protected void doBuild(
try {
SubMonitor subMonitor = SubMonitor.convert(progressMonitor, 1);
subMonitor.subTask("Compiling...");
access.setMonitor(subMonitor.newChild(1));
access.setMonitor(subMonitor.split(1));

List<ListenableFuture<?>> tasks = Lists.newArrayList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public synchronized ImmutableList<IResourceDescription.Delta> update(BuildData b
throw new OperationCanceledException();

final ResourceDescriptionsData newData = getCopiedResourceDescriptionsData();
final Collection<IResourceDescription.Delta> result = doUpdate(buildData, newData, subMonitor.newChild(1));
final Collection<IResourceDescription.Delta> result = doUpdate(buildData, newData, subMonitor.split(1));

if (monitor.isCanceled())
throw new OperationCanceledException();
Expand All @@ -140,7 +140,7 @@ public synchronized ImmutableList<IResourceDescription.Delta> clean(Set<URI> toB
return ImmutableList.of();
if (monitor.isCanceled())
throw new OperationCanceledException();
Collection<IResourceDescription.Delta> deltas = doClean(toBeRemoved, subMonitor.newChild(1));
Collection<IResourceDescription.Delta> deltas = doClean(toBeRemoved, subMonitor.split(1));

final ResourceDescriptionsData newData = getCopiedResourceDescriptionsData();
if (monitor.isCanceled())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected Collection<Delta> doUpdate(BuildData buildData, ResourceDescriptionsDa
installSourceLevelURIs(buildData);
// Step 3: Create a queue; write new temporary resource descriptions for the added or updated resources so that we can link
// subsequently; put all the added or updated resources into the queue.
writeNewResourceDescriptions(buildData, this, newState, progress.newChild(20));
writeNewResourceDescriptions(buildData, this, newState, progress.split(20));

if (progress.isCanceled()) {
throw new OperationCanceledException();
Expand Down Expand Up @@ -169,7 +169,7 @@ protected Collection<Delta> doUpdate(BuildData buildData, ResourceDescriptionsDa
// Add all pending deltas to all deltas (may be scheduled java deltas)
Collection<Delta> pendingDeltas = buildData.getAndRemovePendingDeltas();
allDeltas.addAll(pendingDeltas);
queueAffectedResources(allRemainingURIs, this, newState, allDeltas, allDeltas, buildData, progress.newChild(1));
queueAffectedResources(allRemainingURIs, this, newState, allDeltas, allDeltas, buildData, progress.split(1));
installSourceLevelURIs(buildData);

IProject currentProject = getBuiltProject(buildData);
Expand All @@ -182,7 +182,7 @@ protected Collection<Delta> doUpdate(BuildData buildData, ResourceDescriptionsDa

// Step 6: Iteratively got through the queue. For each resource, create a new resource description and queue all depending
// resources that are not yet in the delta. Validate resources. Do this in chunks.
final SubMonitor subProgress = progress.newChild(80);
final SubMonitor subProgress = progress.split(80);
CancelIndicator cancelMonitor = new MonitorBasedCancelIndicator(progress);

int index = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void build(IBuildContext buildContext, IProgressMonitor monitor) throws C
for (IXtextBuilderParticipant participant : participants) {
if (progress.isCanceled())
throw new OperationCanceledException();
participant.build(buildContext, progress.newChild(1));
participant.build(buildContext, progress.split(1));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ protected ToBeBuilt doRemoveProject(IProject project, IProgressMonitor monitor)
public ToBeBuilt updateProjectNewResourcesOnly(IProject project, IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, Messages.ToBeBuiltComputer_CollectingResources, 1);
progress.subTask(Messages.ToBeBuiltComputer_CollectingResources);
ToBeBuilt toBeBuilt = updateProject(project, progress.newChild(1));
ToBeBuilt toBeBuilt = updateProject(project, progress.split(1));
Iterable<URI> existingURIs = Iterables.transform(builderState.getAllResourceDescriptions(),
new Function<IResourceDescription, URI>() {
@Override
Expand All @@ -245,12 +245,12 @@ public ToBeBuilt updateProject(IProject project, IProgressMonitor monitor) throw
final SubMonitor progress = SubMonitor.convert(monitor, Messages.ToBeBuiltComputer_CollectingResources, 10);
progress.subTask(Messages.ToBeBuiltComputer_CollectingResources);

final ToBeBuilt toBeBuilt = doRemoveProject(project, progress.newChild(8));
final ToBeBuilt toBeBuilt = doRemoveProject(project, progress.split(8));
if (!project.isAccessible())
return toBeBuilt;
if (progress.isCanceled())
throw new OperationCanceledException();
final SubMonitor childMonitor = progress.newChild(1);
final SubMonitor childMonitor = progress.split(1);
project.accept(new IResourceVisitor() {
@Override
public boolean visit(IResource resource) throws CoreException {
Expand All @@ -267,7 +267,7 @@ public boolean visit(IResource resource) throws CoreException {
});
if (progress.isCanceled())
throw new OperationCanceledException();
contribution.updateProject(toBeBuilt, project, progress.newChild(1));
contribution.updateProject(toBeBuilt, project, progress.split(1));
return toBeBuilt;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ public boolean isCanceled() {
}
SubMonitor progress = SubMonitor.convert(monitor, 1);
if (kind == FULL_BUILD) {
fullBuild(progress.newChild(1), IBuildFlag.RECOVERY_BUILD.isSet(args));
fullBuild(progress.split(1), IBuildFlag.RECOVERY_BUILD.isSet(args));
} else {
IResourceDelta delta = getDelta(getProject());
if (delta == null || isOpened(delta)) {
fullBuild(progress.newChild(1), IBuildFlag.RECOVERY_BUILD.isSet(args));
fullBuild(progress.split(1), IBuildFlag.RECOVERY_BUILD.isSet(args));
} else {
incrementalBuild(delta, progress.newChild(1));
incrementalBuild(delta, progress.split(1));
}
}
} catch (CoreException e) {
Expand Down Expand Up @@ -265,7 +265,7 @@ public boolean visit(IResourceDelta delta) throws CoreException {
if (progress.isCanceled())
throw new OperationCanceledException();
progress.worked(2);
doBuild(toBeBuilt, progress.newChild(8), BuildType.INCREMENTAL);
doBuild(toBeBuilt, progress.split(8), BuildType.INCREMENTAL);
}

/**
Expand All @@ -285,12 +285,12 @@ protected void doBuild(ToBeBuilt toBeBuilt, IProgressMonitor monitor, BuildType
ResourceSet resourceSet = getResourceSetProvider().get(getProject());
resourceSet.getLoadOptions().put(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE, Boolean.TRUE);
BuildData buildData = new BuildData(getProject().getName(), resourceSet, toBeBuilt, queuedBuildData, indexingOnly);
ImmutableList<Delta> deltas = builderState.update(buildData, progress.newChild(1));
ImmutableList<Delta> deltas = builderState.update(buildData, progress.split(1));
if (participant != null && !indexingOnly) {
SourceLevelURICache sourceLevelURIs = buildData.getSourceLevelURICache();
Set<URI> sources = sourceLevelURIs.getSources();
participant.build(new BuildContext(this, resourceSet, deltas, sources, type),
progress.newChild(1));
progress.split(1));
try {
getProject().getWorkspace().checkpoint(false);
} catch(NoClassDefFoundError e) { // guard against broken Eclipse installations / bogus project configuration
Expand Down Expand Up @@ -318,9 +318,9 @@ protected void fullBuild(final IProgressMonitor monitor, boolean isRecoveryBuild
IProject project = getProject();
ToBeBuilt toBeBuilt =
isRecoveryBuild
? toBeBuiltComputer.updateProjectNewResourcesOnly(project, progress.newChild(2))
: toBeBuiltComputer.updateProject(project, progress.newChild(2));
doBuild(toBeBuilt, progress.newChild(8),
? toBeBuiltComputer.updateProjectNewResourcesOnly(project, progress.split(2))
: toBeBuiltComputer.updateProject(project, progress.split(2));
doBuild(toBeBuilt, progress.split(8),
isRecoveryBuild
? BuildType.RECOVERY
: BuildType.FULL);
Expand All @@ -341,11 +341,11 @@ protected boolean isOpened(IResourceDelta delta) {
protected void clean(IProgressMonitor monitor) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, 10);
try {
ToBeBuilt toBeBuilt = toBeBuiltComputer.removeProject(getProject(), progress.newChild(2));
ToBeBuilt toBeBuilt = toBeBuiltComputer.removeProject(getProject(), progress.split(2));
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
doClean(toBeBuilt, progress.newChild(8));
doClean(toBeBuilt, progress.split(8));
} finally {
if (monitor != null)
monitor.done();
Expand All @@ -359,7 +359,7 @@ protected void clean(IProgressMonitor monitor) throws CoreException {
*/
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));
ImmutableList<Delta> deltas = builderState.clean(toBeBuilt.getToBeDeleted(), progress.split(1));
if (participant != null) {
Set<URI> sourceURIs = new SourceLevelURICache().getSourcesFrom(toBeBuilt.getToBeDeleted(), resourceServiceProvideRegistry);

Expand All @@ -368,7 +368,7 @@ protected void doClean(ToBeBuilt toBeBuilt, IProgressMonitor monitor) throws Cor
deltas,
sourceURIs,
BuildType.CLEAN),
progress.newChild(1));
progress.split(1));
} else {
progress.worked(1);
}
Expand Down

0 comments on commit 23b6ed8

Please sign in to comment.