Search in sources :

Example 1 with CancelIndicatorProgressMonitor

use of org.eclipse.xtext.ide.util.CancelIndicatorProgressMonitor in project xtext-core by eclipse.

the class DocumentSymbolService method getReferences.

public List<? extends Location> getReferences(final XtextResource resource, final int offset, final IReferenceFinder.IResourceAccess resourceAccess, final IResourceDescriptions indexData, final CancelIndicator cancelIndicator) {
    final EObject element = this._eObjectAtOffsetHelper.resolveElementAt(resource, offset);
    if ((element == null)) {
        return CollectionLiterals.<Location>emptyList();
    }
    final ArrayList<Location> locations = CollectionLiterals.<Location>newArrayList();
    final TargetURIs targetURIs = this.collectTargetURIs(element);
    final IAcceptor<IReferenceDescription> _function = (IReferenceDescription reference) -> {
        final Procedure1<EObject> _function_1 = (EObject obj) -> {
            final Location location = this._documentExtensions.newLocation(obj, reference.getEReference(), reference.getIndexInList());
            if ((location != null)) {
                locations.add(location);
            }
        };
        this.doRead(resourceAccess, reference.getSourceEObjectUri(), _function_1);
    };
    ReferenceAcceptor _referenceAcceptor = new ReferenceAcceptor(this.resourceServiceProviderRegistry, _function);
    CancelIndicatorProgressMonitor _cancelIndicatorProgressMonitor = new CancelIndicatorProgressMonitor(cancelIndicator);
    this.referenceFinder.findAllReferences(targetURIs, resourceAccess, indexData, _referenceAcceptor, _cancelIndicatorProgressMonitor);
    return locations;
}
Also used : ReferenceAcceptor(org.eclipse.xtext.findReferences.ReferenceAcceptor) EObject(org.eclipse.emf.ecore.EObject) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) TargetURIs(org.eclipse.xtext.findReferences.TargetURIs) CancelIndicatorProgressMonitor(org.eclipse.xtext.ide.util.CancelIndicatorProgressMonitor) Location(org.eclipse.lsp4j.Location) IReferenceDescription(org.eclipse.xtext.resource.IReferenceDescription)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)1 Location (org.eclipse.lsp4j.Location)1 ReferenceAcceptor (org.eclipse.xtext.findReferences.ReferenceAcceptor)1 TargetURIs (org.eclipse.xtext.findReferences.TargetURIs)1 CancelIndicatorProgressMonitor (org.eclipse.xtext.ide.util.CancelIndicatorProgressMonitor)1 IReferenceDescription (org.eclipse.xtext.resource.IReferenceDescription)1 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)1