use of org.eclipse.xtext.resource.IResourceDescription.Delta in project xtext-eclipse by eclipse.
the class ParallelBuilderParticipant method createRunnable.
/**
* @since 2.9
*/
protected Runnable createRunnable(final ParallelBuildContext buildContext) {
final IGenerator2 generator = getGenerator2();
final Resource resource = buildContext.resource;
if (resource != null) {
generator.beforeGenerate(resource, buildContext.synchronousFileSystemAccess, buildContext.getGeneratorContext());
buildContext.afterGenerateQueue.add(buildContext);
}
return new Runnable() {
@Override
public void run() {
Delta delta = buildContext.delta;
try {
Set<IFile> derivedResources = getDerivedResources(delta, buildContext.outputConfigurations, buildContext.generatorMarkers);
FileSystemAccessQueue fileSystemAccessQueue = buildContext.fileSystemAccessQueue;
IFileSystemAccess2 fsa = getParallelFileSystemAccess(delta, buildContext, derivedResources, fileSystemAccessQueue, buildContext.synchronousFileSystemAccess);
boolean generated = doGenerate(delta, buildContext, fsa);
final Runnable derivedResourceCallback = getFlushAndCleanDerivedResourcesCallback(buildContext, derivedResources, generated);
fileSystemAccessQueue.sendAsync(delta.getUri(), new Runnable() {
@Override
public void run() {
try {
derivedResourceCallback.run();
} finally {
if (resource != null) {
generator.afterGenerate(resource, buildContext.synchronousFileSystemAccess, buildContext.getGeneratorContext());
buildContext.afterGenerateQueue.remove(buildContext);
}
}
}
});
} catch (OperationCanceledException e) {
// do nothing
} catch (Throwable e) {
addMarkerAndLogError(delta.getUri(), e);
}
}
};
}
use of org.eclipse.xtext.resource.IResourceDescription.Delta in project xtext-eclipse by eclipse.
the class BuilderParticipant method doBuild.
/**
* @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);
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();
}
currentMonitor = subMonitor.split(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);
}
}
use of org.eclipse.xtext.resource.IResourceDescription.Delta in project xtext-eclipse by eclipse.
the class PersistableResourceDescriptionsTest method update.
private Map<URI, IResourceDescription.Delta> update(Set<URI> toBeUpdated, Set<URI> toBeDeleted) {
ResourceSet resourceSet = createResourceSet();
try {
ToBeBuilt toBeBuilt = new ToBeBuilt();
if (toBeDeleted != null)
toBeBuilt.getToBeDeleted().addAll(toBeDeleted);
if (toBeUpdated != null)
toBeBuilt.getToBeUpdated().addAll(toBeUpdated);
BuildData buildData = new BuildData("", resourceSet, toBeBuilt, builderInjector.getInstance(QueuedBuildData.class));
ImmutableList<Delta> update = builderState.update(buildData, new NullProgressMonitor());
return Maps.uniqueIndex(update, new Function<IResourceDescription.Delta, URI>() {
@Override
public URI apply(IResourceDescription.Delta from) {
return from.getUri();
}
});
} finally {
resourceSet.getResources().clear();
}
}
use of org.eclipse.xtext.resource.IResourceDescription.Delta in project xtext-eclipse by eclipse.
the class Bug486584Test method testNoFullBuildIfAttachmentChangeOnly.
@Test
public void testNoFullBuildIfAttachmentChangeOnly() throws CoreException, InterruptedException {
IJavaProject project = setupProject();
assertFalse(getEvents().isEmpty());
getEvents().clear();
IFile libaryFile = copyAndGetXtendExampleJar(project);
IClasspathEntry libraryEntry = JavaCore.newLibraryEntry(libaryFile.getFullPath(), null, null);
addToClasspath(project, libraryEntry);
build();
assertEquals(1, getEvents().size());
Event singleEvent = getEvents().get(0);
ImmutableList<Delta> deltas = singleEvent.getDeltas();
assertEquals(1, deltas.size());
getEvents().clear();
IClasspathEntry[] classpath = project.getRawClasspath();
for (int i = 0; i < classpath.length; ++i) {
IPath entryPath = classpath[i].getPath();
if (libraryEntry.getPath().equals(entryPath)) {
IClasspathEntry[] newClasspath = new IClasspathEntry[classpath.length];
System.arraycopy(classpath, 0, newClasspath, 0, classpath.length);
classpath[i] = JavaCore.newLibraryEntry(libaryFile.getFullPath(), libaryFile.getFullPath(), null);
project.setRawClasspath(classpath, null);
}
}
build();
assertEquals(0, getEvents().size());
}
use of org.eclipse.xtext.resource.IResourceDescription.Delta in project xtext-eclipse by eclipse.
the class Bug486584Test method testFullBuildWhenClasspathChanged_1.
@Test
public void testFullBuildWhenClasspathChanged_1() throws CoreException, InterruptedException {
IJavaProject project = setupProject();
assertFalse(getEvents().isEmpty());
getEvents().clear();
IFile libaryFile = copyAndGetXtendExampleJar(project);
IClasspathEntry libraryEntry = JavaCore.newLibraryEntry(libaryFile.getFullPath(), null, null);
addToClasspath(project, libraryEntry);
assertEquals(1, getEvents().size());
Event singleEvent = getEvents().get(0);
ImmutableList<Delta> deltas = singleEvent.getDeltas();
assertEquals(1, deltas.size());
}
Aggregations