Class: RubyLsp::Requests::FoldingRanges::PartialRange

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_line, end_line, kind) ⇒ PartialRange

Returns a new instance of PartialRange.



148
149
150
151
152
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 148

def initialize(start_line, end_line, kind)
  @start_line = start_line
  @end_line = end_line
  @kind = kind
end

Instance Attribute Details

#end_lineObject (readonly)

Returns the value of attribute end_line.



136
137
138
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 136

def end_line
  @end_line
end

#kindObject (readonly)

Returns the value of attribute kind.



133
134
135
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 133

def kind
  @kind
end

Class Method Details

.from(node, kind) ⇒ Object



142
143
144
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 142

def from(node, kind)
  new(node.location.start_line - 1, node.location.end_line - 1, kind)
end

Instance Method Details

#extend_to(node) ⇒ Object



155
156
157
158
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 155

def extend_to(node)
  @end_line = node.location.end_line - 1
  self
end

#multiline?Boolean

Returns:

  • (Boolean)


175
176
177
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 175

def multiline?
  @end_line > @start_line
end

#new_section?(node) ⇒ Boolean

Returns:

  • (Boolean)


161
162
163
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 161

def new_section?(node)
  node.is_a?(SyntaxTree::Comment) && @end_line + 1 != node.location.start_line - 1
end

#to_rangeObject



166
167
168
169
170
171
172
# File 'lib/ruby_lsp/requests/folding_ranges.rb', line 166

def to_range
  Interface::FoldingRange.new(
    start_line: @start_line,
    end_line: @end_line,
    kind: @kind,
  )
end