Class: Prism::Merge::NocovNode::LocationWithOffsets

Inherits:
Struct
  • Object
show all
Defined in:
lib/prism/merge/nocov_node.rb

Overview

Location struct with byte offsets for correct range comparison with Prism nodes. start_offset / end_offset are used by TopLevelMergeRunner#node_offset_range and must be byte offsets (not line numbers) to avoid false "already output" matches against FreezeNode ranges that also use byte offsets.

Also exposes leading_comments delegated from the owning NocovNode so that filtered_leading_comments_for / emit_dest_gap_lines can find comments that appear in the file before the opening # :nocov: marker.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#end_lineObject

Returns the value of attribute end_line

Returns:

  • (Object)

    the current value of end_line



32
33
34
# File 'lib/prism/merge/nocov_node.rb', line 32

def end_line
  @end_line
end

#end_offsetObject

Returns the value of attribute end_offset

Returns:

  • (Object)

    the current value of end_offset



32
33
34
# File 'lib/prism/merge/nocov_node.rb', line 32

def end_offset
  @end_offset
end

#ownerObject

Returns the value of attribute owner

Returns:

  • (Object)

    the current value of owner



32
33
34
# File 'lib/prism/merge/nocov_node.rb', line 32

def owner
  @owner
end

#start_lineObject

Returns the value of attribute start_line

Returns:

  • (Object)

    the current value of start_line



32
33
34
# File 'lib/prism/merge/nocov_node.rb', line 32

def start_line
  @start_line
end

#start_offsetObject

Returns the value of attribute start_offset

Returns:

  • (Object)

    the current value of start_offset



32
33
34
# File 'lib/prism/merge/nocov_node.rb', line 32

def start_offset
  @start_offset
end

Instance Method Details

#cover?(line) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/prism/merge/nocov_node.rb', line 33

def cover?(line)
  (start_line..end_line).cover?(line)
end

#leading_commentsObject



37
38
39
# File 'lib/prism/merge/nocov_node.rb', line 37

def leading_comments
  owner.leading_comments
end