org.eclipse.xtext.builder
Interface IXtextBuilderParticipant

All Known Implementing Classes:
BuilderParticipant, JavaProjectBasedBuilderParticipant, RegistryBuilderParticipant, XtendBuilderParticipant

public interface IXtextBuilderParticipant

A builder participant allows to process resources that are built by an Eclipse incremental project builder.

A common implementation pattern is to filter the list of deltas by file extension and execute some logic on the respective resources. One main use case is to generate additional artifacts from those resources, i.e. implement a code generator.

A sample implementation may look like this:

 public void build(IBuildContext context, IProgressMonitor monitor) throws CoreException {
   for(IResourceDescription.Delta delta: context.getDeltas()) {
     Resource resource = context.getResourceSet().getResource(delta.getUri(), true);
     .. process resource here ..
   }
 }
 

Implementors should keep in mind that they share the resource set with other builder participants thus you shall not modify the state of the given resource set besides adding or removing resources. Removed resources should be unloaded properly or the resource set should be cleared.

Another important aspect is memory consumption. If you expect a very large number of resources in a single project, try to apply some clustering algorithm to the processing. The application may run out of memory otherwise.

Author:
Sebastian Zarnekow - Initial contribution and API, Sven Efftinge

Nested Class Summary
static class IXtextBuilderParticipant.BuildType
           
static interface IXtextBuilderParticipant.IBuildContext
          The build context provides information that may be used by the participant.
 
Method Summary
 void build(IXtextBuilderParticipant.IBuildContext context, org.eclipse.core.runtime.IProgressMonitor monitor)
          Allows clients to perform additional steps in the build process such as code generation.
 

Method Detail

build

void build(IXtextBuilderParticipant.IBuildContext context,
           org.eclipse.core.runtime.IProgressMonitor monitor)
           throws org.eclipse.core.runtime.CoreException
Allows clients to perform additional steps in the build process such as code generation. It is not expected that any object in the resource set will be modified by a builder participant. However, resources may be dynamically loaded or unloaded.

Parameters:
monitor - the progress monitor to use for reporting progress to the user. It is the caller's responsibility to call done() on the given monitor. Accepts null, indicating that no progress should be reported and that the operation cannot be cancelled.
Throws:
org.eclipse.core.runtime.CoreException