Commit 0d8fd9de authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Change format of auto-detected params.

Instead of string, each param is now a hash:

    {:name => "param-name"}

That's the same data structure that old JsParser produced and it's what
Merger expects.
parent b1884975
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -194,10 +194,18 @@ module JsDuck
      return {
        :type => :method,
        :name => name,
        :params => (ast && !empty_fn?(ast)) ? ast["params"].map {|p| to_s(p) } : []
        :params => make_params(ast)
      }
    end

    def make_params(ast)
      if ast && !empty_fn?(ast)
        ast["params"].map {|p| {:name => to_s(p)} }
      else
        []
      end
    end

    def make_property(name=nil, ast=nil)
      return {
        :type => :property,
+3 −3
Original line number Diff line number Diff line
@@ -89,9 +89,9 @@ describe "JsDuck::Ast detects method with" do
  describe "param names" do
    it "function assignment with three params" do
      params = detect("/** */ foo = function(a, b, c){}")[:params]
      params[0].should == "a"
      params[1].should == "b"
      params[2].should == "c"
      params[0].should == {:name => "a"}
      params[1].should == {:name => "b"}
      params[2].should == {:name => "c"}
    end
  end