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



1005
1006
1007
1008
1009
1010
1011
# File 'lib/rbi/parser.rb', line 1005

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



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

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



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

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



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

def visit_string_node(node)
  return unless node.heredoc?

  closing_loc = node.closing_loc
  return unless closing_loc

  handle_string_node(node)
end