Package org.eclipse.handly.xtext.ui.callhierarchy

# Class XtextCallHierarchyUtility

java.lang.Object
org.eclipse.handly.xtext.ui.callhierarchy.XtextCallHierarchyUtility

public class XtextCallHierarchyUtility extends Object
Serves as a basis for the implementation of `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

  Fields
  Modifier and Type
  Field
  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`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `XtextCallHierarchyUtility()`
  Prevents direct instantiation.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `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.
  `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.
  `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.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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` - not `null`

  - ### setIndexData

    public void setIndexData(org.eclipse.xtext.resource.IResourceDescriptions indexData)
    Sets the index data.
    Parameters:
      `indexData` - not `null`

  - ### 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 the `referenceFinder` before they are passed to the given acceptor.

    Parameters:
      `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 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 the `referenceFinder` before they are passed to the given acceptor.

    Parameters:
      `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 receiver

  - ### getCallTextInfo

    public CallTextInfo getCallTextInfo(org.eclipse.xtext.resource.IReferenceDescription callReference)
    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` - not `null`
    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 not `null`. Clients usually need to override this method for a specific language.

    Parameters:
      `reference` - may be `null`, in which case `false` is returned
    Returns:
      `true` if the given reference is a call reference, and `false` 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 (never `null`)
      `callReference` - never `null`
      `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 the `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.

    Parameters:
      `objectUri` - never `null`
      `work` - never `null`
    Returns:
      the execution result (may be `null`)