Class DefaultDocumentHighlightService
java.lang.Object
org.eclipse.xtext.ide.server.occurrences.DefaultDocumentHighlightService
- All Implemented Interfaces:
IDocumentHighlightService
Default implementation of the
document
highlight service
.- Author:
- akos.kitta - Initial contribution and API
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.eclipse.xtext.resource.ILocationInFileProvider
protected org.eclipse.xtext.resource.EObjectAtOffsetHelper
protected ITextRegionTransformer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionList<? 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 withtrue
if the AST element selected from the resource can provide document highlights, otherwise returns withfalse
.protected boolean
isNullOrEmpty
(org.eclipse.xtext.util.ITextRegion region) Returnstrue
if the argument is eithernull
orempty
.
-
Field Details
-
offsetHelper
@Inject protected org.eclipse.xtext.resource.EObjectAtOffsetHelper offsetHelper -
locationInFileProvider
@Inject protected org.eclipse.xtext.resource.ILocationInFileProvider locationInFileProvider -
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 interfaceIDocumentHighlightService
-
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 withtrue
if the AST element selected from the resource can provide document highlights, otherwise returns withfalse
.Clients may override this method to change the default behavior.
- Parameters:
selectedElement
- the selected element resolved via the offset from the resource. Can benull
.resource
- the resource for the document.offset
- the offset of the selection.- Returns:
true
if the document highlight is available for the selected element, otherwisefalse
.
-
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 noeContainer()
.- 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) Returnstrue
if the argument is eithernull
orempty
. Otherwise returns withfalse
.- Returns:
true
if the argument is eithernull
or empty.
-