Class: RubyLsp::Requests::DocumentLink

Inherits:
Request
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/ruby_lsp/requests/document_link.rb

Overview

![Document link demo](../../document_link.gif)

The [document link](microsoft.github.io/language-server-protocol/specification#textDocument_documentLink) makes ‘# source://PATH_TO_FILE#line` comments in a Ruby/RBI file clickable if the file exists. When the user clicks the link, it’ll open that location.

# Example

“‘ruby # source://syntax_tree/3.2.1/lib/syntax_tree.rb#51 <- it will be clickable and will take the user to that location def format(source, maxwidth = T.unsafe(nil)) end “`

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, comments, dispatcher) ⇒ DocumentLink

Returns a new instance of DocumentLink.



40
41
42
43
44
45
46
47
# File 'lib/ruby_lsp/requests/document_link.rb', line 40

def initialize(uri, comments, dispatcher)
  super()
  @response_builder = T.let(
    ResponseBuilders::CollectionResponseBuilder[Interface::DocumentLink].new,
    ResponseBuilders::CollectionResponseBuilder[Interface::DocumentLink],
  )
  Listeners::DocumentLink.new(@response_builder, uri, comments, dispatcher)
end

Class Method Details

.providerObject



28
29
30
# File 'lib/ruby_lsp/requests/document_link.rb', line 28

def provider
  Interface::DocumentLinkOptions.new(resolve_provider: false)
end

Instance Method Details

#performObject



50
51
52
# File 'lib/ruby_lsp/requests/document_link.rb', line 50

def perform
  @response_builder.response
end