Sha256: c9a05d7de52a2d080763a15769919c6c7c0ce683cd248c633d586f15605efd70

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

# typed: strict
# frozen_string_literal: true

require "ruby_lsp/listeners/inlay_hints"

module RubyLsp
  module Requests
    # [Inlay hints](https://microsoft.github.io/language-server-protocol/specification#textDocument_inlayHint)
    # are labels added directly in the code that explicitly show the user something that might
    # otherwise just be implied.
    class InlayHints < Request
      extend T::Sig

      class << self
        extend T::Sig

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

      sig do
        params(
          document: T.any(RubyDocument, ERBDocument),
          range: T::Hash[Symbol, T.untyped],
          hints_configuration: RequestConfig,
          dispatcher: Prism::Dispatcher,
        ).void
      end
      def initialize(document, range, hints_configuration, dispatcher)
        super()
        start_line = range.dig(:start, :line)
        end_line = range.dig(:end, :line)

        @response_builder = T.let(
          ResponseBuilders::CollectionResponseBuilder[Interface::InlayHint].new,
          ResponseBuilders::CollectionResponseBuilder[Interface::InlayHint],
        )
        Listeners::InlayHints.new(@response_builder, start_line..end_line, hints_configuration, dispatcher)
      end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-lsp-0.18.1 lib/ruby_lsp/requests/inlay_hints.rb
ruby-lsp-0.18.0 lib/ruby_lsp/requests/inlay_hints.rb