org.eclipse.xtext.builder.IXtextBuilderParticipant Java Examples

The following examples show how to use org.eclipse.xtext.builder.IXtextBuilderParticipant. 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: N4JSGenerateImmediatelyBuilderState.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
private N4JSBuilderParticipant findJSBuilderParticipant() {
	ImmutableList<IXtextBuilderParticipant> all = builderParticipant.getParticipants();
	for (IXtextBuilderParticipant candidate : all) {
		if (candidate instanceof DeferredBuilderParticipant) {
			DeferredBuilderParticipant dbp = (DeferredBuilderParticipant) candidate;
			if (isParticipating(dbp)) {
				IXtextBuilderParticipant delegate = dbp.getDelegate();
				if (delegate instanceof N4JSBuilderParticipant) {
					return (N4JSBuilderParticipant) delegate;
				}
			}
		}
		// N4JSBuilderParticipant is never directly used, it's always delegated to via an DeferredBuilderParticipant
	}
	throw new IllegalStateException();
}
 
Example #2
Source File: RegistryBuilderParticipant.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected synchronized ImmutableList<IXtextBuilderParticipant> initParticipants() {
	ImmutableList<IXtextBuilderParticipant> result = participants;
	if (result == null) {
		if (classToParticipant == null) {
			classToParticipant = Maps.newHashMap();
			Activator activator = Activator.getDefault();
			if (activator != null) {
				String pluginID = activator.getBundle().getSymbolicName();
				String extensionPointID = EXTENSION_POINT_ID;
				BuilderParticipantReader reader = new BuilderParticipantReader(extensionRegistry, pluginID, extensionPointID);
				reader.readRegistry();
			}
		}
		result = ImmutableList.copyOf(classToParticipant.values());
		participants = result;
	}
	return result;
}
 
Example #3
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 #4
Source File: RegistryBuilderParticipant.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected boolean readElement(IConfigurationElement element, boolean add) {
	if (element.getName().equals(PARTICIPANT)) {
		String className = element.getAttribute(ATT_CLASS);
		if (className == null) {
			logMissingAttribute(element, ATT_CLASS);
		} else if (add) {
			IXtextBuilderParticipant participant = new DeferredBuilderParticipant(element);
			if (classToParticipant.containsKey(className)) {
				readerLog.warn("The builder participant '" + className + "' was registered twice."); //$NON-NLS-1$ //$NON-NLS-2$
			}
			classToParticipant.put(className, participant);
			participants = null;
			return true;
		} else {
			classToParticipant.remove(className);
			participants = null;
			return true;
		}
	}
	return false;
}
 
Example #5
Source File: N4JSBuilderParticipant.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Intentionally package visible producer for the {@link IBuildParticipantInstruction}.
 *
 * @param project
 *            the currently build project
 * @param buildType
 *            the current build type
 * @return a StatefulBuilderParticipant. Never <code>null</code>.
 */
IBuildParticipantInstruction prepareBuild(IProject project, IXtextBuilderParticipant.BuildType buildType)
		throws CoreException {

	if (!isEnabled(project)) {
		return IBuildParticipantInstruction.NOOP;
	}
	EclipseResourceFileSystemAccess2 access = fileSystemAccessProvider.get();
	access.setProject(project);
	final Map<String, OutputConfiguration> outputConfigurations = getOutputConfigurations(project);
	refreshOutputFolders(project, outputConfigurations, null);
	access.setOutputConfigurations(outputConfigurations);
	if (buildType == BuildType.CLEAN || buildType == BuildType.RECOVERY) {
		IBuildParticipantInstruction clean = new CleanInstruction(project, outputConfigurations,
				getDerivedResourceMarkers());
		if (buildType == BuildType.RECOVERY) {
			clean.finish(Collections.<Delta> emptyList(), null);
		} else {
			return clean;
		}
	}
	Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers = getGeneratorMarkers(project,
			outputConfigurations.values());
	BuildInstruction buildInstruction = new BuildInstruction(project, outputConfigurations,
			getDerivedResourceMarkers(), access,
			generatorMarkers, storage2UriMapper, compositeGenerator, injector);
	return buildInstruction;
}
 
Example #6
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();
}
 
Example #7
Source File: RegistryBuilderParticipant.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public ImmutableList<IXtextBuilderParticipant> getParticipants() {
	ImmutableList<IXtextBuilderParticipant> result = participants;
	if (participants == null) {
		result = initParticipants();
	}
	return result;
}
 
Example #8
Source File: RegistryBuilderParticipant.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
protected synchronized ImmutableList<IXtextBuilderParticipant> initParticipants() {
  if (immutableCommonParticipants == null) {
    String pluginID = "org.eclipse.xtext.builder"; //$NON-NLS-1$ // Activator.getDefault().getBundle().getSymbolicName();
    String extensionPointID = EXTENSION_POINT_ID;
    ConditionalBuilderParticipantReader reader = new ConditionalBuilderParticipantReader(extensionRegistry, pluginID, extensionPointID);
    reader.readRegistry();
    immutableCommonParticipants = reader.getCommonParticipants();
  }
  return immutableCommonParticipants;
}
 
