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(); }
/** * 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); } } }
/** * 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; }
/** * 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; }
/** {@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; }
public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() { return BuilderParticipant.class; }
/** * Bind the {@link IXtextBuilderParticipant} being aware of generating the Javascript files in the output directory. */ @Override public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() { return N4JSBuilderParticipant.class; }
/** * {@inheritDoc} */ @Override public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() { return FormatBuilderParticipant.class; }
/** {@inheritDoc} */ @Override public ImmutableList<IXtextBuilderParticipant> getParticipants() { return initParticipants(); }
protected ImmutableList<IXtextBuilderParticipant> getCommonParticipants() { return ImmutableList.copyOf(commonParticipants); }
@Override public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() { return XtxtUMLBuilderParticipant.class; }
@Override public Class<? extends IXtextBuilderParticipant> bindIXtextBuilderParticipant() { return DialogScriptBuilderParticipant.class; }