Class: I18n::Processes::Scanners::RubyAstScanner

Inherits:
FileScanner show all
Includes:
AST::Sexp, RelativeKeys
Defined in:
lib/i18n/processes/scanners/ruby_ast_scanner.rb

Overview

Scan for I18n.translate calls using whitequark/parser

Constant Summary collapse

MAGIC_COMMENT_PREFIX =
/\A.\s*i18n-processes-use\s+/
RECEIVER_MESSAGES =
[nil, AST::Node.new(:const, [nil, :I18n])].product(%i[t translate])

Instance Attribute Summary

Attributes inherited from FileScanner

#config

Instance Method Summary collapse

Methods included from RelativeKeys

#absolute_key

Methods inherited from FileScanner

#keys

Methods inherited from Scanner

#keys

Constructor Details

#initialize(**args) ⇒ RubyAstScanner

Returns a new instance of RubyAstScanner.



20
21
22
23
24
25
26
27
# File 'lib/i18n/processes/scanners/ruby_ast_scanner.rb', line 20

def initialize(**args)
  super(args)
  @parser = ::Parser::CurrentRuby.new
  @magic_comment_parser = ::Parser::CurrentRuby.new
  @call_finder = RubyAstCallFinder.new(
    receiver_messages: config[:receiver_messages] || RECEIVER_MESSAGES
  )
end