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



1015
1016
1017
1018
1019
1020
1021
# File 'lib/rbi/parser.rb', line 1015

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



1046
1047
1048
1049
1050
1051
1052
# File 'lib/rbi/parser.rb', line 1046

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



1036
1037
1038
1039
1040
1041
1042
1043
# File 'lib/rbi/parser.rb', line 1036

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



1025
1026
1027
1028
1029
1030
1031
1032
# File 'lib/rbi/parser.rb', line 1025

def visit_string_node(node)
  return unless node.heredoc?

  closing_loc = node.closing_loc
  return unless closing_loc

  handle_string_node(node)
end