Search in sources :

Example 1 with IReferenceFinder

use of org.eclipse.xtext.findReferences.IReferenceFinder in project xtext-eclipse by eclipse.

the class DefaultReferenceFinder method findAllIndexedReferences.

/**
 * @since 2.4
 */
protected void findAllIndexedReferences(IAcceptor<IReferenceDescription> referenceAcceptor, SubMonitor subMonitor, Set<URI> targetURIsAsSet, ILocalResourceAccess localResourceAccess) {
    TargetURIs targetURIs = converter.fromIterable(targetURIsAsSet);
    if (!targetURIs.isEmpty()) {
        subMonitor.setWorkRemaining(size(indexData.getAllResourceDescriptions()) / MONITOR_CHUNK_SIZE + 1);
        int i = 0;
        IProgressMonitor useMe = subMonitor.newChild(1);
        for (IResourceDescription resourceDescription : indexData.getAllResourceDescriptions()) {
            IResourceServiceProvider serviceProvider = getServiceProviderRegistry().getResourceServiceProvider(resourceDescription.getURI());
            if (serviceProvider != null) {
                IReferenceFinder referenceFinder = serviceProvider.get(IReferenceFinder.class);
                if (referenceFinder instanceof IReferenceFinderExtension1) {
                    IReferenceFinderExtension1 extension1 = (IReferenceFinderExtension1) referenceFinder;
                    extension1.findReferences(targetURIsAsSet, resourceDescription, referenceAcceptor, useMe, localResourceAccess);
                } else {
                    // don't use the language specific reference finder here for backwards compatibility reasons
                    findReferences(targetURIsAsSet, resourceDescription, referenceAcceptor, useMe, localResourceAccess);
                }
            }
            i++;
            if (i % MONITOR_CHUNK_SIZE == 0) {
                useMe = subMonitor.newChild(1);
            }
        }
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) IReferenceFinder(org.eclipse.xtext.findReferences.IReferenceFinder) TargetURIs(org.eclipse.xtext.findReferences.TargetURIs)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IReferenceFinder (org.eclipse.xtext.findReferences.IReferenceFinder)1 TargetURIs (org.eclipse.xtext.findReferences.TargetURIs)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1 IResourceServiceProvider (org.eclipse.xtext.resource.IResourceServiceProvider)1