Java Code Examples for org.eclipse.xtext.resource.impl.ResourceDescriptionsData#getResourceDescription()

The following examples show how to use org.eclipse.xtext.resource.impl.ResourceDescriptionsData#getResourceDescription() . 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 vote down vote up
/**
 * Compute deltas for resources affected by the given <code>newDeltas</code> and register them in the given
 * <code>newIndex</code>.
 *
 * @param index
 *            the current index; will be changed by this method.
 * @param remainingURIs
 *            set of URIs that were not processed yet.
 * @param newDeltas
 *            deltas representing the resources processed during the most recent build iteration.
 * @param allDeltas
 *            deltas representing all resources processed so far, including {@link XBuildRequest#getExternalDeltas()
 *            external deltas}.
 * @param context
 *            the build context.
 * @return list of deltas representing the affected resources.
 */
public List<Delta> computeAndIndexAffected(ResourceDescriptionsData index, Set<URI> remainingURIs,
		Collection<Delta> newDeltas, Collection<Delta> allDeltas, XBuildContext context) {

	ResourceDescriptionsData originalIndex = context.getOldState().getResourceDescriptions();
	List<URI> affectedURIs = new ArrayList<>();
	for (URI uri : remainingURIs) {
		IResourceServiceProvider resourceServiceProvider = context.getResourceServiceProvider(uri);
		IResourceDescription.Manager manager = resourceServiceProvider.getResourceDescriptionManager();
		IResourceDescription resourceDescription = originalIndex.getResourceDescription(uri);
		if (isAffected(resourceDescription, manager, newDeltas, allDeltas, index)) {
			affectedURIs.add(uri);
		}
	}

	List<Delta> affectedDeltas = getDeltasForChangedResources(affectedURIs, originalIndex, context);
	for (IResourceDescription.Delta delta : affectedDeltas) {
		index.register(delta);
	}
	return affectedDeltas;
}
 
Example 2
Source File: XIndexer.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Process the deleted resources.
 */
protected List<IResourceDescription.Delta> getDeltasForDeletedResources(XBuildRequest request,
		ResourceDescriptionsData oldIndex, XBuildContext context) {

	List<IResourceDescription.Delta> deltas = new ArrayList<>();
	for (URI deleted : request.getDeletedFiles()) {
		IResourceServiceProvider resourceServiceProvider = context.getResourceServiceProvider(deleted);
		if (resourceServiceProvider != null) {
			this.operationCanceledManager.checkCanceled(context.getCancelIndicator());
			IResourceDescription oldDescription = oldIndex != null ? oldIndex.getResourceDescription(deleted)
					: null;
			if (oldDescription != null) {
				DefaultResourceDescriptionDelta delta = new DefaultResourceDescriptionDelta(oldDescription, null);
				deltas.add(delta);
			}
		}
	}
	return deltas;
}
 
Example 3
Source File: FlatResourceSetBasedAllContainersState.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean containsURI(String containerHandle, URI candidateURI) {
	if (!HANDLE.equals(containerHandle))
		return false;
	if (resourceSet instanceof XtextResourceSet) {
		ResourceDescriptionsData descriptionsData = findResourceDescriptionsData(resourceSet);
		if (descriptionsData != null) {
			return descriptionsData.getResourceDescription(candidateURI) != null;
		}
		Collection<URI> allUris = ((XtextResourceSet) resourceSet).getNormalizationMap().values();
		for (URI uri : allUris) {
			if (uri.equals(candidateURI)) {
				return true;
			}
		}
		return false;
	}
	URIConverter uriConverter = resourceSet.getURIConverter();
	for (Resource r : resourceSet.getResources()) {
		URI normalized = uriConverter.normalize(r.getURI());
		if (normalized.equals(candidateURI)) {
			return true;
		}
	}
	return false;
}
 
Example 4
Source File: Indexer.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Process the deleted resources.
 */
protected List<IResourceDescription.Delta> getDeltasForDeletedResources(BuildRequest request,
		ResourceDescriptionsData oldIndex, BuildContext context) {
	List<IResourceDescription.Delta> deltas = new ArrayList<>();
	for (URI deleted : request.getDeletedFiles()) {
		IResourceServiceProvider resourceServiceProvider = context.getResourceServiceProvider(deleted);
		if (resourceServiceProvider != null) {
			operationCanceledManager.checkCanceled(context.getCancelIndicator());
			IResourceDescription oldDescription = oldIndex != null ? oldIndex.getResourceDescription(deleted)
					: null;
			if (oldDescription != null) {
				DefaultResourceDescriptionDelta delta = new DefaultResourceDescriptionDelta(oldDescription, null);
				deltas.add(delta);
			}
		}
	}
	return deltas;
}