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



1002
1003
1004
1005
1006
1007
1008
# File 'lib/rbi/parser.rb', line 1002

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



1033
1034
1035
1036
1037
1038
1039
# File 'lib/rbi/parser.rb', line 1033

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



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

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



1012
1013
1014
1015
1016
1017
1018
1019
# File 'lib/rbi/parser.rb', line 1012

def visit_string_node(node)
  return unless node.heredoc?

  closing_loc = node.closing_loc
  return unless closing_loc

  handle_string_node(node)
end