Class: RubyLsp::Requests::DocumentHighlight
- Extended by:
- T::Sig
- Defined in:
- lib/ruby_lsp/requests/document_highlight.rb
Overview

The [document highlight](microsoft.github.io/language-server-protocol/specification#textDocument_documentHighlight) informs the editor all relevant elements of the currently pointed item for highlighting. For example, when the cursor is on the ‘F` of the constant `FOO`, the editor should identify other occurrences of `FOO` and highlight them.
For writable elements like constants or variables, their read/write occurrences should be highlighted differently. This is achieved by sending different “kind” attributes to the editor (2 for read and 3 for write).
# Example
“‘ruby FOO = 1 # should be highlighted as “write”
def foo
FOO # should be highlighted as "read"
end “‘
Constant Summary collapse
- ResponseType =
type_member { { fixed: T::Array[Interface::DocumentHighlight] } }
Instance Method Summary collapse
-
#initialize(document, position, dispatcher) ⇒ DocumentHighlight
constructor
A new instance of DocumentHighlight.
- #perform ⇒ Object
Constructor Details
#initialize(document, position, dispatcher) ⇒ DocumentHighlight
Returns a new instance of DocumentHighlight.
39 40 41 42 43 |
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 39 def initialize(document, position, dispatcher) super() target, parent = document.locate_node(position) @listener = T.let(Listeners::DocumentHighlight.new(target, parent, dispatcher), Listener[ResponseType]) end |
Instance Method Details
#perform ⇒ Object
46 47 48 |
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 46 def perform @listener.response end |