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.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
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.
24 25 26 27 |
# File 'lib/jruby/lint/collectors.rb', line 24 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.
21 22 23 |
# File 'lib/jruby/lint/collectors.rb', line 21 def checkers @checkers end |
#collector ⇒ Object (readonly)
Returns the value of attribute collector.
21 22 23 |
# File 'lib/jruby/lint/collectors.rb', line 21 def collector @collector end |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
21 22 23 |
# File 'lib/jruby/lint/collectors.rb', line 21 def stack @stack end |
Instance Method Details
#visit(method, node) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# 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.}\n at #{e.backtrace.first}", [:internal, :debug], node.line+1) end end super rescue Exception => e collector.add_finding("Exception while traversing: #{e.}\n at #{e.backtrace.first}", [:internal, :debug], node.line+1) ensure begin after_hooks.each {|h| h.call } rescue end @collector.stack.pop end |