use of org.eclipse.n4js.utils.Cancelable in project n4js by eclipse.
the class ExternalLibrariesReloadHelper method reloadLibrariesInternal.
private void reloadLibrariesInternal(final boolean refreshNpmDefinitions, final IProgressMonitor monitor) throws InvocationTargetException {
final SubMonitor subMonitor = SubMonitor.convert(monitor, refreshNpmDefinitions ? 2 : 1);
if (monitor instanceof Cancelable) {
// No cancel is allowed from now on.
((Cancelable) monitor).setCancelable(false);
}
if (monitor.isCanceled()) {
return;
}
// Refresh the type definitions for the npm packages if required.
if (refreshNpmDefinitions) {
final IStatus refreshStatus = npmManager.refreshInstalledNpmPackages(subMonitor.newChild(1));
if (!refreshStatus.isOK()) {
throw new InvocationTargetException(new CoreException(refreshStatus));
}
}
// Make sure to rebuild only those external ones that are not in the workspace.
// Get all accessible workspace projects...
final Collection<String> workspaceProjectNames = from(asList(getWorkspace().getRoot().getProjects())).filter(p -> p.isAccessible()).transform(p -> p.getName()).toSet();
// And build all those externals that has no corresponding workspace project.
final Collection<N4JSExternalProject> toBuild = from(projectProvider.getProjects()).filter(p -> !workspaceProjectNames.contains(p.getName())).toList();
final Collection<IProject> workspaceProjectsToRebuild = collector.getWSProjectsDependendingOn(toBuild);
builderHelper.build(toBuild, subMonitor.newChild(1));
scheduler.scheduleBuildIfNecessary(workspaceProjectsToRebuild);
}
Aggregations