class RuboCop::AST::NodePattern::Parser::WithMeta::Lexer

Overrides Lexer to token locations and comments

Attributes

source_buffer[R]

Public Class Methods

new(str_or_buffer) click to toggle source
Calls superclass method RuboCop::AST::NodePattern::Lexer::new
# File lib/rubocop/ast/node_pattern/with_meta.rb, line 13
def initialize(str_or_buffer)
  @source_buffer = if str_or_buffer.respond_to?(:source)
                     str_or_buffer
                   else
                     ::Parser::Source::Buffer.new('(string)', source: str_or_buffer)
                   end
  @comments = []
  super(@source_buffer.source)
end

Public Instance Methods

emit_comment() click to toggle source
# File lib/rubocop/ast/node_pattern/with_meta.rb, line 27
def emit_comment
  @comments << Comment.new(pos)
  super
end
pos() click to toggle source

@return [::Parser::Source::Range] last match's position

# File lib/rubocop/ast/node_pattern/with_meta.rb, line 33
def pos
  ::Parser::Source::Range.new(source_buffer, ss.pos - ss.matched_size, ss.pos)
end
token(type, value) click to toggle source
Calls superclass method RuboCop::AST::NodePattern::Lexer#token
# File lib/rubocop/ast/node_pattern/with_meta.rb, line 23
def token(type, value)
  super(type, [value, pos])
end