Class: RubyLsp::Requests::DocumentLink

Inherits:
Request
  • Object
show all
Extended by:
T::Generic, 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 “`

Constant Summary collapse

ResponseType =
type_member { { fixed: T::Array[Interface::DocumentLink] } }

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, comments, dispatcher) ⇒ DocumentLink

Returns a new instance of DocumentLink.



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

def initialize(uri, comments, dispatcher)
  super()
  @listener = T.let(Listeners::DocumentLink.new(uri, comments, dispatcher), Listener[ResponseType])
end

Class Method Details

.providerObject



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

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

Instance Method Details

#performObject



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

def perform
  @listener.response
end