From e44e884b98f0aaf75998fe7c7b20da0d01a9cad1 Mon Sep 17 00:00:00 2001 From: joshvera Date: Thu, 16 Mar 2017 17:18:49 -0400 Subject: [PATCH] Add class properties --- src/Language/JavaScript.hs | 1 + test/fixtures/javascript/class.A.js | 2 +- test/fixtures/javascript/class.diff+A.txt | 1 + test/fixtures/javascript/class.diff-A.txt | 1 + test/fixtures/javascript/class.diffA-B.txt | 28 +++++++--------------- test/fixtures/javascript/class.diffB-A.txt | 1 + test/fixtures/javascript/class.parseA.txt | 1 + 7 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/Language/JavaScript.hs b/src/Language/JavaScript.hs index e2a84d423..9124bf998 100644 --- a/src/Language/JavaScript.hs +++ b/src/Language/JavaScript.hs @@ -107,6 +107,7 @@ categoryForJavaScriptProductionName name = case name of "statement_block" -> ExpressionStatements "assignment" -> Assignment "assignment_pattern" -> Assignment + "public_field_definition" -> Assignment "member_access" -> MemberAccess "op" -> Operator "subscript_access" -> SubscriptAccess diff --git a/test/fixtures/javascript/class.A.js b/test/fixtures/javascript/class.A.js index 8f6ae64db..a55ec1e94 100644 --- a/test/fixtures/javascript/class.A.js +++ b/test/fixtures/javascript/class.A.js @@ -1 +1 @@ -class Foo { static one(a) { return a; }; two(b) { return b; } three(c) { return c; } } +class Foo { bar = 5; static one(a) { return a; }; two(b) { return b; } three(c) { return c; } } diff --git a/test/fixtures/javascript/class.diff+A.txt b/test/fixtures/javascript/class.diff+A.txt index afaaebca3..f6a2b662b 100644 --- a/test/fixtures/javascript/class.diff+A.txt +++ b/test/fixtures/javascript/class.diff+A.txt @@ -2,6 +2,7 @@ (ExpressionStatements (Class (Identifier) + (Assignment(Identifier)(NumberLiteral)) (Method (Identifier) (Identifier) diff --git a/test/fixtures/javascript/class.diff-A.txt b/test/fixtures/javascript/class.diff-A.txt index 36dc9cd77..742cf3cad 100644 --- a/test/fixtures/javascript/class.diff-A.txt +++ b/test/fixtures/javascript/class.diff-A.txt @@ -2,6 +2,7 @@ (ExpressionStatements (Class (Identifier) + (Assignment(Identifier)(NumberLiteral)) (Method (Identifier) (Identifier) diff --git a/test/fixtures/javascript/class.diffA-B.txt b/test/fixtures/javascript/class.diffA-B.txt index e207f1607..c18b2340c 100644 --- a/test/fixtures/javascript/class.diffA-B.txt +++ b/test/fixtures/javascript/class.diffA-B.txt @@ -1,22 +1,10 @@ (Program (ExpressionStatements - (Class - (Identifier) - (Method - { (Identifier) - ->(Identifier) } - (Identifier) - (Return - (Identifier))) - (Method - { (Identifier) - ->(Identifier) } - (Identifier) - (Return - (Identifier))) - (Method - { (Identifier) - ->(Identifier) } - (Identifier) - (Return - (Identifier)))))) + (Class (Identifier) + {+(Method(Identifier)(Identifier)(Return(Identifier)))+} + { +(Method(Identifier)(Identifier)(Return(Identifier)))+ } + { +(Method(Identifier)(Identifier)(Return(Identifier)))+ } + { -(Assignment(Identifier)(NumberLiteral))- } + { -(Method(Identifier)(Identifier)(Return(Identifier)))- } + { -(Method(Identifier)(Identifier)(Return(Identifier)))- } + { -(Method(Identifier)(Identifier)(Return(Identifier)))- }))) diff --git a/test/fixtures/javascript/class.diffB-A.txt b/test/fixtures/javascript/class.diffB-A.txt index e207f1607..eb9f5a9b5 100644 --- a/test/fixtures/javascript/class.diffB-A.txt +++ b/test/fixtures/javascript/class.diffB-A.txt @@ -2,6 +2,7 @@ (ExpressionStatements (Class (Identifier) + {+(Assignment(Identifier)(NumberLiteral))+} (Method { (Identifier) ->(Identifier) } diff --git a/test/fixtures/javascript/class.parseA.txt b/test/fixtures/javascript/class.parseA.txt index 69357f135..ade4aceb6 100644 --- a/test/fixtures/javascript/class.parseA.txt +++ b/test/fixtures/javascript/class.parseA.txt @@ -2,6 +2,7 @@ (ExpressionStatements (Class (Identifier) + (Assignment(Identifier)(NumberLiteral)) (Method (Identifier) (Identifier)