Class: RubyLsp::Requests::FoldingRanges::PartialRange
- Inherits:
-
Object
- Object
- RubyLsp::Requests::FoldingRanges::PartialRange
- Extended by:
- T::Sig
- Defined in:
- lib/ruby_lsp/requests/folding_ranges.rb
Instance Attribute Summary collapse
-
#end_line ⇒ Object
readonly
Returns the value of attribute end_line.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
Class Method Summary collapse
Instance Method Summary collapse
- #extend_to(node) ⇒ Object
-
#initialize(start_line, end_line, kind) ⇒ PartialRange
constructor
A new instance of PartialRange.
- #multiline? ⇒ Boolean
- #new_section?(node) ⇒ Boolean
- #to_range ⇒ Object
Constructor Details
#initialize(start_line, end_line, kind) ⇒ PartialRange
Returns a new instance of PartialRange.
132 133 134 135 136 |
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 132 def initialize(start_line, end_line, kind) @start_line = start_line @end_line = end_line @kind = kind end |
Instance Attribute Details
#end_line ⇒ Object (readonly)
Returns the value of attribute end_line.
120 121 122 |
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 120 def end_line @end_line end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
117 118 119 |
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 117 def kind @kind end |
Class Method Details
.from(node, kind) ⇒ Object
126 127 128 |
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 126 def from(node, kind) new(node.location.start_line - 1, node.location.end_line - 1, kind) end |
Instance Method Details
#extend_to(node) ⇒ Object
139 140 141 142 |
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 139 def extend_to(node) @end_line = node.location.end_line - 1 self end |
#multiline? ⇒ Boolean
159 160 161 |
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 159 def multiline? @end_line > @start_line end |
#new_section?(node) ⇒ Boolean
145 146 147 |
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 145 def new_section?(node) node.is_a?(SyntaxTree::Comment) && @end_line + 1 != node.location.start_line - 1 end |
#to_range ⇒ Object
150 151 152 153 154 155 156 |
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 150 def to_range LanguageServer::Protocol::Interface::FoldingRange.new( start_line: @start_line, end_line: @end_line, kind: @kind, ) end |