Class XtextCallHierarchyUtility
XtextCallHierarchyNode
by providing API and default implementation to find the call references
and obtain the call text info.
Usually, clients need to override methods isCallReference(IReferenceDescription)
and/or getCallRegion(EObject, EReference, int) in a language-specific
subclass.
An instance of this class is intended to be created by Guice. Also, clients
need to set a resource access and an index data before using an instance of this class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.eclipse.xtext.resource.IResourceDescriptionsprotected org.eclipse.xtext.resource.ILocationInFileProviderprotected org.eclipse.xtext.findReferences.IReferenceFinderprotected org.eclipse.xtext.findReferences.IReferenceFinder.IResourceAccessprotected org.eclipse.xtext.resource.IResourceServiceProvider.Registryprotected com.google.inject.Provider<org.eclipse.xtext.findReferences.TargetURIs> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPrevents direct instantiation. -
Method Summary
Modifier and TypeMethodDescriptionvoidfindCalleeReferences(org.eclipse.emf.common.util.URI callerUri, Consumer<org.eclipse.xtext.resource.IReferenceDescription> acceptor, org.eclipse.core.runtime.IProgressMonitor monitor) Finds the callee references from the caller identified by the given URI.voidfindCallerReferences(org.eclipse.emf.common.util.URI calleeUri, Consumer<org.eclipse.xtext.resource.IReferenceDescription> acceptor, org.eclipse.core.runtime.IProgressMonitor monitor) Finds the caller references to the callee identified by the given URI.protected org.eclipse.xtext.util.ITextRegiongetCallRegion(org.eclipse.emf.ecore.EObject owner, org.eclipse.emf.ecore.EReference callReference, int indexInList) Returns the text region for the given call reference.getCallTextInfo(org.eclipse.xtext.resource.IReferenceDescription callReference) Returns the call text info based on the given call reference.protected booleanisCallReference(org.eclipse.xtext.resource.IReferenceDescription reference) Returns whether the given reference is a call reference.protected <R> RreadOnly(org.eclipse.emf.common.util.URI objectUri, org.eclipse.xtext.util.concurrent.IUnitOfWork<R, org.eclipse.emf.ecore.EObject> work) Executes the given unit of work while providing it with safe read access to theEObjectidentified by the given URI.voidsetIndexData(org.eclipse.xtext.resource.IResourceDescriptions indexData) Sets the index data.voidsetResourceAccess(org.eclipse.xtext.findReferences.IReferenceFinder.IResourceAccess resourceAccess) Sets the resource access.
-
Field Details
-
resourceAccess
protected org.eclipse.xtext.findReferences.IReferenceFinder.IResourceAccess resourceAccess -
indexData
protected org.eclipse.xtext.resource.IResourceDescriptions indexData -
referenceFinder
@Inject protected org.eclipse.xtext.findReferences.IReferenceFinder referenceFinder -
targetUrisProvider
@Inject protected com.google.inject.Provider<org.eclipse.xtext.findReferences.TargetURIs> targetUrisProvider -
resourceServiceProviderRegistry
@Inject protected org.eclipse.xtext.resource.IResourceServiceProvider.Registry resourceServiceProviderRegistry -
locationInFileProvider
@Inject protected org.eclipse.xtext.resource.ILocationInFileProvider locationInFileProvider
-
-
Constructor Details
-
XtextCallHierarchyUtility
protected XtextCallHierarchyUtility()Prevents direct instantiation. An instance of this class is intended to be created by Guice.
-
-
Method Details
-
setResourceAccess
public void setResourceAccess(org.eclipse.xtext.findReferences.IReferenceFinder.IResourceAccess resourceAccess) Sets the resource access.- Parameters:
resourceAccess- notnull
-
setIndexData
public void setIndexData(org.eclipse.xtext.resource.IResourceDescriptions indexData) Sets the index data.- Parameters:
indexData- notnull
-
findCallerReferences
public void findCallerReferences(org.eclipse.emf.common.util.URI calleeUri, Consumer<org.eclipse.xtext.resource.IReferenceDescription> acceptor, org.eclipse.core.runtime.IProgressMonitor monitor) Finds the caller references to the callee identified by the given URI.This implementation calls
isCallReference(IReferenceDescription)to filter the references reported by thereferenceFinderbefore they are passed to the given acceptor.- Parameters:
calleeUri- notnullacceptor- accepts the matches (notnull)monitor- a progress monitor, ornullif progress reporting is not desired. The caller must not rely onIProgressMonitor.done()having been called by the receiver
-
findCalleeReferences
public void findCalleeReferences(org.eclipse.emf.common.util.URI callerUri, Consumer<org.eclipse.xtext.resource.IReferenceDescription> acceptor, org.eclipse.core.runtime.IProgressMonitor monitor) Finds the callee references from the caller identified by the given URI.This implementation calls
isCallReference(IReferenceDescription)to filter the references reported by thereferenceFinderbefore they are passed to the given acceptor.- Parameters:
callerUri- notnullacceptor- accepts the matches (notnull)monitor- a progress monitor, ornullif progress reporting is not desired. The caller must not rely onIProgressMonitor.done()having been called by the receiver
-
getCallTextInfo
Returns the call text info based on the given call reference.This implementation invokes
getCallRegion(EObject, EReference, int)to obtain the call text region.- Parameters:
callReference- notnull- Returns:
- the call text info (never
null)
-
isCallReference
protected boolean isCallReference(org.eclipse.xtext.resource.IReferenceDescription reference) Returns whether the given reference is a call reference.Default implementation returns
trueiff the given reference is notnull. Clients usually need to override this method for a specific language.- Parameters:
reference- may benull, in which casefalseis returned- Returns:
trueif the given reference is a call reference, andfalseotherwise
-
getCallRegion
protected org.eclipse.xtext.util.ITextRegion getCallRegion(org.eclipse.emf.ecore.EObject owner, org.eclipse.emf.ecore.EReference callReference, int indexInList) Returns the text region for the given call reference.Default implementation returns the significant region as reported by the
locationInFileProvider. Clients may need to override this method for a specific language.- Parameters:
owner- the owner of the reference (nevernull)callReference- nevernullindexInList- the index of the reference, or -1 if it is a single value reference- Returns:
- the call region (not
null)
-
readOnly
protected <R> R readOnly(org.eclipse.emf.common.util.URI objectUri, org.eclipse.xtext.util.concurrent.IUnitOfWork<R, org.eclipse.emf.ecore.EObject> work) Executes the given unit of work while providing it with safe read access to theEObjectidentified by the given URI. Note that this method may returnnullif it was not able to start executing the unit of work for some reason.This implementation uses the
resourceAccessto provide safe read access to the object.- Parameters:
objectUri- nevernullwork- nevernull- Returns:
- the execution result (may be
null)
-