Sha256: 6e5bd872b514a24e37d060a15fb93778cc224393980639f8c36185fc19422b35

Contents?: true

Size: 1.39 KB

Versions: 22

Compression:

Stored size: 1.39 KB

Contents

# typed: strict
# frozen_string_literal: true

require "ruby_lsp/listeners/folding_ranges"

module RubyLsp
  module Requests
    # The [folding ranges](https://microsoft.github.io/language-server-protocol/specification#textDocument_foldingRange)
    # request informs the editor of the ranges where and how code can be folded.
    class FoldingRanges < Request
      extend T::Sig

      class << self
        extend T::Sig

        sig { returns(Interface::FoldingRangeRegistrationOptions) }
        def provider
          Interface::FoldingRangeRegistrationOptions.new(
            document_selector: [
              Interface::DocumentFilter.new(language: "ruby"),
            ],
          )
        end
      end

      sig { params(comments: T::Array[Prism::Comment], dispatcher: Prism::Dispatcher).void }
      def initialize(comments, dispatcher)
        super()
        @response_builder = T.let(
          ResponseBuilders::CollectionResponseBuilder[Interface::FoldingRange].new,
          ResponseBuilders::CollectionResponseBuilder[Interface::FoldingRange],
        )
        @listener = T.let(
          Listeners::FoldingRanges.new(@response_builder, comments, dispatcher),
          Listeners::FoldingRanges,
        )
      end

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

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
ruby-lsp-0.23.6 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.23.5 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.23.4 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.23.3 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.23.2 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.23.1 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.23.0 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.22.1 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.22.0 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.21.3 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.21.2 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.21.1 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.21.0 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.20.1 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.20.0 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.19.1 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.19.0 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.18.4 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.18.3 lib/ruby_lsp/requests/folding_ranges.rb
ruby-lsp-0.18.2 lib/ruby_lsp/requests/folding_ranges.rb