class JRuby::Lint::Collector::CheckersVisitor

Attributes

checkers[R]
collector[R]
stack[R]

Public Class Methods

new(ast, collector, checkers) click to toggle source
Calls superclass method JRuby::Lint::AST::Visitor::new
# File lib/jruby/lint/collectors.rb, line 24
def initialize(ast, collector, checkers)
  super(ast)
  @collector, @checkers = collector, checkers
end

Public Instance Methods

visit(method, node) click to toggle source
Calls superclass method JRuby::Lint::AST::Visitor#visit
# File lib/jruby/lint/collectors.rb, line 29
def visit(method, node)
  @collector.stack.push  node
  after_hooks = []
  checkers.each do |ch|
    begin
      if ch.respond_to?(method)
        res = ch.send(method, node)
        after_hooks << res if res.respond_to?(:call)
      end
    rescue Exception => e
      collector.add_finding("Exception while traversing: #{e.message}\n  at #{e.backtrace.first}",
                                        [:internal, :debug], node.line+1)
    end
  end
  super
rescue Exception => e
  collector.add_finding("Exception while traversing: #{e.message}\n  at #{e.backtrace.first}",
                                    [:internal, :debug], node.line+1)
ensure
  begin
    after_hooks.each {|h| h.call }
  rescue
  end
  @collector.stack.pop
end