Sha256: 41a1c5c1398f2480fdd9f1f39dbf63399c8fb2d2e620e20d771650de4f30038c

Contents?: true

Size: 1.08 KB

Versions: 40

Compression:

Stored size: 1.08 KB

Contents

# typed: strict
# frozen_string_literal: true

module RubyLsp
  module ResponseBuilders
    class Hover < ResponseBuilder
      ResponseType = type_member { { fixed: String } }

      extend T::Sig
      extend T::Generic

      sig { void }
      def initialize
        super

        @response = T.let(
          {
            title: +"",
            links: +"",
            documentation: +"",
          },
          T::Hash[Symbol, String],
        )
      end

      sig { params(content: String, category: Symbol).void }
      def push(content, category:)
        hover_content = @response[category]
        if hover_content
          hover_content << content + "\n"
        end
      end

      sig { returns(T::Boolean) }
      def empty?
        @response.values.all?(&:empty?)
      end

      sig { override.returns(ResponseType) }
      def response
        result = T.must(@response[:title])
        result << "\n" << @response[:links] if @response[:links]
        result << "\n" << @response[:documentation] if @response[:documentation]

        result.strip
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
ruby-lsp-0.19.1 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.19.0 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.18.4 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.18.3 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.18.2 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.18.1 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.18.0 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.17.17 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.17.16 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.17.15 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.17.14 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.17.13 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.17.12 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.17.11 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.17.10 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.17.9 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.17.8 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.17.7 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.17.6 lib/ruby_lsp/response_builders/hover.rb
ruby-lsp-0.17.5 lib/ruby_lsp/response_builders/hover.rb