use of org.eclipse.xtext.generator.IGenerator2 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);
}
}
};
}
Aggregations