Sha256: 0f5ce40b2adffd9b6c81b9bc7374e9eeca28419766ca3284a7ada4f1d24b9a1a

Contents?: true

Size: 1.54 KB

Versions: 25

Compression:

Stored size: 1.54 KB

Contents

# typed: strict
# frozen_string_literal: true

require "shellwords"

require "ruby_lsp/listeners/code_lens"

module RubyLsp
  module Requests
    # ![Code lens demo](../../code_lens.gif)
    #
    # The
    # [code lens](https://microsoft.github.io/language-server-protocol/specification#textDocument_codeLens)
    # request informs the editor of runnable commands such as testing and debugging
    #
    # # Example
    #
    # ```ruby
    # # Run | Run in Terminal | Debug
    # class Test < Minitest::Test
    # end
    # ```
    class CodeLens < Request
      extend T::Sig

      class << self
        extend T::Sig

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

      sig do
        params(
          global_state: GlobalState,
          uri: URI::Generic,
          dispatcher: Prism::Dispatcher,
        ).void
      end
      def initialize(global_state, uri, dispatcher)
        @response_builder = T.let(
          ResponseBuilders::CollectionResponseBuilder[Interface::CodeLens].new,
          ResponseBuilders::CollectionResponseBuilder[Interface::CodeLens],
        )
        super()
        Listeners::CodeLens.new(@response_builder, global_state, uri, dispatcher)

        Addon.addons.each do |addon|
          addon.create_code_lens_listener(@response_builder, uri, dispatcher)
        end
      end

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

Version data entries

25 entries across 25 versions & 1 rubygems

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