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 “‘
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.
37 38 39 40 41 42 43 44 45 |
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 37 def initialize(document, position, dispatcher) super() node_context = document.locate_node(position) @response_builder = T.let( ResponseBuilders::CollectionResponseBuilder[Interface::DocumentHighlight].new, ResponseBuilders::CollectionResponseBuilder[Interface::DocumentHighlight], ) Listeners::DocumentHighlight.new(@response_builder, node_context.node, node_context.parent, dispatcher) end |
Instance Method Details
#perform ⇒ Object
48 49 50 |
# File 'lib/ruby_lsp/requests/document_highlight.rb', line 48 def perform @response_builder.response end |