Loading lib/jsduck/js/ast.rb +10 −0 Original line number Diff line number Diff line require "jsduck/js/function" require "jsduck/js/fires" require "jsduck/js/method_calls" require "jsduck/js/node" require "jsduck/tag_registry" Loading Loading @@ -318,6 +319,7 @@ module JsDuck :params => empty_array_to_nil(make_params(ast)), :chainable => chainable?(ast) && name != "constructor", :fires => empty_array_to_nil(detect_fires(ast)), :method_calls => empty_array_to_nil(detect_method_calls(ast)), } end Loading Loading @@ -349,6 +351,14 @@ module JsDuck end end def detect_method_calls(ast) if ast.function? && !ast.ext_empty_fn? Js::MethodCalls.detect(ast) else [] end end def make_event(name) return { :tagname => :event, Loading lib/jsduck/tag/method.rb +1 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ module JsDuck::Tag h[:params] = code[:params] h[:chainable] = code[:chainable] h[:fires] = code[:fires] h[:method_calls] = code[:method_calls] h end Loading spec/aggregator_method_calls_spec.rb 0 → 100644 +28 −0 Original line number Diff line number Diff line require "mini_parser" describe JsDuck::Aggregator do def parse(string) Helper::MiniParser.parse(string) end def parse_calls(string) parse(string)["global"][:members][0][:method_calls] end describe "function with method calls in code" do let(:calls) do parse_calls(<<-EOS) /** */ function bar() { this.bar(); this.foo(); } EOS end it "detects these method calls" do calls.should == ["bar", "foo"] end end end Loading
lib/jsduck/js/ast.rb +10 −0 Original line number Diff line number Diff line require "jsduck/js/function" require "jsduck/js/fires" require "jsduck/js/method_calls" require "jsduck/js/node" require "jsduck/tag_registry" Loading Loading @@ -318,6 +319,7 @@ module JsDuck :params => empty_array_to_nil(make_params(ast)), :chainable => chainable?(ast) && name != "constructor", :fires => empty_array_to_nil(detect_fires(ast)), :method_calls => empty_array_to_nil(detect_method_calls(ast)), } end Loading Loading @@ -349,6 +351,14 @@ module JsDuck end end def detect_method_calls(ast) if ast.function? && !ast.ext_empty_fn? Js::MethodCalls.detect(ast) else [] end end def make_event(name) return { :tagname => :event, Loading
lib/jsduck/tag/method.rb +1 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ module JsDuck::Tag h[:params] = code[:params] h[:chainable] = code[:chainable] h[:fires] = code[:fires] h[:method_calls] = code[:method_calls] h end Loading
spec/aggregator_method_calls_spec.rb 0 → 100644 +28 −0 Original line number Diff line number Diff line require "mini_parser" describe JsDuck::Aggregator do def parse(string) Helper::MiniParser.parse(string) end def parse_calls(string) parse(string)["global"][:members][0][:method_calls] end describe "function with method calls in code" do let(:calls) do parse_calls(<<-EOS) /** */ function bar() { this.bar(); this.foo(); } EOS end it "detects these method calls" do calls.should == ["bar", "foo"] end end end