Example #9
Source File: RegistryBuilderParticipant.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Initializes the given {@link IXtextBuilderParticipant}.
 *
 * @param participant
 *          the {@link IXtextBuilderParticipant} to initialize, must not be {@code null}
 * @return whether the builder participant was initialized successfully
 */
private boolean initializeParticipant(final IXtextBuilderParticipant participant) {
  String languageId = null;
  if (participant instanceof IGeneratorModuleProvider) {
    languageId = ((IGeneratorModuleProvider) participant).getGeneratorModuleId();
  } else if (participant instanceof ILanguageSpecificBuilderParticipant) {
    languageId = ((ILanguageSpecificBuilderParticipant) participant).getLanguageId();
  }
  if (languageId != null && !BuilderParticipantSettings.isBuilderParticipantEnabled(languageId)) {
    return false;
  }
  if (!initializedParticipants.contains(participant)) {
    if (languageId != null) {
      final IResourceServiceProvider resourceServiceProvider = resourceServiceProviderLocator.getResourceServiceProviderById(languageId);
      if (resourceServiceProvider != null) {
        // inject members of the participant
        final Injector injector = resourceServiceProvider.get(Injector.class);
        injector.injectMembers(participant);
      } else {
        LOG.error(NLS.bind("No ResourceServiceProvider found for builder participant ''{0}'' and language id ''{1}''", participant.getClass().getName(), languageId)); //$NON-NLS-1$
        return false;
      }
    }
    initializedParticipants.add(participant);
  }
  return true;
}
 
Example #10
Source File: FormatUiModule.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
  return FormatBuilderParticipant.class;
}
 
Example #11
Source File: AbstractBug462047LangUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
	return BuilderParticipant.class;
}
 
Example #12
Source File: AbstractXImportSectionTestLangUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
	return BuilderParticipant.class;
}
 
Example #13
Source File: RegistryBuilderParticipant.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
private IXtextBuilderParticipant getDelegate(IBuildContext context) {
	if (!interestedIn(context)) {
		return new NoOpBuilderParticipant();
	}
	return getDelegate();
}
 
Example #14
Source File: RegistryBuilderParticipant.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public IXtextBuilderParticipant getDelegate() {
	if (delegate == null) {
		initDelegate();
	}
	return delegate;
}
 
Example #15
Source File: AbstractXtendUiModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
	return BuilderParticipant.class;
}
 
Example #16
Source File: XtendUiModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
	return XtendParallelBuilderParticipant.class;
}
 
Example #17
Source File: AbstractHelloWorldUiModule.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
	return BuilderParticipant.class;
}
 
Example #18
Source File: DelegatingBuilderParticipant.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public IXtextBuilderParticipant getDelegate() {
	return delegate;
}
 
Example #19
Source File: RegistryBuilderParticipant.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public ImmutableList<IXtextBuilderParticipant> getParticipants() {
  return initParticipants();
}
 
Example #20
Source File: RegistryBuilderParticipant.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
protected ImmutableList<IXtextBuilderParticipant> getCommonParticipants() {
  return ImmutableList.copyOf(commonParticipants);
}
 
Example #21
Source File: AbstractGamlUiModule.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
	return BuilderParticipant.class;
}
 
Example #22
Source File: XtxtUMLUiModule.java    From txtUML with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
	return XtxtUMLBuilderParticipant.class;
}
 
Example #23
Source File: AbstractSARLUiModule.java    From sarl with Apache License 2.0 4 votes vote down vote up
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
	return BuilderParticipant.class;
}
 
Example #24
Source File: AbstractSingleCodetemplateUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
	return BuilderParticipant.class;
}
 
Example #25
Source File: N4JSUiModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Bind the {@link IXtextBuilderParticipant} being aware of generating the Javascript files in the output directory.
 */
@Override
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
	return N4JSBuilderParticipant.class;
}
 
Example #26
Source File: AbstractRegularExpressionUiModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
	return BuilderParticipant.class;
}
 
Example #27
Source File: AbstractBromiumUiModule.java    From bromium with MIT License 4 votes vote down vote up
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
	return BuilderParticipant.class;
}
 
Example #28
Source File: AbstractMyDslUiModule.java    From M2Doc with Eclipse Public License 1.0 4 votes vote down vote up
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
	return BuilderParticipant.class;
}
 
Example #29
Source File: AbstractFileAwareTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
	return BuilderParticipant.class;
}
 
Example #30
Source File: AbstractXtextGrammarTestLanguageUiModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() {
	return BuilderParticipant.class;
}