Commit 0717b931 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Support ALL type (*) in type expressions.

parent b8cd4419
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -55,17 +55,23 @@ module JsDuck

    # The basic type
    #
    #     <ident> [ "." <ident> ]* [ "[]" ]* [ "..." ]
    #     <basic-type> ::= <type-name> [ "[]" ]* [ "..." ]
    #
    #     <type-name> ::= <ident-chain> | "*"
    #
    #     <ident-chain> ::= <ident> [ "." <ident> ]*
    #
    #     <ident> ::= [a-zA-Z0-9_]+
    #
    # dot-separated identifiers followed by optional "[]"
    def base_type
      type = @input.scan(/[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*/)
      type = @input.scan(/[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*|\*/)

      if !type
        return false
      elsif @relations[type]
        @out << @formatter.link(type, nil, type)
      elsif @relations.ignore?(type) || type == "undefined"
      elsif @relations.ignore?(type) || type == "undefined" || type == "*"
        @out << type
      else
        @error = :name
+10 −0
Original line number Diff line number Diff line
@@ -109,5 +109,15 @@ describe JsDuck::TypeParser do
    end
  end

  # Type expressions supported by closure compiler:
  # https://developers.google.com/closure/compiler/docs/js-for-compiler#types
  describe "supporting closure compiler" do

    it "matches the ALL type" do
      parse("*").should == true
    end

  end

end