Java Code Examples for org.eclipse.xtext.builder.IXtextBuilderParticipant#build()

The following examples show how to use org.eclipse.xtext.builder.IXtextBuilderParticipant#build() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegistryBuilderParticipant.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Builds all other registered (non-language specific) {@link IXtextBuilderParticipant}s.
 *
 * @param buildContext
 *          the {@link IBuildContext}, must not be {@code null}
 * @param monitor
 *          the {@link IProgressMonitor}, must not be {@code null}
 * @throws CoreException
 *           caused by an {@link IXtextBuilderParticipant}
 */
protected void buildOtherParticipants(final IBuildContext buildContext, final IProgressMonitor monitor) throws CoreException {
  ImmutableList<IXtextBuilderParticipant> otherBuilderParticipants = getParticipants();
  if (otherBuilderParticipants.isEmpty()) {
    return;
  }
  SubMonitor progress = SubMonitor.convert(monitor, otherBuilderParticipants.size());
  progress.subTask(Messages.RegistryBuilderParticipant_InvokingBuildParticipants);
  for (final IXtextBuilderParticipant participant : otherBuilderParticipants) {
    if (progress.isCanceled()) {
      throw new OperationCanceledException();
    }
    try {
      if (initializeParticipant(participant)) {
        participant.build(buildContext, progress.newChild(1));
      }
      // CHECKSTYLE:CHECK-OFF IllegalCatchCheck we need to recover from any exception and continue the build
    } catch (Throwable throwable) {
      // CHECKSTYLE:CHECK-ON IllegalCatchCheck
      LOG.error("Error occurred during build of builder participant: " //$NON-NLS-1$
          + participant.getClass().getName(), throwable);
    }
  }
}
 
Example 2
Source File: RegistryBuilderParticipant.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void build(IBuildContext buildContext, IProgressMonitor monitor) throws CoreException {
	ImmutableList<IXtextBuilderParticipant> participants = getParticipants();
	if (participants.isEmpty())
		return;
	SubMonitor progress = SubMonitor.convert(monitor, participants.size());
	progress.subTask(Messages.RegistryBuilderParticipant_InvokingBuildParticipants);
	for (IXtextBuilderParticipant participant : participants) {
		if (progress.isCanceled())
			throw new OperationCanceledException();
		participant.build(buildContext, progress.split(1));
	}
	if (progress.isCanceled())
		throw new OperationCanceledException();
}