class RDoc::Parser::Tokenizer::SquashTokenVisitor
Visitor to squash several tokens that consist a single node into a single token
Attributes
Public Class Methods
Public Instance Methods
Source
# File lib/rdoc/parser/tokenizer.rb, line 209 def push_location(location, type) @tokens << [type, location.start_offset, location.end_offset] end
Source
# File lib/rdoc/parser/tokenizer.rb, line 198 def visit_array_node(node) # Right hand side of `a = 1,2` is an array node without opening if node.opening&.start_with?('%') # Percent array: squash entire node into a single token. # We don't handle embedded expressions inside yet. push_location(node.location, WORDS) else super end end
Calls superclass method
Source
# File lib/rdoc/parser/tokenizer.rb, line 213 def visit_def_node(node) # For special colorizing of method name in def node push_location(node.name_loc, DEF_METHOD_NAME) super end
Calls superclass method
Source
# File lib/rdoc/parser/tokenizer.rb, line 162 def visit_float_node(node) push_location(node.location, FLOAT) end
Source
# File lib/rdoc/parser/tokenizer.rb, line 170 def visit_imaginary_node(node) push_location(node.location, IMAGINARY) end
Source
# File lib/rdoc/parser/tokenizer.rb, line 158 def visit_integer_node(node) push_location(node.location, INTEGER) end
Squash UMINUS and its operand(integer, float, rational, imaginary) token into a single token
Source
# File lib/rdoc/parser/tokenizer.rb, line 219 def visit_interpolated_string_node(node) # `"a" "b"` is an interpolated string node without opening if node.opening&.start_with?('<<') # Heredocs. Squash content into a single token. # We don't tokenize embedded expressions inside, and don't handle nested heredocs yet. push_location(node.opening_loc, HEREDOC_BEG) unless node.parts.empty? # Squash heredoc content into a single token part_locations = node.parts.map(&:location) @tokens << [ HEREDOC_CONTENT, part_locations.map(&:start_offset).min, part_locations.map(&:end_offset).max ] end # incomplete heredoc might not have closing_loc push_location(node.closing_loc, HEREDOC_END) if node.closing_loc else # Squash entire node into a single token push_location(node.location, DSTRING) end end
Also aliased as: visit_interpolated_x_string_node
Source
# File lib/rdoc/parser/tokenizer.rb, line 166 def visit_rational_node(node) push_location(node.location, RATIONAL) end
Source
# File lib/rdoc/parser/tokenizer.rb, line 179 def visit_regular_expression_node(node) push_location(node.location, REGEXP) end
Source
# File lib/rdoc/parser/tokenizer.rb, line 186 def visit_string_node(node) # opening of StringNode inside InterpolatedStringNode might be nil if node.opening&.start_with?('<<') push_location(node.opening_loc, HEREDOC_BEG) push_location(node.content_loc, HEREDOC_CONTENT) push_location(node.closing_loc, HEREDOC_END) else push_location(node.location, STRING) end end
Also aliased as: visit_x_string_node
Source
# File lib/rdoc/parser/tokenizer.rb, line 174 def visit_symbol_node(node) push_location(node.location, SYMBOL) end
Also aliased as: visit_interpolated_symbol_node