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.IResourceDescriptions
protected org.eclipse.xtext.resource.ILocationInFileProvider
protected org.eclipse.xtext.findReferences.IReferenceFinder
protected org.eclipse.xtext.findReferences.IReferenceFinder.IResourceAccess
protected org.eclipse.xtext.resource.IResourceServiceProvider.Registry
protected com.google.inject.Provider<org.eclipse.xtext.findReferences.TargetURIs>
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Prevents direct instantiation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.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.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.getCallTextInfo
(org.eclipse.xtext.resource.IReferenceDescription callReference) Returns the call text info based on the given call reference.protected boolean
isCallReference
(org.eclipse.xtext.resource.IReferenceDescription reference) Returns whether the given reference is a call reference.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 theEObject
identified by the given URI.void
setIndexData
(org.eclipse.xtext.resource.IResourceDescriptions indexData) Sets the index data.void
setResourceAccess
(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 thereferenceFinder
before they are passed to the given acceptor.- Parameters:
calleeUri
- notnull
acceptor
- accepts the matches (notnull
)monitor
- a progress monitor, ornull
if 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 thereferenceFinder
before they are passed to the given acceptor.- Parameters:
callerUri
- notnull
acceptor
- accepts the matches (notnull
)monitor
- a progress monitor, ornull
if 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
true
iff the given reference is notnull
. Clients usually need to override this method for a specific language.- Parameters:
reference
- may benull
, in which casefalse
is returned- Returns:
true
if the given reference is a call reference, andfalse
otherwise
-
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
- nevernull
indexInList
- 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 theEObject
identified by the given URI. Note that this method may returnnull
if it was not able to start executing the unit of work for some reason.This implementation uses the
resourceAccess
to provide safe read access to the object.- Parameters:
objectUri
- nevernull
work
- nevernull
- Returns:
- the execution result (may be
null
)
-