org.eclipse.xtext.builder.impl.BuildData Java Examples
The following examples show how to use
org.eclipse.xtext.builder.impl.BuildData.
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: N4ClusteringBuilderState.java From n4js with Eclipse Public License 1.0 | 6 votes |
protected void installSourceLevelURIs(BuildData buildData) { ResourceSet resourceSet = buildData.getResourceSet(); Iterable<URI> sourceLevelUris = Iterables.concat(buildData.getToBeUpdated(), buildData.getURIQueue()); Set<URI> sourceUris = newHashSet(); for (URI uri : sourceLevelUris) { if (buildData.getSourceLevelURICache().getOrComputeIsSource(uri, resourceServiceProviderRegistry)) { sourceUris.add(uri); // unload resources loaded from storage previously Resource resource = resourceSet.getResource(uri, false); if (resource instanceof StorageAwareResource) { if (((StorageAwareResource) resource).isLoadedFromStorage()) { resource.unload(); } } } } SourceLevelURIsAdapter.setSourceLevelUris(resourceSet, sourceUris); }
Example #2
Source File: MonitoredClusteringBuilderState.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Override which installs an {@link DirectLinkingSourceLevelURIsAdapter} instead of Xtext's * {@link org.eclipse.xtext.resource.persistence.SourceLevelURIsAdapter} so that the builder can modify * {@link org.eclipse.xtext.builder.impl.SourceLevelURICache#getSources()} and get these changes reflected in the adapter. */ @Override protected void installSourceLevelURIs(final BuildData buildData) { ResourceSet resourceSet = buildData.getResourceSet(); Iterable<URI> sourceLevelUris = Iterables.concat(buildData.getToBeUpdated(), buildData.getURIQueue()); for (URI uri : sourceLevelUris) { if (buildData.getSourceLevelURICache().getOrComputeIsSource(uri, resourceServiceProviderRegistry)) { // unload resources loaded from storage previously Resource resource = resourceSet.getResource(uri, false); if (resource instanceof StorageAwareResource && ((StorageAwareResource) resource).isLoadedFromStorage()) { resource.unload(); } } } DirectLinkingSourceLevelURIsAdapter.setSourceLevelUris(resourceSet, buildData.getSourceLevelURICache().getSources()); }
Example #3
Source File: MonitoredClusteringBuilderState.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Stores the process resource as a binary if it doesn't contain syntax or linking errors. * * @param resource * resource to store, must not be {@code null} * @param buildData * build data, must not be {@code null} */ protected void storeBinaryResource(final Resource resource, final BuildData buildData) { if (isBinaryModelStorageAvailable && resource instanceof StorageAwareResource && ((StorageAwareResource) resource).getResourceStorageFacade() != null && fileSystemAccess instanceof IFileSystemAccessExtension3) { CompletableFuture.runAsync(() -> { final long maxTaskExecutionNanos = TimeUnit.NANOSECONDS.convert(1, TimeUnit.SECONDS); try { long elapsed = System.nanoTime(); IResourceStorageFacade storageFacade = ((StorageAwareResource) resource).getResourceStorageFacade(); storageFacade.saveResource((StorageAwareResource) resource, (IFileSystemAccessExtension3) fileSystemAccess); buildData.getSourceLevelURICache().getSources().remove(resource.getURI()); elapsed = System.nanoTime() - elapsed; if (elapsed > maxTaskExecutionNanos) { LOGGER.info("saving binary taking longer than expected (" + elapsed + " ns) : " + resource.getURI()); //$NON-NLS-1$ //$NON-NLS-2$ } // CHECKSTYLE:OFF } catch (Throwable ex) { // CHECKSTYLE:ON LOGGER.error("Failed to save binary for " + resource.getURI(), ex); //$NON-NLS-1$ } }, binaryStorageExecutor); } }
Example #4
Source File: AbstractBuilderState.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public synchronized ImmutableList<IResourceDescription.Delta> update(BuildData buildData, IProgressMonitor monitor) { ensureLoaded(); final SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.AbstractBuilderState_0, 1); subMonitor.subTask(Messages.AbstractBuilderState_0); if (buildData.isEmpty()) return ImmutableList.of(); if (monitor.isCanceled()) throw new OperationCanceledException(); final ResourceDescriptionsData newData = getCopiedResourceDescriptionsData(); final Collection<IResourceDescription.Delta> result = doUpdate(buildData, newData, subMonitor.split(1)); if (monitor.isCanceled()) throw new OperationCanceledException(); final ResourceDescriptionChangeEvent event = new ResourceDescriptionChangeEvent(result); // update the reference setResourceDescriptionsData(newData); notifyListeners(event); return event.getDeltas(); }
Example #5
Source File: ClusteringBuilderState.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected void installSourceLevelURIs(BuildData buildData) { ResourceSet resourceSet = buildData.getResourceSet(); Iterable<URI> sourceLevelUris = Iterables.concat(buildData.getToBeUpdated(), buildData.getURIQueue()); Set<URI> sourceUris = newHashSet(); for (URI uri : sourceLevelUris) { if (buildData.getSourceLevelURICache().getOrComputeIsSource(uri, resourceServiceProviderRegistry)) { sourceUris.add(uri); // unload resources loaded from storage previously Resource resource = resourceSet.getResource(uri, false); if (resource instanceof StorageAwareResource) { if (((StorageAwareResource) resource).isLoadedFromStorage()) { resource.unload(); } } } } SourceLevelURIsAdapter.setSourceLevelUris(resourceSet, sourceUris); }
Example #6
Source File: N4JSGenerateImmediatelyBuilderState.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** logic of {@link IN4JSCore#findAllProjects()} with filtering by name */ private IProject findProject(BuildData buildData) { String eclipseProjectName = buildData.getProjectName(); if (Strings.isNullOrEmpty(eclipseProjectName)) { return null; } IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); IProject project = root.getProject(eclipseProjectName); // creates a project instance if not existing if (null == project || !project.isAccessible()) { N4JSProjectName n4jsProjectName = new EclipseProjectName(eclipseProjectName).toN4JSProjectName(); final IProject externalProject = externalLibraryWorkspace.getProject(n4jsProjectName); if (null != externalProject && externalProject.exists()) { project = externalProject; } } return project; }
Example #7
Source File: N4JSGenerateImmediatelyBuilderState.java From n4js with Eclipse Public License 1.0 | 6 votes |
private void logBuildData(BuildData buildData, String... tags) { // This log call sometimes yields a ConcurrentModificationException (see GHOLD-296) // We disable it as a temporary fix only until GHOLD-296 is resolved. // TODO Uncomment the following code when GHOLD-296 is resolved and remove the SuppressWarnings annotation. // UPDATE as of Nov 2017 (mor): // commented logging back in after (hopefully) fixing the ConcurrentModificationException // (but keeping these comments for reference, for now; if this does not cause problems over the next few weeks, // this comment and the previous comments in this method can be removed) String tag = Arrays2.isEmpty(tags) ? "" : Joiner.on(" - ").join(tags); String header = "---------------------- Build data" + tag + " --------------------------------------"; builderStateLogger.log(header); builderStateLogger.log("Project name: " + buildData.getProjectName()); builderStateLogger.log("To be deleted: " + ensureNotNull(buildData.getToBeDeleted())); builderStateLogger.log("To be updated: " + ensureNotNull(buildData.getToBeUpdated())); builderStateLogger.log("URI queue: " + buildData.getURIQueue()); builderStateLogger.log("All remaining URIs: " + buildData.getAllRemainingURIs()); builderStateLogger.log(Strings.repeat("-", header.length()) + "\n"); }
Example #8
Source File: WriteNewResourceDescriptionsImplementation.java From n4js with Eclipse Public License 1.0 | 6 votes |
public WriteNewResourceDescriptionsImplementation(N4ClusteringBuilderState state, BuildData buildData, IResourceDescriptions oldState, CurrentDescriptions newState, IProgressMonitor monitor, IBuildLogger buildLogger, IResourceLoader globalIndexResourceLoader, IResourceClusteringPolicy clusteringPolicy, CompilerPhases compilerPhases) { this.compilerPhases = compilerPhases; this.clusteringPolicy = clusteringPolicy; this.globalIndexResourceLoader = globalIndexResourceLoader; this.state = state; this.buildData = buildData; this.oldState = oldState; this.newState = newState; this.progress = SubMonitor.convert(monitor, buildData.getToBeUpdated().size()); this.buildLogger = buildLogger; this.resourceSet = buildData.getResourceSet(); this.currentProject = state.getBuiltProject(buildData); }
Example #9
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 #10
Source File: DoUpdateImplementation.java From n4js with Eclipse Public License 1.0 | 6 votes |
public DoUpdateImplementation(N4ClusteringBuilderState state, BuildData buildData, ResourceDescriptionsData newData, IProgressMonitor monitor, IBuildLogger buildLogger, IResourceLoader crossLinkingResourceLoader, IResourceClusteringPolicy clusteringPolicy) { this.clusteringPolicy = clusteringPolicy; this.crossLinkingResourceLoader = crossLinkingResourceLoader; this.buildLogger = buildLogger; this.state = state; this.buildData = buildData; this.newData = newData; this.progress = SubMonitor.convert(monitor); this.cancelMonitor = new MonitorBasedCancelIndicator(progress); this.toBeDeleted = buildData.getAndRemoveToBeDeleted(); this.resourceSet = buildData.getResourceSet(); this.newState = new CurrentDescriptions(resourceSet, newData, buildData); this.currentProject = state.getBuiltProject(buildData); this.queue = buildData.getURIQueue(); }
Example #11
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 #12
Source File: MonitoredClusteringBuilderState.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Save copies of existing resource descriptions (which will be overwritten in the first build phase). We only copy the EObjectDescriptions. * * @param buildData * The buildData * @return a map containing all existing resource descriptions, with NULL_DESCRIPTION for non-existing descriptions. */ protected Map<URI, IResourceDescription> saveOldDescriptions(final BuildData buildData) { Map<URI, IResourceDescription> cache = Maps.newHashMapWithExpectedSize(buildData.getToBeUpdated().size()); for (URI uri : Iterables.concat(buildData.getToBeUpdated(), buildData.getToBeDeleted())) { // Do *not* use descriptionCopier here, we just want the EObjectDescriptions! cache.computeIfAbsent(uri, u -> Optional.ofNullable(getResourceDescription(u)).<IResourceDescription> map(this::createOldStateResourceDescription).orElse(NULL_DESCRIPTION)); } return cache; }
Example #13
Source File: MonitoredClusteringBuilderState.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Save copies of existing associations for derived objects (which will be cleared in the first build phase as resource descriptions will be overwritten). * * @param buildData * The build data * @return a map containing associations for objects derived from resources identified by their URIs */ protected Map<URI, DerivedObjectAssociations> saveOldDerivedObjectAssociations(final BuildData buildData) { IDerivedObjectAssociationsStore associationStore = getDerivedObjectAssociationsStore(); if (associationStore != null) { Map<URI, DerivedObjectAssociations> cache = Maps.newHashMapWithExpectedSize(buildData.getToBeUpdated().size()); for (URI uri : Iterables.concat(buildData.getToBeUpdated(), buildData.getToBeDeleted())) { cache.computeIfAbsent(uri, associationStore::getAssociations); } return cache; } return Collections.emptyMap(); }
Example #14
Source File: MonitoredClusteringBuilderState.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
@Override @SuppressWarnings("PMD.AvoidInstanceofChecksInCatchClause") public synchronized ImmutableList<Delta> update(final BuildData buildData, final IProgressMonitor monitor) { ensureLoaded(); final SubMonitor subMonitor = SubMonitor.convert(monitor, org.eclipse.xtext.builder.builderState.Messages.AbstractBuilderState_0, 1); subMonitor.subTask(org.eclipse.xtext.builder.builderState.Messages.AbstractBuilderState_0); checkForCancellation(monitor); final ResourceDescriptionsData newData = getCopiedResourceDescriptionsData(); Collection<IResourceDescription.Delta> result = null; try { result = doUpdate(buildData, newData, subMonitor.newChild(1)); // update the reference setResourceDescriptionsData(newData, monitor); // CHECKSTYLE:CHECK-OFF IllegalCatch } catch (Throwable t) { // CHECKSTYLE:CHECK-ON IllegalCatch if (!operationCanceledManager.isOperationCanceledException(t)) { LOGGER.error("Failed to update index. Executing rollback.", t); //$NON-NLS-1$ } if (newData instanceof AbstractResourceDescriptionsData) { ((AbstractResourceDescriptionsData) newData).rollbackChanges(); } throw t; } final ResourceDescriptionChangeEvent event = new ResourceDescriptionChangeEvent(result); notifyListeners(event); return event.getDeltas(); }
Example #15
Source File: MonitoredClusteringBuilderState.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** {@inheritDoc} */ protected void writeNewResourceDescriptions(final BuildData buildData, final IResourceDescriptions oldState, final CurrentDescriptions newState, final ResourceDescriptionsData newData, final IProgressMonitor monitor) { final List<List<URI>> toWriteGroups = phaseOneBuildSorter.sort(buildData.getToBeUpdated()); final List<URI> toBuild = Lists.newLinkedList(); ResourceSet resourceSet = buildData.getResourceSet(); BuildPhases.setIndexing(resourceSet, true); int totalSize = 0; for (List<URI> group : toWriteGroups) { totalSize = totalSize + group.size(); } final SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.MonitoredClusteringBuilderState_WRITE_DESCRIPTIONS, totalSize); try { traceSet.started(BuildIndexingEvent.class); /* * We handle one group at a time to enforce strict ordering between some specific source types. * I.e. We start processing a source type (or a set of them) only after all occurrences of another source on which the depend has been written into the * index. * One list sorted by source type would not be enough to enforce such ordering in a parallel loading scenario. * In fact, in this case we might start processing sources before the ones they depend on are still being handled. */ for (Collection<URI> fileExtensionBuildGroup : toWriteGroups) { toBuild.addAll(writeResources(fileExtensionBuildGroup, buildData, oldState, newState, subMonitor)); } flushChanges(newData); } finally { // Clear the flags BuildPhases.setIndexing(resourceSet, false); resourceSet.getLoadOptions().remove(ILazyLinkingResource2.MARK_UNRESOLVABLE_XREFS); phaseTwoBuildSorter.sort(toBuild).stream().flatMap(List::stream).forEach(buildData::queueURI); traceSet.ended(BuildIndexingEvent.class); } }
Example #16
Source File: ClusteringBuilderState.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected IProject getBuiltProject(BuildData buildData) { if (Strings.isEmpty(buildData.getProjectName())) return null; return workspace.getRoot().getProject(buildData.getProjectName()); }
Example #17
Source File: ClusteringBuilderState.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * Put all resources that depend on some changes onto the queue of resources to be processed. * Updates notInDelta by removing all URIs put into the queue. * * @param allRemainingURIs * URIs that were not considered by prior operations. * @param oldState * State before the build * @param newState * The current state * @param changedDeltas * the deltas that have changed {@link IEObjectDescription}s * @param allDeltas * All deltas * @param buildData * the underlying data for this build run. * @param monitor * The progress monitor used for user feedback */ protected void queueAffectedResources( Set<URI> allRemainingURIs, IResourceDescriptions oldState, CurrentDescriptions newState, Collection<Delta> changedDeltas, Collection<Delta> allDeltas, BuildData buildData, final IProgressMonitor monitor) { if (allDeltas.isEmpty()) { return; } final SubMonitor progress = SubMonitor.convert(monitor, allRemainingURIs.size() + 1); Iterator<URI> iter = allRemainingURIs.iterator(); while (iter.hasNext()) { if (progress.isCanceled()) { throw new OperationCanceledException(); } final URI candidateURI = iter.next(); final IResourceDescription candidateDescription = oldState.getResourceDescription(candidateURI); final IResourceDescription.Manager manager = getResourceDescriptionManager(candidateURI); if (candidateDescription == null || manager == null) { // If there is no description in the old state, there's no need to re-check this over and over. iter.remove(); } else { boolean affected; if ((manager instanceof IResourceDescription.Manager.AllChangeAware)) { affected = ((AllChangeAware) manager).isAffectedByAny(allDeltas, candidateDescription, newState); } else { if (changedDeltas.isEmpty()) { affected = false; } else { affected = manager.isAffected(changedDeltas, candidateDescription, newState); } } if (affected) { buildData.queueURI(candidateURI); iter.remove(); } } progress.split(1); } }
Example #18
Source File: CurrentDescriptions.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.4 */ public BuildData getBuildData() { return buildData; }
Example #19
Source File: ClusteringBuilderState.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * Create new resource descriptions for a set of resources given by their URIs. * * @param buildData * The underlying data for the write operation. * @param oldState * The old index * @param newState * The new index * @param monitor * The progress monitor used for user feedback */ protected void writeNewResourceDescriptions( BuildData buildData, IResourceDescriptions oldState, CurrentDescriptions newState, final IProgressMonitor monitor) { int index = 0; ResourceSet resourceSet = buildData.getResourceSet(); Set<URI> toBeUpdated = buildData.getToBeUpdated(); final SubMonitor subMonitor = SubMonitor.convert(monitor, "Write new resource descriptions", toBeUpdated.size() + 1); // TODO: NLS IProject currentProject = getBuiltProject(buildData); LoadOperation loadOperation = null; try { compilerPhases.setIndexing(resourceSet, true); loadOperation = globalIndexResourceLoader.create(resourceSet, currentProject); loadOperation.load(toBeUpdated); while (loadOperation.hasNext()) { if (subMonitor.isCanceled()) { loadOperation.cancel(); throw new OperationCanceledException(); } if (!clusteringPolicy.continueProcessing(resourceSet, null, index)) { clearResourceSet(resourceSet); } URI uri = null; Resource resource = null; try { LoadResult loadResult = loadOperation.next(); uri = loadResult.getUri(); resource = addResource(loadResult.getResource(), resourceSet); subMonitor.subTask("Writing new resource description " + resource.getURI().lastSegment()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Writing new resource description " + uri); } final IResourceDescription.Manager manager = getResourceDescriptionManager(uri); if (manager != null) { // We don't care here about links, we really just want the exported objects so that we can link in the // next phase. final IResourceDescription description = manager.getResourceDescription(resource); final IResourceDescription copiedDescription = new CopiedResourceDescription(description); // We also don't care what kind of Delta we get here; it's just a temporary transport vehicle. That interface // could do with some clean-up, too, because all we actually want to do is register the new resource // description, not the delta. newState.register(new DefaultResourceDescriptionDelta(oldState.getResourceDescription(uri), copiedDescription)); buildData.queueURI(uri); } } catch (final RuntimeException ex) { if(ex instanceof LoadOperationException) { uri = ((LoadOperationException) ex).getUri(); } if (uri == null) { LOGGER.error("Error loading resource", ex); //$NON-NLS-1$ } else { if (resourceSet.getURIConverter().exists(uri, Collections.emptyMap())) { LOGGER.error("Error loading resource from: " + uri.toString(), ex); //$NON-NLS-1$ } if (resource != null) { resourceSet.getResources().remove(resource); } final IResourceDescription oldDescription = oldState.getResourceDescription(uri); if (oldDescription != null) { newState.register(new DefaultResourceDescriptionDelta(oldDescription, null)); } } // If we couldn't load it, there's no use trying again: do not add it to the queue } index++; subMonitor.split(1); } } finally { compilerPhases.setIndexing(resourceSet, false); if(loadOperation != null) loadOperation.cancel(); } }
Example #20
Source File: N4ClusteringBuilderState.java From n4js with Eclipse Public License 1.0 | 4 votes |
/** * Put all resources that depend on some changes onto the queue of resources to be processed. Updates notInDelta by * removing all URIs put into the queue. * * @param allRemainingURIs * URIs that were not considered by prior operations. * @param oldState * State before the build * @param newState * The current state * @param changedDeltas * the deltas that have changed {@link IEObjectDescription}s * @param allDeltas * All deltas * @param buildData * the underlying data for this build run. * @param monitor * The progress monitor used for user feedback */ protected void queueAffectedResources( Set<URI> allRemainingURIs, IResourceDescriptions oldState, CurrentDescriptions newState, Collection<Delta> changedDeltas, Collection<Delta> allDeltas, BuildData buildData, final IProgressMonitor monitor) { if (allDeltas.isEmpty()) { return; } final SubMonitor progress = SubMonitor.convert(monitor, allRemainingURIs.size()); Iterator<URI> iter = allRemainingURIs.iterator(); while (iter.hasNext()) { if (progress.isCanceled()) { throw new OperationCanceledException(); } final URI candidateURI = iter.next(); final IResourceDescription candidateDescription = oldState.getResourceDescription(candidateURI); final IResourceDescription.Manager manager = getResourceDescriptionManager(candidateURI); if (candidateDescription == null || manager == null) { // If there is no description in the old state, there's no need to re-check this over and over. iter.remove(); } else { boolean affected; if ((manager instanceof IResourceDescription.Manager.AllChangeAware)) { affected = ((AllChangeAware) manager).isAffectedByAny(allDeltas, candidateDescription, newState); } else { if (changedDeltas.isEmpty()) { affected = false; } else { affected = manager.isAffected(changedDeltas, candidateDescription, newState); } } if (affected) { buildData.queueURI(candidateURI); // since the candidate is affected by any of the currently changed resources, we disable // the module data of the candidate to ensure that no code will see it later on by accident // Related tests: // - IncrementalBuilderCornerCasesPluginTest#testMissingReloadBug() // - ReproduceInvalidIndexPluginTest if (!N4JSGlobals.PACKAGE_JSON.equals(candidateURI.lastSegment())) { ResourceDescriptionWithoutModuleUserData noModuleData = new ResourceDescriptionWithoutModuleUserData( candidateDescription); newState.register(manager.createDelta(candidateDescription, noModuleData)); // also we ensure that we do run a subsequent build. buildData.requestRebuild(); } iter.remove(); } } progress.worked(1); } }
Example #21
Source File: N4ClusteringBuilderState.java From n4js with Eclipse Public License 1.0 | 4 votes |
protected IProject getBuiltProject(BuildData buildData) { if (Strings.isEmpty(buildData.getProjectName())) return null; return workspace.getRoot().getProject(buildData.getProjectName()); }
Example #22
Source File: AbstractBuilderState.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected abstract Collection<IResourceDescription.Delta> doUpdate(BuildData buildData, ResourceDescriptionsData newData, IProgressMonitor monitor);
Example #23
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 #24
Source File: Bug349445Test.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Test public void testUpdate() { testMe.update(new BuildData(null, null, new ToBeBuilt(), new QueuedBuildData(null)), null); assertEquals(1, loadCalled); }
Example #25
Source File: N4JSBuildTypeTrackingBuilder.java From n4js with Eclipse Public License 1.0 | 4 votes |
private boolean isNoop(ToBeBuilt toBeBuilt, QueuedBuildData queuedBuildData, boolean indexingOnly) { return new BuildData(getProject().getName(), null, toBeBuilt, queuedBuildData, indexingOnly, this::needRebuild) .isEmpty(); }
Example #26
Source File: N4ClusteringBuilderState.java From n4js with Eclipse Public License 1.0 | 3 votes |
/** * Actually do the build. * * @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) { return new DoUpdateImplementation(this, buildData, newData, SubMonitor.convert(monitor, 1), this.buildLogger, crossLinkingResourceLoader, clusteringPolicy) .doUpdate(); }
Example #27
Source File: N4ClusteringBuilderState.java From n4js with Eclipse Public License 1.0 | 3 votes |
/** * Create new resource descriptions for a set of resources given by their URIs. * * @param buildData * The underlying data for the write operation. * @param oldState * The old index * @param newState * The new index * @param monitor * The progress monitor used for user feedback */ protected void writeNewResourceDescriptions( BuildData buildData, IResourceDescriptions oldState, CurrentDescriptions newState, final IProgressMonitor monitor) { new WriteNewResourceDescriptionsImplementation(this, buildData, oldState, newState, monitor, buildLogger, globalIndexResourceLoader, clusteringPolicy, compilerPhases) .writeNewResourceDescriptions(); }
Example #28
Source File: IBuilderState.java From xtext-eclipse with Eclipse Public License 2.0 | 2 votes |
/** * Updated the underlying {@link IResourceDescriptions} according to the passed URIs. * It updates transitively affected {@link IResourceDescription} as well. * * The change to the underlying {@link IResourceDescriptions} is guaranteed to be atomic. * * @param buildData the underlying data for the update. * @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 canceled. * * @return a list of changes in the form of deltas. */ ImmutableList<IResourceDescription.Delta> update(BuildData buildData, IProgressMonitor monitor);
Example #29
Source File: CurrentDescriptions.java From xtext-eclipse with Eclipse Public License 2.0 | 2 votes |
/** * Create a new index based on an old one. * * @param resourceSet * The resource set * @param newData * the new index state. * @param buildData * the currently processed builddata * @since 2.4 */ public CurrentDescriptions(ResourceSet resourceSet, ResourceDescriptionsData newData, BuildData buildData) { this(resourceSet, newData); this.buildData = buildData; }