Class: JsDuck::Js::MethodCalls
- Inherits:
-
Object
- Object
- JsDuck::Js::MethodCalls
- Includes:
- Util::Singleton
- Defined in:
- lib/jsduck/js/method_calls.rb
Overview
Looks the AST of a FunctionDeclaration or FunctionExpression for calls to methods of the owner class.
Instance Method Summary collapse
-
#detect(function_node) ⇒ Object
Returns array of method names called by the given function.
Methods included from Util::Singleton
Instance Method Details
#detect(function_node) ⇒ Object
Returns array of method names called by the given function. When no methods called, empty array is returned.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jsduck/js/method_calls.rb', line 14 def detect(function_node) @traverser = Js::ScopedTraverser.new methods = [] @traverser.traverse(function_node["body"]) do |node| if method_call?(node) methods << node["callee"]["property"].to_s end end methods.sort.uniq end |