Java Code Examples for org.eclipse.xtext.findReferences.IReferenceFinder#IResourceAccess
The following examples show how to use
org.eclipse.xtext.findReferences.IReferenceFinder#IResourceAccess .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HeadlessReferenceFinder.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * 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; }
Example 2
Source File: DocumentSymbolService.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public List<? extends Location> getDefinitions(XtextResource resource, int offset, IReferenceFinder.IResourceAccess resourceAccess, CancelIndicator cancelIndicator) { EObject element = eObjectAtOffsetHelper.resolveElementAt(resource, offset); if (element == null) { return Collections.emptyList(); } List<Location> locations = new ArrayList<>(); TargetURIs targetURIs = collectTargetURIs(element); for (URI targetURI : targetURIs) { operationCanceledManager.checkCanceled(cancelIndicator); doRead(resourceAccess, targetURI, (EObject obj) -> { Location location = documentExtensions.newLocation(obj); if (location != null) { locations.add(location); } }); } return locations; }
Example 3
Source File: DocumentSymbolService.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public List<? extends Location> getReferences(XtextResource resource, int offset, IReferenceFinder.IResourceAccess resourceAccess, IResourceDescriptions indexData, CancelIndicator cancelIndicator) { EObject element = eObjectAtOffsetHelper.resolveElementAt(resource, offset); if (element == null) { return Collections.emptyList(); } List<Location> locations = new ArrayList<>(); TargetURIs targetURIs = collectTargetURIs(element); referenceFinder.findAllReferences(targetURIs, resourceAccess, indexData, new ReferenceAcceptor(resourceServiceProviderRegistry, (IReferenceDescription reference) -> { doRead(resourceAccess, reference.getSourceEObjectUri(), (EObject obj) -> { Location location = documentExtensions.newLocation(obj, reference.getEReference(), reference.getIndexInList()); if (location != null) { locations.add(location); } }); }), new CancelIndicatorProgressMonitor(cancelIndicator)); return locations; }
Example 4
Source File: TargetURIKey.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * 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); }
Example 5
Source File: ForwardingResourceAccess.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Configure the delegate. * * @param delegate * the delegate to use. */ public ForwardingResourceAccess(IReferenceFinder.IResourceAccess delegate, IResourceSetProvider resourceSetProvider) { this.delegate = delegate; this.resourceSetProvider = resourceSetProvider; }
Example 6
Source File: Declarators.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public Declarators.DeclaratorsData getDeclaratorData(final TargetURIs targetURIs, final IReferenceFinder.IResourceAccess resourceAccess) { Declarators.DeclaratorsData result = targetURIs.<Declarators.DeclaratorsData>getUserData(Declarators.KEY); if ((result != null)) { return result; } final HashSet<QualifiedName> declaratorNames = CollectionLiterals.<QualifiedName>newHashSet(); final Consumer<URI> _function = (URI uri) -> { final IUnitOfWork<Object, ResourceSet> _function_1 = (ResourceSet it) -> { Object _xblockexpression = null; { final Consumer<URI> _function_2 = (URI objectURI) -> { final EObject object = it.getEObject(objectURI, true); if ((object != null)) { final JvmType type = EcoreUtil2.<JvmType>getContainerOfType(object, JvmType.class); if ((type != null)) { QualifiedName _lowerCase = this.nameConverter.toQualifiedName(type.getIdentifier()).toLowerCase(); declaratorNames.add(_lowerCase); QualifiedName _lowerCase_1 = this.nameConverter.toQualifiedName(type.getQualifiedName('.')).toLowerCase(); declaratorNames.add(_lowerCase_1); } } }; targetURIs.getEObjectURIs(uri).forEach(_function_2); _xblockexpression = null; } return _xblockexpression; }; resourceAccess.<Object>readOnly(uri, _function_1); }; targetURIs.getTargetResourceURIs().forEach(_function); Declarators.DeclaratorsData _declaratorsData = new Declarators.DeclaratorsData(declaratorNames); result = _declaratorsData; targetURIs.<Declarators.DeclaratorsData>putUserData(Declarators.KEY, result); return result; }
Example 7
Source File: DocumentSymbolService.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
public List<? extends Location> getReferences(Document document, XtextResource resource, ReferenceParams params, IReferenceFinder.IResourceAccess resourceAccess, IResourceDescriptions indexData, CancelIndicator cancelIndicator) { int offset = document.getOffSet(params.getPosition()); List<? extends Location> definitions = Collections.emptyList(); if (params.getContext().isIncludeDeclaration()) { definitions = getDefinitions(resource, offset, resourceAccess, cancelIndicator); } List<? extends Location> references = getReferences(resource, offset, resourceAccess, indexData, cancelIndicator); List<Location> result = new ArrayList<>(); result.addAll(definitions); result.addAll(references); return result; }
Example 8
Source File: DocumentSymbolService.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
public List<? extends SymbolInformation> getSymbols(IResourceDescription resourceDescription, String query, IReferenceFinder.IResourceAccess resourceAccess, CancelIndicator cancelIndicator) { List<SymbolInformation> symbols = new LinkedList<>(); for (IEObjectDescription description : resourceDescription.getExportedObjects()) { operationCanceledManager.checkCanceled(cancelIndicator); if (filter(description, query)) { createSymbol(description, resourceAccess, (SymbolInformation symbol) -> { symbols.add(symbol); }); } } return symbols; }
Example 9
Source File: DocumentSymbolService.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected void createSymbol(IEObjectDescription description, IReferenceFinder.IResourceAccess resourceAccess, Procedure1<? super SymbolInformation> acceptor) { String name = getSymbolName(description); if (name == null) { return; } SymbolKind kind = getSymbolKind(description); if (kind == null) { return; } getSymbolLocation(description, resourceAccess, (Location location) -> { SymbolInformation symbol = new SymbolInformation(name, kind, location); acceptor.apply(symbol); }); }
Example 10
Source File: DocumentSymbolService.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected void getSymbolLocation(IEObjectDescription description, IReferenceFinder.IResourceAccess resourceAccess, Procedure1<? super Location> acceptor) { doRead(resourceAccess, description.getEObjectURI(), (EObject obj) -> { Location location = getSymbolLocation(obj); if (location != null) { acceptor.apply(location); } }); }
Example 11
Source File: DocumentSymbolService.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected void doRead(IReferenceFinder.IResourceAccess resourceAccess, URI objectURI, Procedure1<? super EObject> acceptor) { resourceAccess.readOnly(objectURI, (ResourceSet resourceSet) -> { EObject object = resourceSet.getEObject(objectURI, true); if (object != null) { acceptor.apply(object); } return null; }); }
Example 12
Source File: TargetURIKey.java From n4js with Eclipse Public License 1.0 | 4 votes |
private Data initData(TargetURIs targetURIs, IReferenceFinder.IResourceAccess resourceAccess) { Data result = new Data(qualifiedNameProvider); init(result, resourceAccess, targetURIs); targetURIs.putUserData(KEY, result); return result; }
Example 13
Source File: LanguageServerImpl.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.16 */ protected IReferenceFinder.IResourceAccess getWorkspaceResourceAccess() { return resourceAccess; }
Example 14
Source File: DocumentSymbolService.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.21 */ public List<? extends Location> getDefinitions(Document document, XtextResource resource, DefinitionParams params, IReferenceFinder.IResourceAccess resourceAccess, CancelIndicator cancelIndicator) { int offset = document.getOffSet(params.getPosition()); return getDefinitions(resource, offset, resourceAccess, cancelIndicator); }
Example 15
Source File: AbstractHierarchyBuilder.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected IReferenceFinder.IResourceAccess getResourceAccess() { return resourceAccess; }
Example 16
Source File: AbstractHierarchyBuilder.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public void setResourceAccess(IReferenceFinder.IResourceAccess resourceAccess) { this.resourceAccess = resourceAccess; }