public class XtextCallHierarchyUtility
extends java.lang.Object
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.
Modifier and Type | Field and Description |
---|---|
protected org.eclipse.xtext.resource.IResourceDescriptions |
indexData |
protected org.eclipse.xtext.resource.ILocationInFileProvider |
locationInFileProvider |
protected org.eclipse.xtext.findReferences.IReferenceFinder |
referenceFinder |
protected org.eclipse.xtext.findReferences.IReferenceFinder.IResourceAccess |
resourceAccess |
protected org.eclipse.xtext.resource.IResourceServiceProvider.Registry |
resourceServiceProviderRegistry |
protected com.google.inject.Provider<org.eclipse.xtext.findReferences.TargetURIs> |
targetUrisProvider |
Modifier | Constructor and Description |
---|---|
protected |
XtextCallHierarchyUtility()
Prevents direct instantiation.
|
Modifier and Type | Method and Description |
---|---|
void |
findCalleeReferences(org.eclipse.emf.common.util.URI callerUri,
java.util.function.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,
java.util.function.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.
|
CallTextInfo |
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 the
EObject 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.
|
protected org.eclipse.xtext.findReferences.IReferenceFinder.IResourceAccess resourceAccess
protected org.eclipse.xtext.resource.IResourceDescriptions indexData
@Inject protected org.eclipse.xtext.findReferences.IReferenceFinder referenceFinder
@Inject protected com.google.inject.Provider<org.eclipse.xtext.findReferences.TargetURIs> targetUrisProvider
@Inject protected org.eclipse.xtext.resource.IResourceServiceProvider.Registry resourceServiceProviderRegistry
@Inject protected org.eclipse.xtext.resource.ILocationInFileProvider locationInFileProvider
protected XtextCallHierarchyUtility()
public void setResourceAccess(org.eclipse.xtext.findReferences.IReferenceFinder.IResourceAccess resourceAccess)
resourceAccess
- not null
public void setIndexData(org.eclipse.xtext.resource.IResourceDescriptions indexData)
indexData
- not null
public void findCallerReferences(org.eclipse.emf.common.util.URI calleeUri, java.util.function.Consumer<org.eclipse.xtext.resource.IReferenceDescription> acceptor, org.eclipse.core.runtime.IProgressMonitor monitor)
This implementation calls isCallReference(IReferenceDescription)
to filter the references reported by the referenceFinder
before they are passed to the given acceptor.
calleeUri
- not null
acceptor
- accepts the matches (not null
)monitor
- a progress monitor, or null
if progress reporting is not desired. The caller must not rely on
IProgressMonitor.done()
having been called by the receiverpublic void findCalleeReferences(org.eclipse.emf.common.util.URI callerUri, java.util.function.Consumer<org.eclipse.xtext.resource.IReferenceDescription> acceptor, org.eclipse.core.runtime.IProgressMonitor monitor)
This implementation calls isCallReference(IReferenceDescription)
to filter the references reported by the referenceFinder
before they are passed to the given acceptor.
callerUri
- not null
acceptor
- accepts the matches (not null
)monitor
- a progress monitor, or null
if progress reporting is not desired. The caller must not rely on
IProgressMonitor.done()
having been called by the receiverpublic CallTextInfo getCallTextInfo(org.eclipse.xtext.resource.IReferenceDescription callReference)
This implementation invokes getCallRegion(EObject, EReference, int)
to obtain the call text region.
callReference
- not null
null
)protected boolean isCallReference(org.eclipse.xtext.resource.IReferenceDescription reference)
Default implementation returns true
iff the given reference
is not null
. Clients usually need to override this method
for a specific language.
reference
- may be null
,
in which case false
is returnedtrue
if the given reference is a call reference,
and false
otherwiseprotected org.eclipse.xtext.util.ITextRegion getCallRegion(org.eclipse.emf.ecore.EObject owner, org.eclipse.emf.ecore.EReference callReference, int indexInList)
Default implementation returns the significant region as reported
by the locationInFileProvider
. Clients may need to override
this method for a specific language.
owner
- the owner of the reference (never null
)callReference
- never null
indexInList
- the index of the reference,
or -1 if it is a single value referencenull
)protected <R> R readOnly(org.eclipse.emf.common.util.URI objectUri, org.eclipse.xtext.util.concurrent.IUnitOfWork<R,org.eclipse.emf.ecore.EObject> work)
EObject
identified by the given URI. Note that this method
may return null
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.
objectUri
- never null
work
- never null
null
)Copyright (c) 2014, 2019 1C-Soft LLC and others. Made available under the Eclipse Public License 2.0