Search in sources :

Example 1 with ReferenceAcceptor

use of org.eclipse.xtext.findReferences.ReferenceAcceptor 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)

Example 2 with ReferenceAcceptor

use of org.eclipse.xtext.findReferences.ReferenceAcceptor in project xtext-core by eclipse.

the class DefaultCallHierarchyBuilder method findTargetDeclarations.

protected void findTargetDeclarations(final URI sourceDeclarationURI, final IProgressMonitor monitor, final Procedure2<? super IEObjectDescription, ? super IReferenceDescription> acceptor) {
    final IUnitOfWork<Object, EObject> _function = (EObject sourceDeclaration) -> {
        Object _xblockexpression = null;
        {
            IResourceServiceProvider.Registry _resourceServiceProviderRegistry = this.getResourceServiceProviderRegistry();
            final IAcceptor<IReferenceDescription> _function_1 = (IReferenceDescription reference) -> {
                boolean _filterReference = this.filterReference(reference);
                if (_filterReference) {
                    IEObjectDescription _findTargetDeclaration = null;
                    if (reference != null) {
                        _findTargetDeclaration = this.findTargetDeclaration(reference);
                    }
                    final IEObjectDescription targetDeclaration = _findTargetDeclaration;
                    acceptor.apply(targetDeclaration, reference);
                }
            };
            ReferenceAcceptor _referenceAcceptor = new ReferenceAcceptor(_resourceServiceProviderRegistry, _function_1);
            this.getReferenceFinder().findAllReferences(sourceDeclaration, _referenceAcceptor, monitor);
            _xblockexpression = null;
        }
        return _xblockexpression;
    };
    this.<Object>readOnly(sourceDeclarationURI, _function);
}
Also used : ReferenceAcceptor(org.eclipse.xtext.findReferences.ReferenceAcceptor) IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) EObject(org.eclipse.emf.ecore.EObject) EObject(org.eclipse.emf.ecore.EObject) IReferenceDescription(org.eclipse.xtext.resource.IReferenceDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Example 3 with ReferenceAcceptor

use of org.eclipse.xtext.findReferences.ReferenceAcceptor in project xtext-core by eclipse.

the class DefaultCallHierarchyBuilder method findSourceDeclarations.

protected void findSourceDeclarations(final URI targetDeclarationURI, final IProgressMonitor monitor, final Procedure2<? super IEObjectDescription, ? super IReferenceDescription> acceptor) {
    final TargetURIs targetURIs = this.collectTargetURIs(targetDeclarationURI);
    IResourceServiceProvider.Registry _resourceServiceProviderRegistry = this.getResourceServiceProviderRegistry();
    final IAcceptor<IReferenceDescription> _function = (IReferenceDescription reference) -> {
        boolean _filterReference = this.filterReference(reference);
        if (_filterReference) {
            IEObjectDescription _findSourceDeclaration = null;
            if (reference != null) {
                _findSourceDeclaration = this.findSourceDeclaration(reference);
            }
            final IEObjectDescription sourceDeclaration = _findSourceDeclaration;
            acceptor.apply(sourceDeclaration, reference);
        }
    };
    ReferenceAcceptor _referenceAcceptor = new ReferenceAcceptor(_resourceServiceProviderRegistry, _function);
    this.getReferenceFinder().findAllReferences(targetURIs, this.getResourceAccess(), this.getIndexData(), _referenceAcceptor, monitor);
}
Also used : ReferenceAcceptor(org.eclipse.xtext.findReferences.ReferenceAcceptor) IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) TargetURIs(org.eclipse.xtext.findReferences.TargetURIs) IReferenceDescription(org.eclipse.xtext.resource.IReferenceDescription) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Aggregations

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