class RuboCop::AST::NodePattern::Compiler::Debug::Colorizer
@api private
Constants
- COLOR_SCHEME
- Compiler
Variant of the
Compiler
with tracing information for nodes- Result
Result
of aNodePattern
run against a particularAST
Consider constructor is private
Attributes
compiler[R]
node_pattern[R]
pattern[R]
Public Class Methods
new(pattern, compiler: self.class::Compiler.new)
click to toggle source
# File lib/rubocop/ast/node_pattern/compiler/debug.rb, line 96 def initialize(pattern, compiler: self.class::Compiler.new) @pattern = pattern @compiler = compiler @node_pattern = ::RuboCop::AST::NodePattern.new(pattern, compiler: @compiler) end
Public Instance Methods
test(ruby, trace: self.class::Compiler::Trace.new)
click to toggle source
@return [Node] the Ruby AST
# File lib/rubocop/ast/node_pattern/compiler/debug.rb, line 103 def test(ruby, trace: self.class::Compiler::Trace.new) ruby = ruby_ast(ruby) if ruby.is_a?(String) returned = @node_pattern.as_lambda.call(ruby, trace: trace) self.class::Result.new(self, trace, returned, ruby) end
Private Instance Methods
ruby_ast(ruby)
click to toggle source
# File lib/rubocop/ast/node_pattern/compiler/debug.rb, line 111 def ruby_ast(ruby) buffer = ::Parser::Source::Buffer.new('(ruby)', source: ruby) ruby_parser.parse(buffer) end
ruby_parser()
click to toggle source
# File lib/rubocop/ast/node_pattern/compiler/debug.rb, line 116 def ruby_parser require 'parser/current' builder = ::RuboCop::AST::Builder.new ::Parser::CurrentRuby.new(builder) end