Sha256: b3b5221f12e9245a67cf3f831a007ad5abc7ec486d0823b53232c7d0f4d935c4

Contents?: true

Size: 1.61 KB

Versions: 33

Compression:

Stored size: 1.61 KB

Contents

# typed: strict
# frozen_string_literal: true

require "ruby_lsp/listeners/document_link"

module RubyLsp
  module Requests
    # ![Document link demo](../../document_link.gif)
    #
    # The [document link](https://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 DocumentLink < Request
      extend T::Sig

      class << self
        extend T::Sig

        sig { returns(Interface::DocumentLinkOptions) }
        def provider
          Interface::DocumentLinkOptions.new(resolve_provider: false)
        end
      end

      sig do
        params(
          uri: URI::Generic,
          comments: T::Array[Prism::Comment],
          dispatcher: Prism::Dispatcher,
        ).void
      end
      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

      sig { override.returns(T::Array[Interface::DocumentLink]) }
      def perform
        @response_builder.response
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
ruby-lsp-0.17.17 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.16 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.15 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.14 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.13 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.12 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.11 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.10 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.9 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.8 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.7 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.6 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.5 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.4 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.3 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.2 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.1 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.17.0 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.16.6 lib/ruby_lsp/requests/document_link.rb
ruby-lsp-0.16.5 lib/ruby_lsp/requests/document_link.rb