org.eclipse.xtext.builder.IXtextBuilderParticipant.BuildType Java Examples
The following examples show how to use
org.eclipse.xtext.builder.IXtextBuilderParticipant.BuildType.
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: N4JSBuildTypeTrackingBuilder.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override protected void doBuild(ToBeBuilt toBeBuilt, Set<String> removedProjects, IProgressMonitor monitor, BuildType type) throws CoreException, OperationCanceledException { // if we built it, we don't have to treat it as deleted first toBeBuilt.getToBeDeleted().removeAll(toBeBuilt.getToBeUpdated()); OutdatedPackageJsonQueue.Task task = outdatedPackageJsonQueue.exhaust(); try { if (!task.isEmpty()) { externalIndexSynchronizer.checkAndClearIndex(monitor); } toBeBuilt.getToBeDeleted().addAll(task.getToBeBuilt().getToBeDeleted()); toBeBuilt.getToBeUpdated().addAll(task.getToBeBuilt().getToBeUpdated()); RaceDetectionHelper.log("%s", toBeBuilt); runWithBuildType(monitor, type, (m) -> superDoBuild(toBeBuilt, removedProjects, m, type)); } catch (Exception e) { task.reschedule(); throw e; } }
Example #2
Source File: N4JSBuildTypeTrackingBuilder.java From n4js with Eclipse Public License 1.0 | 6 votes |
private void superDoBuild(ToBeBuilt toBeBuilt, Set<String> removedProjects, IProgressMonitor monitor, BuildType type) { // return early if there's nothing to do. // we reuse the isEmpty() impl from BuildData assuming that it doesnT access the ResourceSet which is still null // and would be expensive to create. boolean indexingOnly = type == BuildType.RECOVERY; QueuedBuildData queuedBuildData = getQueuedBuildData(); if (isNoop(toBeBuilt, queuedBuildData, indexingOnly)) return; SubMonitor progress = toBuilderMonitor(monitor, 1); IProject project = getProject(); ResourceSet resourceSet = createResourceSet(project); BuildData buildData = new BuildData(getProject().getName(), resourceSet, toBeBuilt, queuedBuildData, indexingOnly, this::needRebuild, removedProjects); getBuilderState().update(buildData, progress.split(1, SubMonitor.SUPPRESS_NONE)); if (!indexingOnly) { try { project.getWorkspace().checkpoint(false); } catch (NoClassDefFoundError e) { // guard against broken Eclipse installations / bogus project // configuration throw new RuntimeException(e); } } }
Example #3
Source File: XtextBuilder.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * @param 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. */ protected void incrementalBuild(IResourceDelta delta, final IProgressMonitor monitor) throws CoreException { final SubMonitor progress = SubMonitor.convert(monitor, Messages.XtextBuilder_CollectingResources, 10); progress.subTask(Messages.XtextBuilder_CollectingResources); pollQueuedBuildData(); final ToBeBuilt toBeBuilt = new ToBeBuilt(); IResourceDeltaVisitor visitor = createDeltaVisitor(toBeBuiltComputer, toBeBuilt, progress); delta.accept(visitor); if (progress.isCanceled()) { throw new OperationCanceledException(); } progress.worked(2); Task task = closedProjectsQueue.exhaust(); try { addInfosFromTaskAndBuild(task, toBeBuilt, BuildType.INCREMENTAL, progress.split(8)); } catch(Exception e) { task.reschedule(); throw e; } }
Example #4
Source File: XtextBuilder.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * @since 2.18 */ protected void addInfosFromTaskAndBuild(Task task, ToBeBuilt toBeBuilt, BuildType buildType, IProgressMonitor monitor) throws CoreException { addInfosFromTask(task, toBeBuilt); if (XtextBuilder.class.equals(getClass())) { doBuild(toBeBuilt, task.getProjectNames(), monitor, buildType); } else { if (mustCallDeprecatedDoBuild == null) { mustCallDeprecatedDoBuild = isDoBuildSpecialized(getClass()); if (mustCallDeprecatedDoBuild.booleanValue() && !wasDeprecationWarningLoggedForBuild) { log.warn("XtextBuilder is specialized and overrides the deprecated method doBuild(..). The implementation should be adjusted."); wasDeprecationWarningLoggedForBuild = true; } } if (mustCallDeprecatedDoBuild.booleanValue()) { doBuild(toBeBuilt, monitor, buildType); } else { doBuild(toBeBuilt, task.getProjectNames(), monitor, buildType); } } }
Example #5
Source File: XtextBuilder.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * * @param toBeBuilt the collected URIs that should be handled by this clean operation. * @param removedProjects additional projects that were available but do no longer have the Xtext nature or have been deleted * * @param 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. */ protected void doClean(ToBeBuilt toBeBuilt, Set<String> removedProjects, IProgressMonitor monitor) throws CoreException { SubMonitor progress = SubMonitor.convert(monitor, 2); SetWithProjectNames toBeDeletedAndProjects = new SetWithProjectNames(toBeBuilt.getToBeDeleted(), getProject().getName(), removedProjects); ImmutableList<Delta> deltas = builderState.clean(toBeDeletedAndProjects, progress.split(1)); if (participant != null) { Set<URI> sourceURIs = new SourceLevelURICache().getSourcesFrom(toBeBuilt.getToBeDeleted(), resourceServiceProvideRegistry); participant.build(new BuildContext(this, getResourceSetProvider().get(getProject()), deltas, sourceURIs, BuildType.CLEAN), progress.split(1)); } else { progress.worked(1); } }
Example #6
Source File: XtextBuilder.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * @param 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. */ protected void fullBuild(final IProgressMonitor monitor, boolean isRecoveryBuild) throws CoreException { SubMonitor progress = SubMonitor.convert(monitor, 10); pollQueuedBuildData(); IProject project = getProject(); ToBeBuilt toBeBuilt = isRecoveryBuild ? toBeBuiltComputer.updateProjectNewResourcesOnly(project, progress.split(2)) : toBeBuiltComputer.updateProject(project, progress.split(2)); Task task = closedProjectsQueue.exhaust(); try { addInfosFromTaskAndBuild(task, toBeBuilt, isRecoveryBuild ? BuildType.RECOVERY : BuildType.FULL, progress.split(8)); } catch(Exception e) { task.reschedule(); throw e; } }
Example #7
Source File: N4JSGenerateImmediatelyBuilderState.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * {@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() >>>"); monitor.subTask("Building " + buildData.getProjectName()); logBuildData(buildData, " of before #doUpdate"); try (Measurement m = N4JSDataCollectors.dcBuild.getMeasurement()) { try { IBuildParticipantInstruction instruction = IBuildParticipantInstruction.NOOP; IProject project = findProject(buildData); if (project != null) { BuildType buildType = N4JSBuildTypeTracker.getBuildType(project); 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; } }
Example #8
Source File: N4JSBuildTypeTrackingBuilder.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override protected void doClean(ToBeBuilt toBeBuilt, Set<String> removedProjects, IProgressMonitor monitor) throws CoreException { IProject project = getProject(); projectsStateHelper.clearProjectCache(project); runWithBuildType(monitor, BuildType.CLEAN, (m) -> super.doClean(toBeBuilt, removedProjects, m)); }
Example #9
Source File: RebuildingXtextBuilder.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override protected void fullBuild(final IProgressMonitor monitor, final boolean isRecoveryBuild) throws CoreException { SubMonitor progress = SubMonitor.convert(monitor, 2); IProject project = getProject(); ToBeBuilt toBeBuilt = isRecoveryBuild ? getToBeBuiltComputer().updateProjectNewResourcesOnly(project, progress.newChild(1)) : getToBeBuiltComputer().updateProject(project, progress.newChild(1)); doBuild(toBeBuilt, progress.newChild(1), isRecoveryBuild ? BuildType.RECOVERY : BuildType.FULL); }
Example #10
Source File: BuildContext.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
public BuildContext(XtextBuilder builder, ResourceSet resourceSet, List<Delta> deltas, Set<URI> sourceLevelURIs, BuildType type) { super(); this.builder = builder; this.resourceSet = resourceSet; this.deltas = deltas; this.sourceLevelURIs = sourceLevelURIs; this.type = type; }
Example #11
Source File: XtextBuilder.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @param toBeBuilt * the URIs that will be processed in this build run. * @param removedProjects * the projects that are no longer considered by XtextBuilders but are yet to be removed from the index. * @param monitor * the progress monitor for the build. * @param type * indicates the kind of build that is running. * * @since 2.18 */ protected void doBuild(ToBeBuilt toBeBuilt, Set<String> removedProjects, IProgressMonitor monitor, BuildType type) throws CoreException { buildLogger.log("Building " + getProject().getName()); // return early if there's nothing to do. // we reuse the isEmpty() impl from BuildData assuming that it doesnT access the ResourceSet which is still null // and would be expensive to create. boolean indexingOnly = type == BuildType.RECOVERY; if (new BuildData(getProject().getName(), null, toBeBuilt, queuedBuildData, indexingOnly, this::needRebuild, removedProjects).isEmpty()) return; SubMonitor progress = SubMonitor.convert(monitor, 2); ResourceSet resourceSet = getResourceSetProvider().get(getProject()); resourceSet.getLoadOptions().put(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE, Boolean.TRUE); BuildData buildData = new BuildData(getProject().getName(), resourceSet, toBeBuilt, queuedBuildData, indexingOnly, this::needRebuild, removedProjects); ImmutableList<Delta> deltas = builderState.update(buildData, progress.split(1)); if (participant != null && !indexingOnly) { SourceLevelURICache sourceLevelURIs = buildData.getSourceLevelURICache(); Set<URI> sources = sourceLevelURIs.getSources(); participant.build(new BuildContext(this, resourceSet, deltas, sources, type), progress.split(1)); try { getProject().getWorkspace().checkpoint(false); } catch(NoClassDefFoundError e) { // guard against broken Eclipse installations / bogus project configuration log.error(e.getMessage(), e); } } else { progress.worked(1); } resourceSet.eSetDeliver(false); for (Resource resource : resourceSet.getResources()) { resource.eSetDeliver(false); } resourceSet.getResources().clear(); resourceSet.eAdapters().clear(); }
Example #12
Source File: RebuildingXtextBuilder.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
/** * Like the super implementation, except the build is not triggered if * both toBeDeleted and toBeUpdated are empty. {@inheritDoc} */ @SuppressWarnings("nls") @Override protected void doBuild(final ToBeBuilt toBeBuilt, final IProgressMonitor monitor, final BuildType type) throws CoreException { if (toBeBuilt.getToBeDeleted().size() != 0 || toBeBuilt.getToBeUpdated().size() != 0) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Starting " + type.name() + " build:" + "\ndeleted(" + toBeBuilt.getToBeDeleted().size() + ")=" + toBeBuilt.getToBeDeleted().toString() + "\nupdated(" + toBeBuilt.getToBeUpdated().size() + ")=" + toBeBuilt.getToBeUpdated().toString()); } SubMonitor progress = SubMonitor.convert(monitor, 1 + 1 + 1); // build + participant + rebuild ResourceSet resourceSet = getResourceSetProvider().get(getProject()); resourceSet.getLoadOptions().put(ResourceDescriptionsProvider.NAMED_BUILDER_SCOPE, Boolean.TRUE); if (resourceSet instanceof ResourceSetImpl && ((ResourceSetImpl) resourceSet).getURIResourceMap() == null) { ((ResourceSetImpl) resourceSet).setURIResourceMap(Maps.<URI, Resource> newHashMap()); } BuildData buildData = new BuildData(getProject().getName(), resourceSet, toBeBuilt, queuedBuildData); ImmutableList<Delta> deltas = builderState.update(buildData, progress.newChild(1)); if (participant != null) { final BuildContext buildContext = new BuildContext(this, resourceSet, deltas, type); // remember the current workspace tree final ElementTree oldTree = ((Workspace) ResourcesPlugin.getWorkspace()).getElementTree(); oldTree.immutable(); participant.build(buildContext, progress.newChild(1)); if (buildContext.isRebuildRequired() && rebuilds++ <= 2) { final ElementTree newTree = ((Workspace) ResourcesPlugin.getWorkspace()).getElementTree(); newTree.immutable(); final ResourceDelta generatedDelta = ResourceDeltaFactory.computeDelta((Workspace) ResourcesPlugin.getWorkspace(), oldTree, newTree, getProject().getFullPath(), -1); // rebuild the generated delta ResourcesPlugin.getWorkspace().checkpoint(false); incrementalBuild(generatedDelta, progress.newChild(1)); } } else { progress.worked(2); } resourceSet.getResources().clear(); resourceSet.eAdapters().clear(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Build done."); } } else if (LOGGER.isDebugEnabled()) { LOGGER.debug("Ignoring empty " + type.name() + " build."); } }
Example #13
Source File: BuildContext.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
/** {@inheritDoc} */ @Override public BuildType getBuildType() { return type; }
Example #14
Source File: XtextBuilder.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @deprecated call {@link #doBuild(ToBeBuilt, Set, IProgressMonitor, BuildType)} instead. */ @Deprecated protected void doBuild(ToBeBuilt toBeBuilt, IProgressMonitor monitor, BuildType type) throws CoreException { doBuild(toBeBuilt, ImmutableSet.of(), monitor, type); }
Example #15
Source File: XtextBuilder.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.18 * @deprecated This method is present for backwards compatibility reasons and will be removed in a future release. */ @Deprecated protected boolean isDoBuildSpecialized(Class<?> c) { return isMethodSpecialized(c, "doBuild", ToBeBuilt.class, IProgressMonitor.class, BuildType.class); }
Example #16
Source File: BuildContext.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override public BuildType getBuildType() { return type; }
Example #17
Source File: BuildContext.java From dsl-devkit with Eclipse Public License 1.0 | 3 votes |
/** * Creates a new instance of {@link BuildContext}. * * @param builder * the {@link XtextBuilder}, may be {@code null} * @param builtProject * the {@link IProject} being built, may be {@code null} * @param resourceSet * the {@link ResourceSet}, must not be {@code null} * @param deltas * the list of {@link Delta}, must not be {@code null} * @param type * the {@link BuildType}, must not be {@code null} */ protected BuildContext(final XtextBuilder builder, final IProject builtProject, final ResourceSet resourceSet, final List<Delta> deltas, final BuildType type) { this.type = type; this.builder = builder; this.resourceSet = resourceSet; this.deltas = deltas; this.builtProject = builtProject; }
Example #18
Source File: BuildContext.java From dsl-devkit with Eclipse Public License 1.0 | 2 votes |
/** * Creates a new instance of {@link BuildContext}. * * @param builtProject * the {@link IProject} being built, must not be {@code null} * @param resourceSet * the {@link ResourceSet}, must not be {@code null} * @param type * the {@link BuildType}, must not be {@code null} */ public BuildContext(final IProject builtProject, final ResourceSet resourceSet, final BuildType type) { this(null, builtProject, resourceSet, Lists.<Delta> newArrayList(), type); }
Example #19
Source File: BuildContext.java From dsl-devkit with Eclipse Public License 1.0 | 2 votes |
/** * Creates a new instance of {@link BuildContext}. * * @param builder * the {@link XtextBuilder}, must not be {@code null} * @param resourceSet * the {@link ResourceSet}, must not be {@code null} * @param deltas * the list of {@link Delta}, must not be {@code null} * @param type * the {@link BuildType}, must not be {@code null} */ public BuildContext(final XtextBuilder builder, final ResourceSet resourceSet, final List<Delta> deltas, final BuildType type) { this(builder, null, resourceSet, deltas, type); }
Example #20
Source File: N4JSBuildTypeTracker.java From n4js with Eclipse Public License 1.0 | 2 votes |
/** * Obtain the build type for the given project. * * @param project * the built project. May not be null. */ public static BuildType getBuildType(IProject project) { return buildTypes.get(project); }
Example #21
Source File: N4JSBuildTypeTracker.java From n4js with Eclipse Public License 1.0 | 2 votes |
/** * Store the build type for the given project. * * @param project * the built project. May not be null. * @param type * the build type. May not be null. */ public static void setBuildType(IProject project, BuildType type) { buildTypes.put(project, type); }