Class: JRuby::Lint::Collector::CheckersVisitor
- Inherits:
-
AST::Visitor
- Object
- AST::Visitor
- JRuby::Lint::Collector::CheckersVisitor
- Defined in:
- lib/jruby/lint/collectors.rb
Instance Attribute Summary collapse
-
#checkers ⇒ Object
readonly
Returns the value of attribute checkers.
-
#collector ⇒ Object
readonly
Returns the value of attribute collector.
Attributes inherited from AST::Visitor
Instance Method Summary collapse
-
#initialize(ast, collector, checkers) ⇒ CheckersVisitor
constructor
A new instance of CheckersVisitor.
- #visit(method, node) ⇒ Object
Methods inherited from AST::Visitor
Constructor Details
#initialize(ast, collector, checkers) ⇒ CheckersVisitor
Returns a new instance of CheckersVisitor.
15 16 17 18 |
# File 'lib/jruby/lint/collectors.rb', line 15 def initialize(ast, collector, checkers) super(ast) @collector, @checkers = collector, checkers end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class JRuby::Lint::AST::Visitor
Instance Attribute Details
#checkers ⇒ Object (readonly)
Returns the value of attribute checkers.
13 14 15 |
# File 'lib/jruby/lint/collectors.rb', line 13 def checkers @checkers end |
#collector ⇒ Object (readonly)
Returns the value of attribute collector.
13 14 15 |
# File 'lib/jruby/lint/collectors.rb', line 13 def collector @collector end |
Instance Method Details
#visit(method, node) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/jruby/lint/collectors.rb', line 20 def visit(method, 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.findings << Finding.new("Exception while traversing: #{e.}\n at #{e.backtrace.first}", [:internal, :debug], node.position) end end super rescue Exception => e collector.findings << Finding.new("Exception while traversing: #{e.}\n at #{e.backtrace.first}", [:internal, :debug], node.position) ensure begin after_hooks.each {|h| h.call } rescue end end |