Class: RBI::Parser::HeredocLocationVisitor

Inherits:
Prism::Visitor
  • Object
show all
Defined in:
lib/rbi/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(source, begin_offset, end_offset) ⇒ HeredocLocationVisitor

: (Prism::Source source, Integer begin_offset, Integer end_offset) -> void



956
957
958
959
960
961
962
# File 'lib/rbi/parser.rb', line 956

def initialize(source, begin_offset, end_offset)
  super()
  @source = source
  @begin_offset = begin_offset
  @end_offset = end_offset
  @offset_last_newline = false #: bool
end

Instance Method Details

#locationObject

: -> Prism::Location



985
986
987
988
989
990
991
# File 'lib/rbi/parser.rb', line 985

def location
  Prism::Location.new(
    @source,
    @begin_offset,
    @end_offset - @begin_offset - (@offset_last_newline ? 1 : 0),
  )
end

#visit_interpolated_string_node(node) ⇒ Object

: (Prism::InterpolatedStringNode node) -> void



975
976
977
978
979
980
981
982
# File 'lib/rbi/parser.rb', line 975

def visit_interpolated_string_node(node)
  return super unless node.heredoc?

  closing_loc = node.closing_loc
  return super unless closing_loc

  handle_string_node(node)
end

#visit_string_node(node) ⇒ Object

: (Prism::StringNode node) -> void



965
966
967
968
969
970
971
972
# File 'lib/rbi/parser.rb', line 965

def visit_string_node(node)
  return unless node.heredoc?

  closing_loc = node.closing_loc
  return unless closing_loc

  handle_string_node(node)
end