/** @since 2.7 */ protected void doBuild( List<IResourceDescription.Delta> deltas, Map<String, OutputConfiguration> outputConfigurations, Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers, IBuildContext context, EclipseResourceFileSystemAccess2 access, IProgressMonitor progressMonitor) throws CoreException { final int numberOfDeltas = deltas.size(); SubMonitor subMonitor = SubMonitor.convert(progressMonitor, numberOfDeltas / MONITOR_CHUNK_SIZE + 1); SubMonitor currentMonitor = null; int clusterIndex = 0; for (int i = 0; i < numberOfDeltas; i++) { IResourceDescription.Delta delta = deltas.get(i); if (subMonitor.isCanceled()) { throw new OperationCanceledException(); } if (i % 10 == 0) { subMonitor.subTask( "Compiling chunk " + (i / MONITOR_CHUNK_SIZE + 1) + " of " + (numberOfDeltas / MONITOR_CHUNK_SIZE + 1)); currentMonitor = subMonitor.newChild(1); access.setMonitor(currentMonitor); } if (logger.isDebugEnabled()) { logger.debug("Compiling " + delta.getUri() + " (" + i + " of " + numberOfDeltas + ")"); } if (delta.getNew() != null && !clusteringPolicy.continueProcessing( context.getResourceSet(), delta.getUri(), clusterIndex)) { clearResourceSet(context.getResourceSet()); clusterIndex = 0; } Set<IFile> derivedResources = getDerivedResources(delta, outputConfigurations, generatorMarkers); access.setPostProcessor(getPostProcessor(delta, context, derivedResources)); if (doGenerate(delta, context, access)) { clusterIndex++; access.flushSourceTraces(); } cleanDerivedResources(delta, derivedResources, context, access, currentMonitor); } }
protected void handleChangedContents( Delta delta, IBuildContext context, EclipseResourceFileSystemAccess2 fileSystemAccess) throws CoreException { // TODO: we will run out of memory here if the number of deltas is large enough Resource resource = context.getResourceSet().getResource(delta.getUri(), true); if (shouldGenerate(resource, context)) { try { generator.doGenerate(resource, fileSystemAccess); } catch (RuntimeException e) { if (e.getCause() instanceof CoreException) { throw (CoreException) e.getCause(); } throw e; } } }
@Override public void build(IBuildContext context, IProgressMonitor monitor) throws CoreException { if (!context.getBuiltProject().hasNature(KarelNature.NATURE_ID)) return; for (Delta delta : context.getDeltas()) { IResourceDescription newRes = delta.getNew(); if (newRes == null) continue; try { IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); URI uri = CommonPlugin.resolve(newRes.getURI()); if (!uri.isFile()) continue; IPath path = new Path(uri.toFileString()); IFile file = workspaceRoot.getFileForLocation(path); if (file == null) continue; generate(context.getBuiltProject(), file, monitor); } catch (Exception e) { IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); Activator.getDefault().getLog().log(status); } } context.getResourceSet(); }