Class: TreeHaver::Backends::Prism::Comment
Overview
Prism comment wrapper.
Prism exposes native Ruby comments via Prism::Comment subclasses and
Prism::Location objects. This wrapper normalizes those objects onto a
small parser-facing contract for downstream consumers.
Constant Summary
TreeHaver::Base::Comment::ATTACHMENT_HINTS
Instance Attribute Summary
#attachment_hint, #inner_comment, #source
Class Method Summary
collapse
Instance Method Summary
collapse
#attachment_hint?, #end_line, #initialize, #inline?, #inspect, #leading?, #source_position, #start_line, #trailing?
Class Method Details
359
360
361
362
363
|
# File 'lib/tree_haver/backends/prism.rb', line 359
def (klass)
klass.name.split("::").last
.gsub(/([a-z\d])([A-Z])/, '\\1_\\2')
.downcase
end
|
Instance Method Details
#end_byte ⇒ Object
336
337
338
|
# File 'lib/tree_haver/backends/prism.rb', line 336
def end_byte
location.end_offset
end
|
#end_point ⇒ Object
347
348
349
350
351
352
|
# File 'lib/tree_haver/backends/prism.rb', line 347
def end_point
{
row: location.end_line - 1,
column: location.end_column,
}
end
|
#location ⇒ Object
320
321
322
|
# File 'lib/tree_haver/backends/prism.rb', line 320
def location
.location
end
|
#start_byte ⇒ Object
332
333
334
|
# File 'lib/tree_haver/backends/prism.rb', line 332
def start_byte
location.start_offset
end
|
#start_point ⇒ Object
340
341
342
343
344
345
|
# File 'lib/tree_haver/backends/prism.rb', line 340
def start_point
{
row: location.start_line - 1,
column: location.start_column,
}
end
|
#style ⇒ Object
354
355
356
|
# File 'lib/tree_haver/backends/prism.rb', line 354
def style
:line
end
|
#text ⇒ Object
328
329
330
|
# File 'lib/tree_haver/backends/prism.rb', line 328
def text
.slice
end
|
#type ⇒ Object
324
325
326
|
# File 'lib/tree_haver/backends/prism.rb', line 324
def type
self.class.(.class)
end
|