use of com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptions2 in project dsl-devkit by dsldevkit.
the class MonitoredClusteringBuilderState method setResourceDescriptionsData.
/**
* Set the resource descriptions data, unless cancellation has been requested.
*
* @param newData
* the new resource descriptions data
* @param monitor
* the monitor to check for cancellation
*/
protected void setResourceDescriptionsData(final ResourceDescriptionsData newData, final IProgressMonitor monitor) {
checkForCancellation(monitor);
rawData = newData;
if (newData instanceof IResourceDescriptions2) {
myData = (IResourceDescriptions2) newData;
} else {
myData = new ResourceDescriptions2(newData);
}
super.setResourceDescriptionsData(newData);
if (isLoaded && newData instanceof AbstractResourceDescriptionsData) {
((AbstractResourceDescriptionsData) newData).commitChanges();
}
isLoaded = true;
}
use of com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptions2 in project dsl-devkit by dsldevkit.
the class AbstractCachingResourceDescriptionManager method isReferencedBy.
/**
* Determines if a given candidate is affected by a given delta.
*
* @param delta
* delta
* @param candidate
* candidate
* @param context
* context index
* @return true if the candidate is affected
*/
protected boolean isReferencedBy(final Delta delta, final IResourceDescription candidate, final IResourceDescriptions context) {
URI candidateURI = candidate.getURI();
if (delta instanceof ResourceDescriptionDelta && ((ResourceDescriptionDelta) delta).hasObjectFingerprints()) {
ResourceDescriptionDelta detailedDelta = (ResourceDescriptionDelta) delta;
final Set<IEObjectDescription> changedOrDeletedObjects = Sets.newHashSet(Iterables.concat(detailedDelta.getChangedObjects(), detailedDelta.getDeletedObjects()));
for (IResourceDescription desc : ((IResourceDescriptions2) context).findExactReferencingResources(changedOrDeletedObjects, ReferenceMatchPolicy.REFERENCES)) {
if (desc.getURI().equals(candidateURI)) {
return true;
}
}
for (IResourceDescription desc : ((IResourceDescriptions2) context).findExactReferencingResources(Sets.newHashSet(detailedDelta.getAddedObjects()), ReferenceMatchPolicy.UNRESOLVED_IMPORTED_NAMES)) {
if (desc.getURI().equals(candidateURI)) {
return true;
}
}
} else {
IResourceDescription resource = delta.getNew() != null ? delta.getNew() : delta.getOld();
for (IResourceDescription desc : ((IResourceDescriptions2) context).findAllReferencingResources(ImmutableSet.of(resource), ReferenceMatchPolicy.ALL)) {
if (desc.getURI().equals(candidateURI)) {
return true;
}
}
}
return false;
}
use of com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptions2 in project dsl-devkit by dsldevkit.
the class ReferenceFinder2 method findAllReferences.
/**
* {@inheritDoc}
*/
@Override
public void findAllReferences(final TargetURIs targetURIs, final IResourceAccess resourceAccess, final IResourceDescriptions indexData, final Acceptor acceptor, final IProgressMonitor monitor) {
final SubMonitor subMonitor = SubMonitor.convert(monitor, 10);
if (!Iterables.isEmpty(targetURIs)) {
if (indexData instanceof IResourceDescriptions2) {
findReferences(targetURIs, Sets.newHashSet(targetURIs.getTargetResourceURIs()), resourceAccess, indexData, acceptor, subMonitor.newChild(1));
findAllIndexedReferences(targetURIs, indexData, acceptor, subMonitor.newChild(9));
} else {
super.findAllReferences(targetURIs, resourceAccess, indexData, acceptor, subMonitor);
}
}
}
use of com.avaloq.tools.ddk.xtext.resource.extensions.IResourceDescriptions2 in project dsl-devkit by dsldevkit.
the class ReferenceFinder2 method findAllIndexedReferences.
/**
* Uses IResourceDescriptions2 to find all indexed references.
*
* @param targetURIs
* the URIs to find references to, must not be {@code null}
* @param indexData
* index to use when finding references, must not be {@code null}
* @param referenceAcceptor
* the reference acceptor, must not be {@code null}
* @param subMonitor
* the progress monitor, can be {@code null}
*/
protected void findAllIndexedReferences(final TargetURIs targetURIs, final IResourceDescriptions indexData, final Acceptor referenceAcceptor, final SubMonitor subMonitor) {
IResourceDescriptions2 idx = (IResourceDescriptions2) indexData;
List<IReferenceDescription> refs = uniqueReferences(Lists.newArrayList(idx.findReferencesToObjects(targetURIs.asSet())));
final SubMonitor monitor = SubMonitor.convert(subMonitor, Messages.ReferenceQuery_monitor, refs.size());
for (IReferenceDescription desc : refs) {
if (monitor.isCanceled()) {
return;
}
referenceAcceptor.accept(desc);
monitor.worked(1);
}
monitor.done();
}
Aggregations