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

Recognize Ext.baseCSSPrefix in config values.

   foo: Ext.baseCSSPrefix + "name"

will be interpreted as:

   foo: "x-name"
parent b8cb5909
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -156,12 +156,14 @@ module JsDuck
      return chain
    end

    # <expression> := <function> | <ext-extend> | <literal>
    # <expression> := <function> | <ext-extend> | <ext-base-css-prefix> | <literal>
    def expression
      if look("function")
        function
      elsif ext_look(:ns, ".", "extend")
        ext_extend
      elsif ext_look(:ns, ".", "baseCSSPrefix", "+", :string)
        ext_base_css_prefix
      else
        my_literal
      end
@@ -202,6 +204,16 @@ module JsDuck
      }
    end

    # <ext-base-css-prefix> := "Ext" "." "baseCSSPrefix" "+" <string>
    def ext_base_css_prefix
      match(:ident, ".", "baseCSSPrefix", "+")
      return {
        :type => :literal,
        :class => "String",
        :value => '"x-' + match(:string)[:value] + '"',
      }
    end

    # <ext-define> := "Ext" "." ["define" | "ClassManager" "." "create" ] "(" <string> "," <ext-define-cfg>
    def ext_define
      match(:ident, ".");
+14 −0
Original line number Diff line number Diff line
@@ -304,6 +304,20 @@ describe JsDuck::Aggregator do
    end
  end

  describe "cfg with implicit string value starting with Ext.baseCSSPrefix" do
    before do
      @doc = parse(<<-EOS)[0]
        /**
         * @cfg foo Something
         */
        foo: Ext.baseCSSPrefix + "foo"
      EOS
    end
    it "replaces Ext.baseCSSPrefix with 'x-'" do
      @doc[:default].should == '"x-foo"'
    end
  end

  describe "cfg with implicit name followed by code field with another name" do
    before do
      @doc = parse(<<-EOS)[0]