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

Ident-chain can now again begin with this keyword.

Introduction of ident/keyword separation broke this before,
now it's working again.
parent df7953c6
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ module JsDuck
        var_declaration
      elsif look(:ident, ":") || look(:string, ":") then
        property_literal
      elsif look(:ident) then
      elsif look(:ident) || look("this") then
        maybe_assignment
      elsif look(:string) then
        {:type => :assignment, :left => [match(:string)]}
@@ -121,9 +121,14 @@ module JsDuck
      }
    end

    # <ident-chain> := <ident> [ "." <ident> ]*
    # <ident-chain> := [ "this" | <ident> ]  [ "." <ident> ]*
    def ident_chain
      if look("this")
        chain = [match("this")]
      else
        chain = [match(:ident)]
      end

      while look(".", :ident) do
        chain << match(".", :ident)
      end
+13 −0
Original line number Diff line number Diff line
@@ -399,6 +399,19 @@ foo: true,
    assert_equal("My comment", docs[0][:doc])
  end

  def test_property_ident_chain_begins_with_this
    docs = JsDuck.parse("
/**
 * If true then lock actions
 */
this.locked = false;
")
    assert_equal(:property, docs[0][:tagname])
    assert_equal("locked", docs[0][:name])
    assert_equal("Boolean", docs[0][:type])
    assert_equal("If true then lock actions", docs[0][:doc])
  end

  def test_implicit_property_type
    comment = "
/**