Class: RubyLsp::Requests::FoldingRanges

Inherits:
Request
  • Object
show all
Extended by:
T::Generic, T::Sig
Defined in:
lib/ruby_lsp/requests/folding_ranges.rb

Overview

![Folding ranges demo](../../folding_ranges.gif)

The [folding ranges](microsoft.github.io/language-server-protocol/specification#textDocument_foldingRange) request informs the editor of the ranges where and how code can be folded.

# Example

“‘ruby def say_hello # <– folding range start

puts "Hello"

end # <– folding range end “‘

Constant Summary collapse

ResponseType =
type_member { { fixed: T::Array[Interface::FoldingRange] } }

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(comments, dispatcher) ⇒ FoldingRanges

Returns a new instance of FoldingRanges.



36
37
38
39
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 36

def initialize(comments, dispatcher)
  super()
  @listener = T.let(Listeners::FoldingRanges.new(comments, dispatcher), Listener[ResponseType])
end

Class Method Details

.providerObject



28
29
30
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 28

def provider
  Interface::FoldingRangeClientCapabilities.new(line_folding_only: true)
end

Instance Method Details

#performObject



42
43
44
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 42

def perform
  @listener.response
end