class RuboCop::AST::NodePattern::Compiler::Subcompiler
/docs/modules/ROOT/pages/node_pattern.adoc
Doc on how this fits in the compiling process:
Implements visitor pattern
Base class for subcompilers
def compile(node)
def compile(node) prev = @node @node = node do_compile ensure @node = prev end
def do_compile
def do_compile send(self.class.registry.fetch(node.type, :visit_other_type)) end
def inherited(base)
def inherited(base) us = self base.class_eval { @registry = us.registry.dup } super end
def initialize(compiler)
def initialize(compiler) @compiler = compiler @node = nil end
def method_added(method)
def method_added(method) @registry[Regexp.last_match(1).to_sym] = method if method =~ /^visit_(.*)/ super end