Commit bb08a155 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Support Ext.ClassManager.create().

That's equivalent to using Ext.define().

See this issue: https://github.com/senchalabs/jsduck/issues/40
parent 1e761121
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -76,6 +76,8 @@ module JsDuck
        var_declaration
      elsif look("Ext", ".", "define", "(", :string)
        ext_define
      elsif look("Ext", ".", "ClassManager", ".", "create", "(", :string)
        ext_define
      elsif look(:ident, ":") || look(:string, ":")
        property_literal
      elsif look(",", :ident, ":") || look(",", :string, ":")
@@ -178,9 +180,11 @@ module JsDuck
      }
    end

    # <ext-define> := "Ext" "." "define" "(" <string> "," <ext-define-cfg>
    # <ext-define> := "Ext" "." ["define" | "ClassManager" "." "create" ] "(" <string> "," <ext-define-cfg>
    def ext_define
      name = match("Ext", ".", "define", "(", :string)
      match("Ext", ".");
      look("define") ? match("define") : match("ClassManager", ".", "create");
      name = match("(", :string)

      if look(",", "{")
        match(",")
+11 −0
Original line number Diff line number Diff line
@@ -218,6 +218,17 @@ describe JsDuck::Aggregator do
    it_should_behave_like "Ext.define"
  end

  describe "Ext.ClassManager.create() instead of Ext.define()" do
    before do
      @doc = parse(<<-EOS)[0]
        /** */
        Ext.ClassManager.create('MyClass', {
        });
      EOS
    end
    it_should_behave_like "class"
  end

  describe "complex Ext.define() in code" do
    before do
      @doc = parse(<<-EOS)[0]