Class DefaultDocumentHighlightService

java.lang.Object
org.eclipse.xtext.ide.server.occurrences.DefaultDocumentHighlightService
All Implemented Interfaces:
IDocumentHighlightService

public class DefaultDocumentHighlightService extends Object implements IDocumentHighlightService
Default implementation of the document highlight service.
Author:
akos.kitta - Initial contribution and API
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.eclipse.xtext.resource.ILocationInFileProvider
     
    protected org.eclipse.xtext.resource.EObjectAtOffsetHelper
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    List<? extends org.eclipse.lsp4j.DocumentHighlight>
    getDocumentHighlights(Document document, org.eclipse.xtext.resource.XtextResource resource, org.eclipse.lsp4j.DocumentHighlightParams params, org.eclipse.xtext.util.CancelIndicator cancelIndicator)
     
    List<org.eclipse.lsp4j.DocumentHighlight>
    getDocumentHighlights(org.eclipse.xtext.resource.XtextResource resource, int offset)
     
    protected com.google.common.base.Predicate<org.eclipse.emf.ecore.EObject>
    Returns with a filter that is used to ignore elements at a given offset.
    protected Iterable<org.eclipse.emf.common.util.URI>
    getTargetURIs(org.eclipse.emf.ecore.EObject primaryTarget)
    Returns with an iterable of URIs that points to all elements that are referenced by the argument or vice-versa.
    protected boolean
    isDocumentHighlightAvailableFor(org.eclipse.emf.ecore.EObject selectedElement, org.eclipse.xtext.resource.XtextResource resource, int offset)
    Returns with true if the AST element selected from the resource can provide document highlights, otherwise returns with false.
    protected boolean
    isNullOrEmpty(org.eclipse.xtext.util.ITextRegion region)
    Returns true if the argument is either null or empty.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • offsetHelper

      @Inject protected org.eclipse.xtext.resource.EObjectAtOffsetHelper offsetHelper
    • locationInFileProvider

      @Inject protected org.eclipse.xtext.resource.ILocationInFileProvider locationInFileProvider
    • textRegionTransformer

      @Inject protected ITextRegionTransformer textRegionTransformer
  • Constructor Details

    • DefaultDocumentHighlightService

      public DefaultDocumentHighlightService()
  • Method Details

    • getDocumentHighlights

      public List<? extends org.eclipse.lsp4j.DocumentHighlight> getDocumentHighlights(Document document, org.eclipse.xtext.resource.XtextResource resource, org.eclipse.lsp4j.DocumentHighlightParams params, org.eclipse.xtext.util.CancelIndicator cancelIndicator)
      Specified by:
      getDocumentHighlights in interface IDocumentHighlightService
    • getDocumentHighlights

      public List<org.eclipse.lsp4j.DocumentHighlight> getDocumentHighlights(org.eclipse.xtext.resource.XtextResource resource, int offset)
    • isDocumentHighlightAvailableFor

      protected boolean isDocumentHighlightAvailableFor(org.eclipse.emf.ecore.EObject selectedElement, org.eclipse.xtext.resource.XtextResource resource, int offset)
      Returns with true if the AST element selected from the resource can provide document highlights, otherwise returns with false.

      Clients may override this method to change the default behavior.

      Parameters:
      selectedElement - the selected element resolved via the offset from the resource. Can be null.
      resource - the resource for the document.
      offset - the offset of the selection.
      Returns:
      true if the document highlight is available for the selected element, otherwise false.
    • getSelectedElementFilter

      protected com.google.common.base.Predicate<org.eclipse.emf.ecore.EObject> getSelectedElementFilter()
      Returns with a filter that is used to ignore elements at a given offset.

      By default returns with a filter that skips all EObject instances that have no eContainer().

      Returns:
      a function that will be used to skip elements selected on the given offset.
    • getTargetURIs

      protected Iterable<org.eclipse.emf.common.util.URI> getTargetURIs(org.eclipse.emf.ecore.EObject primaryTarget)
      Returns with an iterable of URIs that points to all elements that are referenced by the argument or vice-versa.
      Returns:
      an iterable of URIs that are referenced by the argument or the other way around.
    • isNullOrEmpty

      protected boolean isNullOrEmpty(org.eclipse.xtext.util.ITextRegion region)
      Returns true if the argument is either null or empty. Otherwise returns with false.
      Returns:
      true if the argument is either null or empty.