Class: RubyLsp::Requests::FoldingRanges
- Inherits:
-
BaseRequest
- Object
- SyntaxTree::Visitor
- BaseRequest
- RubyLsp::Requests::FoldingRanges
- Defined in:
- lib/ruby_lsp/requests/folding_ranges.rb
Overview
The [folding ranges](microsoft.github.io/language-server-protocol/specification#textDocument_foldingRange) request informs the editor of the ranges where code can be folded.
# Example “‘ruby def say_hello # <– folding range start
puts "Hello"
end # <– folding range end “‘
Defined Under Namespace
Classes: PartialRange
Constant Summary collapse
- SIMPLE_FOLDABLES =
[ SyntaxTree::ArrayLiteral, SyntaxTree::BraceBlock, SyntaxTree::Case, SyntaxTree::ClassDeclaration, SyntaxTree::Command, SyntaxTree::DoBlock, SyntaxTree::FCall, SyntaxTree::For, SyntaxTree::HashLiteral, SyntaxTree::Heredoc, SyntaxTree::If, SyntaxTree::ModuleDeclaration, SyntaxTree::SClass, SyntaxTree::Unless, SyntaxTree::Until, SyntaxTree::While, ].freeze
- NODES_WITH_STATEMENTS =
[ SyntaxTree::Else, SyntaxTree::Elsif, SyntaxTree::Ensure, SyntaxTree::In, SyntaxTree::Rescue, SyntaxTree::When, ].freeze
Instance Method Summary collapse
-
#initialize(document) ⇒ FoldingRanges
constructor
A new instance of FoldingRanges.
- #run ⇒ Object
Methods inherited from BaseRequest
#range_from_syntax_tree_node, run
Constructor Details
#initialize(document) ⇒ FoldingRanges
Returns a new instance of FoldingRanges.
44 45 46 47 48 49 |
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 44 def initialize(document) super @ranges = [] @partial_range = nil end |
Instance Method Details
#run ⇒ Object
51 52 53 54 55 |
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 51 def run visit(@document.tree) emit_partial_range @ranges end |