/** * Find all references to the given target with its resource set as working environment. * * @param target * the object to look for. * @param monitor * the progress monitor. * @return the list of reference descriptions. */ public List<IReferenceDescription> findReferencesTo(EObject target, IProgressMonitor monitor) { final TargetURIs targetURIs = getTargetURIs(target); final ResourceSet resourceSet = target.eResource().getResourceSet(); final List<IReferenceDescription> result = Lists.newArrayList(); IReferenceFinder.IResourceAccess resourceAccess = new SimpleResourceAccess(resourceSet); IReferenceFinder.Acceptor acceptor = new IReferenceFinder.Acceptor() { @Override public void accept(IReferenceDescription description) { result.add(description); } @Override public void accept(EObject source, URI sourceURI, EReference eReference, int index, EObject targetOrProxy, URI targetURI) { accept(new DefaultReferenceDescription(sourceURI, targetURI, eReference, index, null)); } }; referenceFinder.findAllReferences(targetURIs, resourceAccess, resourceDescriptionsProvider.getResourceDescriptions(resourceSet), acceptor, monitor); return result; }
public List<? extends SymbolInformation> getSymbols(final String query, final IReferenceFinder.IResourceAccess resourceAccess, final IResourceDescriptions indexData, final CancelIndicator cancelIndicator) { final LinkedList<SymbolInformation> result = CollectionLiterals.<SymbolInformation>newLinkedList(); Iterable<IResourceDescription> _allResourceDescriptions = indexData.getAllResourceDescriptions(); for (final IResourceDescription resourceDescription : _allResourceDescriptions) { { this.operationCanceledManager.checkCanceled(cancelIndicator); final IResourceServiceProvider resourceServiceProvider = this._registry.getResourceServiceProvider(resourceDescription.getURI()); DocumentSymbolService _get = null; if (resourceServiceProvider!=null) { _get=resourceServiceProvider.<DocumentSymbolService>get(DocumentSymbolService.class); } final DocumentSymbolService documentSymbolService = _get; if ((documentSymbolService != null)) { List<? extends SymbolInformation> _symbols = documentSymbolService.getSymbols(resourceDescription, query, resourceAccess, cancelIndicator); Iterables.<SymbolInformation>addAll(result, _symbols); } } } return result; }
public List<? extends Location> getDefinitions(final XtextResource resource, final int offset, final IReferenceFinder.IResourceAccess resourceAccess, 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); for (final URI targetURI : targetURIs) { { this.operationCanceledManager.checkCanceled(cancelIndicator); final Procedure1<EObject> _function = (EObject obj) -> { final Location location = this._documentExtensions.newLocation(obj); if ((location != null)) { locations.add(location); } }; this.doRead(resourceAccess, targetURI, _function); } } return locations; }
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; }
public List<? extends SymbolInformation> getSymbols(final IResourceDescription resourceDescription, final String query, final IReferenceFinder.IResourceAccess resourceAccess, final CancelIndicator cancelIndicator) { final LinkedList<SymbolInformation> symbols = CollectionLiterals.<SymbolInformation>newLinkedList(); Iterable<IEObjectDescription> _exportedObjects = resourceDescription.getExportedObjects(); for (final IEObjectDescription description : _exportedObjects) { { this.operationCanceledManager.checkCanceled(cancelIndicator); boolean _filter = this.filter(description, query); if (_filter) { final Procedure1<SymbolInformation> _function = (SymbolInformation symbol) -> { symbols.add(symbol); }; this.createSymbol(description, resourceAccess, _function); } } } return symbols; }
/** * Get or create a data cache in the user data space of the given target URIs. * * @return a new or existing data cache. */ public Data getData(TargetURIs targetURIs, IReferenceFinder.IResourceAccess resourceAccess) { Data result = targetURIs.getUserData(KEY); if (result != null) { return result; } return initData(targetURIs, resourceAccess); }
/** * Configure the delegate. * * @param delegate * the delegate to use. */ public ForwardingResourceAccess(IReferenceFinder.IResourceAccess delegate, IResourceSetProvider resourceSetProvider) { this.delegate = delegate; this.resourceSetProvider = resourceSetProvider; }
public List<? extends Location> getReferences(final Document document, final XtextResource resource, final ReferenceParams params, final IReferenceFinder.IResourceAccess resourceAccess, final IResourceDescriptions indexData, final CancelIndicator cancelIndicator) { final int offset = document.getOffSet(params.getPosition()); List<? extends Location> _xifexpression = null; boolean _isIncludeDeclaration = params.getContext().isIncludeDeclaration(); if (_isIncludeDeclaration) { _xifexpression = this.getDefinitions(resource, offset, resourceAccess, cancelIndicator); } else { _xifexpression = CollectionLiterals.emptyList(); } final List<? extends Location> definitions = _xifexpression; final List<? extends Location> references = this.getReferences(resource, offset, resourceAccess, indexData, cancelIndicator); final Iterable<Location> result = Iterables.<Location>concat(definitions, references); return IterableExtensions.<Location>toList(result); }
protected void createSymbol(final IEObjectDescription description, final IReferenceFinder.IResourceAccess resourceAccess, final Procedure1<? super SymbolInformation> acceptor) { final String name = this.getSymbolName(description); if ((name == null)) { return; } final SymbolKind kind = this.getSymbolKind(description); if ((kind == null)) { return; } final Procedure1<Location> _function = (Location location) -> { final SymbolInformation symbol = new SymbolInformation(name, kind, location); acceptor.apply(symbol); }; this.getSymbolLocation(description, resourceAccess, _function); }
protected void getSymbolLocation(final IEObjectDescription description, final IReferenceFinder.IResourceAccess resourceAccess, final Procedure1<? super Location> acceptor) { final Procedure1<EObject> _function = (EObject obj) -> { final Location location = this.getSymbolLocation(obj); if ((location != null)) { acceptor.apply(location); } }; this.doRead(resourceAccess, description.getEObjectURI(), _function); }
protected void doRead(final IReferenceFinder.IResourceAccess resourceAccess, final URI objectURI, final Procedure1<? super EObject> acceptor) { final IUnitOfWork<Object, ResourceSet> _function = (ResourceSet resourceSet) -> { final EObject object = resourceSet.getEObject(objectURI, true); if ((object != null)) { acceptor.apply(object); } return null; }; resourceAccess.<Object>readOnly(objectURI, _function); }
private Data initData(TargetURIs targetURIs, IReferenceFinder.IResourceAccess resourceAccess) { Data result = new Data(qualifiedNameProvider); init(result, resourceAccess, targetURIs); targetURIs.putUserData(KEY, result); return result; }
/***/ public Class<? extends IReferenceFinder> bindReferenceFinder() { return ConcreteSyntaxAwareReferenceFinder.class; }
public List<? extends Location> getDefinitions(final Document document, final XtextResource resource, final TextDocumentPositionParams params, final IReferenceFinder.IResourceAccess resourceAccess, final CancelIndicator cancelIndicator) { final int offset = document.getOffSet(params.getPosition()); return this.getDefinitions(resource, offset, resourceAccess, cancelIndicator); }
@Pure protected IReferenceFinder.IResourceAccess getResourceAccess() { return this.resourceAccess; }
public void setResourceAccess(final IReferenceFinder.IResourceAccess resourceAccess) { this.resourceAccess = resourceAccess; }
@Pure protected IReferenceFinder getReferenceFinder() { return this.referenceFinder; }
public void setReferenceFinder(final IReferenceFinder referenceFinder) { this.referenceFinder = referenceFinder; }
/** * Bind the {@link org.eclipse.xtext.ui.editor.findrefs.IReferenceFinder} that find references solely to types (and * TVariables, IdentifiableElement and TEnumLiterals). */ public Class<? extends org.eclipse.xtext.ui.editor.findrefs.IReferenceFinder> bindIReferenceFinder() { return LabellingReferenceFinder.class; }