Java Code Examples for org.eclipse.xtext.resource.IResourceDescription#Delta
The following examples show how to use
org.eclipse.xtext.resource.IResourceDescription#Delta .
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: XIndexer.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Return true, if the given resource must be processed due to the given changes. */ protected boolean isAffected(IResourceDescription affectionCandidate, IResourceDescription.Manager manager, Collection<IResourceDescription.Delta> newDeltas, Collection<IResourceDescription.Delta> allDeltas, IResourceDescriptions resourceDescriptions) { if (manager instanceof IResourceDescription.Manager.AllChangeAware) { AllChangeAware allChangeAwareManager = (IResourceDescription.Manager.AllChangeAware) manager; return allChangeAwareManager.isAffectedByAny(allDeltas, affectionCandidate, resourceDescriptions); } else { if (newDeltas.isEmpty()) { return false; } else { return manager.isAffected(newDeltas, affectionCandidate, resourceDescriptions); } } }
Example 2
Source File: XBuildManager.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Run a full build on the workspace * * @return the delta. */ public List<IResourceDescription.Delta> doInitialBuild(List<ProjectDescription> projects, CancelIndicator indicator) { lspLogger.log("Initial build ..."); ProjectBuildOrderInfo projectBuildOrderInfo = projectBuildOrderInfoProvider.get(); ProjectBuildOrderIterator pboIterator = projectBuildOrderInfo.getIterator(projects); printBuildOrder(); List<IResourceDescription.Delta> result = new ArrayList<>(); while (pboIterator.hasNext()) { ProjectDescription description = pboIterator.next(); String projectName = description.getName(); XProjectManager projectManager = workspaceManager.getProjectManager(projectName); XBuildResult partialresult = projectManager.doInitialBuild(indicator); result.addAll(partialresult.getAffectedResources()); } lspLogger.log("... initial build done."); return result; }
Example 3
Source File: BuilderParticipant.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.7 */ protected void doBuild(List<IResourceDescription.Delta> deltas, Map<String, OutputConfiguration> outputConfigurations, Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers, IBuildContext context, EclipseResourceFileSystemAccess2 access, IProgressMonitor progressMonitor) throws CoreException { final int numberOfDeltas = deltas.size(); SubMonitor subMonitor = SubMonitor.convert(progressMonitor, numberOfDeltas); SubMonitor currentMonitor = null; int clusterIndex = 0; for (int i = 0; i < numberOfDeltas; i++) { IResourceDescription.Delta delta = deltas.get(i); if (subMonitor.isCanceled()) { throw new OperationCanceledException(); } currentMonitor = subMonitor.split(1); access.setMonitor(currentMonitor); if (logger.isDebugEnabled()) { logger.debug("Compiling " + delta.getUri() + " (" + i + " of " + numberOfDeltas + ")"); } if (delta.getNew() != null && !clusteringPolicy.continueProcessing(context.getResourceSet(), delta.getUri(), clusterIndex)) { clearResourceSet(context.getResourceSet()); clusterIndex = 0; } Set<IFile> derivedResources = getDerivedResources(delta, outputConfigurations, generatorMarkers); access.setPostProcessor(getPostProcessor(delta, context, derivedResources)); if (doGenerate(delta, context, access)) { clusterIndex++; access.flushSourceTraces(); } cleanDerivedResources(delta, derivedResources, context, access, currentMonitor); } }
Example 4
Source File: RegistryBuilderParticipant.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * For each {@link IResourceDescription.Delta} searches and calls the responsible {@link ILanguageSpecificBuilderParticipant}s. * * @param buildContext * the {@link IBuildContext}, must not be {@code null} * @param monitor * the {@link IProgressMonitor}, must not be {@code null} */ protected void buildLanguageSpecificParticipants(final IBuildContext buildContext, final IProgressMonitor monitor) { initParticipants(); SubMonitor progress = SubMonitor.convert(monitor, buildContext.getDeltas().size() * MONITOR_PARTICIPANTS_PER_LANGUAGE); Map<String, BuildContext> languageIdToBuildContext = Maps.newHashMap(); for (IResourceDescription.Delta delta : buildContext.getDeltas()) { IResourceServiceProvider resourceServiceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(delta.getUri()); if (resourceServiceProvider == null) { progress.worked(MONITOR_PARTICIPANTS_PER_LANGUAGE); continue; } IGrammarAccess grammarAccess = null; try { grammarAccess = resourceServiceProvider.get(IGrammarAccess.class); } catch (ConfigurationException e) { progress.worked(MONITOR_PARTICIPANTS_PER_LANGUAGE); continue; } if (grammarAccess == null) { progress.worked(MONITOR_PARTICIPANTS_PER_LANGUAGE); continue; } String languageId = grammarAccess.getGrammar().getName(); BuildContext entryBuildContext = languageIdToBuildContext.get(languageId); if (entryBuildContext == null) { entryBuildContext = new BuildContext(buildContext.getBuiltProject(), buildContext.getResourceSet(), buildContext.getBuildType()); languageIdToBuildContext.put(languageId, entryBuildContext); } entryBuildContext.addDelta(delta); } builLanguageSpecificContext(buildContext, progress, languageIdToBuildContext); }
Example 5
Source File: Indexer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * Process the changed resources. */ protected List<IResourceDescription.Delta> getDeltasForChangedResources(Iterable<URI> affectedUris, ResourceDescriptionsData oldIndex, BuildContext context) { try { compilerPhases.setIndexing(context.getResourceSet(), true); // Since context.executeClustered, we can avoid a copy due of the list due to the impl detail of // IterableExtensions.toList return IterableExtensions .toList(context.executeClustered(affectedUris, it -> addToIndex(it, true, oldIndex, context))); } finally { compilerPhases.setIndexing(context.getResourceSet(), false); } }
Example 6
Source File: DeltaConverter.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected void convertCompilationUnit(IJavaElementDelta delta, List<IResourceDescription.Delta> result) { if (delta.getKind() == IJavaElementDelta.ADDED) { convertAddedCompilationUnit(delta, result); } else if (delta.getKind() == IJavaElementDelta.REMOVED) { convertRemovedTypes(delta, result); } else { convertChangedCompilationUnit(delta, result); } }
Example 7
Source File: DefaultUniqueNameContext.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected boolean isAffected(IResourceDescription.Delta delta, IResourceDescription candidate, boolean caseSensitive) { if (candidate.getURI().equals(delta.getUri())) { return false; } if (delta.getNew() != null && intersects(delta.getNew(), candidate, caseSensitive)) { return true; } if (delta.getOld() != null && intersects(delta.getOld(), candidate, caseSensitive)) { return true; } return false; }
Example 8
Source File: XWorkspaceManager.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** Triggers an incremental build, and will generate output files. */ protected XBuildable getIncrementalGenerateBuildable(WorkspaceChanges workspaceChanges) { XBuildManager.XBuildable buildable = buildManager.getIncrementalGenerateBuildable(workspaceChanges); return (cancelIndicator) -> { List<IResourceDescription.Delta> deltas = buildable.build(cancelIndicator); afterBuild(deltas); LOG.info("Output files generated."); return deltas; }; }
Example 9
Source File: DirtyStateEditorSupport.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.8 */ protected void processDelta(IResourceDescription.Delta delta, Resource context, List<Resource> result) { ResourceSet resourceSet = context.getResourceSet(); Resource resourceInResourceSet = resourceSet.getResource(delta.getUri(), false); if(resourceInResourceSet != null && resourceInResourceSet != context) { result.add(resourceInResourceSet); } }
Example 10
Source File: XIndexer.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Compute deltas for the build's initial resource deletions and changes as recorded in the given build request, and * register them in the request's index. */ public XIndexer.XIndexResult computeAndIndexDeletedAndChanged(XBuildRequest request, XBuildContext context) { ResourceDescriptionsData previousIndex = context.getOldState().getResourceDescriptions(); ResourceDescriptionsData newIndex = request.getState().getResourceDescriptions(); List<IResourceDescription.Delta> deltas = new ArrayList<>(); deltas.addAll(getDeltasForDeletedResources(request, previousIndex, context)); deltas.addAll(getDeltasForChangedResources(request.getDirtyFiles(), previousIndex, context)); for (IResourceDescription.Delta delta : deltas) { newIndex.register(delta); } return new XIndexer.XIndexResult(deltas, newIndex); }
Example 11
Source File: DefaultUniqueNameContext.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public boolean isAffected(Collection<IResourceDescription.Delta> deltas, IResourceDescription candidate, IResourceDescriptions context) { for (IResourceDescription.Delta delta : deltas) { if (isAffected(delta, candidate, true)) { return true; } } return false; }
Example 12
Source File: DeltaConverter.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.8 * @deprecated * @see #convertRemovedTypes(TypeNames, List) */ @Deprecated protected void convertRemovedTypes(Collection<String> typeNames, IJavaProject project, List<IResourceDescription.Delta> result) { for (String typeName : typeNames) { convertRemovedType(typeName, project, result); } }
Example 13
Source File: Indexer.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * Index the given resource. * * @param isPreIndexing * can be evaluated to produce different index entries depending on the phase */ protected IResourceDescription.Delta addToIndex(Resource resource, boolean isPreIndexing, ResourceDescriptionsData oldIndex, BuildContext context) { operationCanceledManager.checkCanceled(context.getCancelIndicator()); URI uri = resource.getURI(); IResourceServiceProvider serviceProvider = context.getResourceServiceProvider(uri); IResourceDescription.Manager manager = serviceProvider.getResourceDescriptionManager(); IResourceDescription newDescription = manager.getResourceDescription(resource); IResourceDescription toBeAdded = new Indexer.ResolvedResourceDescription(newDescription); IResourceDescription.Delta delta = manager .createDelta(oldIndex != null ? oldIndex.getResourceDescription(uri) : null, toBeAdded); return delta; }
Example 14
Source File: DeltaConverter.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.5 */ protected void convertAddedCompilationUnit(IJavaElementDelta delta, List<IResourceDescription.Delta> result) { ICompilationUnit compilationUnit = (ICompilationUnit) delta.getElement(); convertNewTypes(compilationUnit, result); }
Example 15
Source File: BuildRequest.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public void setExternalDeltas(List<IResourceDescription.Delta> externalDeltas) { this.externalDeltas = externalDeltas; }
Example 16
Source File: XtendResourceDescriptionManager.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
/** * When an annotation processor changes, even if it is just its implementation, the downstream classes should be rebuilt. That is why we are interested even in * deltas that have no changed EObjectDescriptions */ @Override public boolean isAffectedByAny(final Collection<IResourceDescription.Delta> deltas, final IResourceDescription candidate, final IResourceDescriptions context) throws IllegalArgumentException { return this.isAffected(deltas, candidate, context); }
Example 17
Source File: IOrderInfo.java From n4js with Eclipse Public License 1.0 | 4 votes |
/** Set all affected elements of the underlying collection to be visited by this iterator. */ public IOrderIterator<T> visitAffected(List<IResourceDescription.Delta> changes);
Example 18
Source File: DeltaConverter.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.8 */ protected void convertRemovedType(String typeName, IJavaProject project, List<IResourceDescription.Delta> result) { if (!isDerived(typeName, project)) { result.add(createContentChangeDelta(createTypeResourceDescription(typeName), null)); } }
Example 19
Source File: ResourceDescriptionChangeEvent.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.5 */ public ResourceDescriptionChangeEvent(Iterable<IResourceDescription.Delta> delta) { this.delta = ImmutableList.copyOf(delta); }
Example 20
Source File: WorkspaceManager.java From xtext-core with Eclipse Public License 2.0 | 3 votes |
/** * Announce dirty and deleted files and provide means to start a build. * * @param dirtyFiles * the dirty files * @param deletedFiles * the deleted files * @return a build command that can be triggered */ public Buildable didChangeFiles(List<URI> dirtyFiles, List<URI> deletedFiles) { BuildManager.Buildable buildable = buildManager.submit(dirtyFiles, deletedFiles); return (cancelIndicator) -> { List<IResourceDescription.Delta> deltas = buildable.build(cancelIndicator); afterBuild(deltas); return deltas; }; }