Search in sources :

Example 1 with IBuildParticipantInstruction

use of org.eclipse.n4js.ui.building.instructions.IBuildParticipantInstruction in project n4js by eclipse.

the class N4JSGenerateImmediatelyBuilderState method doUpdate.

/**
 * {@inheritDoc}
 *
 * Initializes an adapter which is attached to the builder's resource set. This adapter will be used later on to
 * process each delta after the corresponding resource was validated.
 *
 * @param buildData
 *            the data that should be considered for the update
 * @param newData
 *            the new resource descriptions as they are to be persisted (the new index after the build). Initially
 *            contains the old resource descriptions.
 * @param monitor
 *            The progress monitor
 * @return A list of deltas describing all changes made by the build.
 */
@Override
protected Collection<Delta> doUpdate(BuildData buildData, ResourceDescriptionsData newData, IProgressMonitor monitor) {
    builderStateLogger.log("N4JSGenerateImmediatelyBuilderState.doUpdate() >>>");
    logBuildData(buildData, " of before #doUpdate");
    IProject project = getProject(buildData);
    try (ClosableMeasurement m = dcBuild.getClosableMeasurement("build " + Instant.now())) {
        BuildType buildType = N4JSBuildTypeTracker.getBuildType(project);
        IBuildParticipantInstruction instruction;
        if (buildType == null) {
            instruction = IBuildParticipantInstruction.NOOP;
        } else {
            instruction = findJSBuilderParticipant().prepareBuild(project, buildType);
        }
        // removed after the build automatically;
        // the resource set is discarded afterwards, anyway
        buildData.getResourceSet().eAdapters().add(instruction);
    } catch (CoreException e) {
        handleCoreException(e);
    }
    Collection<Delta> modifiedDeltas = super.doUpdate(buildData, newData, monitor);
    logBuildData(buildData, " of after #doUpdate");
    builderStateLogger.log("Modified deltas: " + modifiedDeltas);
    builderStateLogger.log("N4JSGenerateImmediatelyBuilderState.doUpdate() <<<");
    return modifiedDeltas;
}
Also used : ClosableMeasurement(org.eclipse.n4js.smith.ClosableMeasurement) IBuildParticipantInstruction(org.eclipse.n4js.ui.building.instructions.IBuildParticipantInstruction) CoreException(org.eclipse.core.runtime.CoreException) Delta(org.eclipse.xtext.resource.IResourceDescription.Delta) DefaultResourceDescriptionDelta(org.eclipse.xtext.resource.impl.DefaultResourceDescriptionDelta) BuildType(org.eclipse.xtext.builder.IXtextBuilderParticipant.BuildType) IProject(org.eclipse.core.resources.IProject)

Example 2 with IBuildParticipantInstruction

use of org.eclipse.n4js.ui.building.instructions.IBuildParticipantInstruction in project n4js by eclipse.

the class N4JSBuilderParticipant method prepareBuild.

/**
 * 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;
}
Also used : IBuildParticipantInstruction(org.eclipse.n4js.ui.building.instructions.IBuildParticipantInstruction) EclipseResourceFileSystemAccess2(org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2) OutputConfiguration(org.eclipse.xtext.generator.OutputConfiguration) BuildInstruction(org.eclipse.n4js.ui.building.instructions.BuildInstruction) CleanInstruction(org.eclipse.n4js.ui.building.instructions.CleanInstruction)

Aggregations

IBuildParticipantInstruction (org.eclipse.n4js.ui.building.instructions.IBuildParticipantInstruction)2 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 ClosableMeasurement (org.eclipse.n4js.smith.ClosableMeasurement)1 BuildInstruction (org.eclipse.n4js.ui.building.instructions.BuildInstruction)1 CleanInstruction (org.eclipse.n4js.ui.building.instructions.CleanInstruction)1 EclipseResourceFileSystemAccess2 (org.eclipse.xtext.builder.EclipseResourceFileSystemAccess2)1 BuildType (org.eclipse.xtext.builder.IXtextBuilderParticipant.BuildType)1 OutputConfiguration (org.eclipse.xtext.generator.OutputConfiguration)1 Delta (org.eclipse.xtext.resource.IResourceDescription.Delta)1 DefaultResourceDescriptionDelta (org.eclipse.xtext.resource.impl.DefaultResourceDescriptionDelta)1