From 32130e68c3b6f83d7f1ff6af726bda85cf9bf97d Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:41:54 -0400 Subject: [PATCH 01/71] ++js-test --- test/repos/js-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/repos/js-test b/test/repos/js-test index 0989485a6..bcb07d990 160000 --- a/test/repos/js-test +++ b/test/repos/js-test @@ -1 +1 @@ -Subproject commit 0989485a6fad0ac82c12410c6ae6c9d5453662a2 +Subproject commit bcb07d9909ab948bb5c9b3e3853a2d46f3cec531 From fd1b648a9e0319814b674c33526c289155a4a9ae Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:42:27 -0400 Subject: [PATCH 02/71] ++js-test --- test/repos/js-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/repos/js-test b/test/repos/js-test index bcb07d990..4a6e3d1a2 160000 --- a/test/repos/js-test +++ b/test/repos/js-test @@ -1 +1 @@ -Subproject commit bcb07d9909ab948bb5c9b3e3853a2d46f3cec531 +Subproject commit 4a6e3d1a2b50d2ea285ef6f8681216bdb3442e94 From 2490d92c377bc8b5f0db3c5f6e80fc2b34c298db Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:45:25 -0400 Subject: [PATCH 03/71] Add Try statement --- src/Syntax.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Syntax.hs b/src/Syntax.hs index d06897412..477bdd06a 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -60,6 +60,7 @@ data Syntax | DoWhile { doWhileBody :: f, doWhileExpr :: f } | While { whileExpr :: f, whileBody :: f } | Return (Maybe f) + | Try f (Maybe f) (Maybe f) deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable) From ad9c63ef4230099ac78934f34fadb0c83c8a8990 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:58:49 -0400 Subject: [PATCH 04/71] Add Try/Catch/Finally categories --- src/Category.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Category.hs b/src/Category.hs index 24f31d4c2..fe111559b 100644 --- a/src/Category.hs +++ b/src/Category.hs @@ -77,6 +77,12 @@ data Category | Object -- | A return statement. | Return + -- | A try statement. + | Try + -- | A catch statement. + | Catch + -- | A finally statement. + | Finally -- | A non-standard category, which can be used for comparability. | Other Text deriving (Eq, Generic, Ord, Show) From f767ad20dbc2e551618ccbd1152c05e0db42626e Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:58:55 -0400 Subject: [PATCH 05/71] Construct Try terms --- src/Parser.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Parser.hs b/src/Parser.hs index 4f408596e..70e839609 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -101,5 +101,13 @@ termConstructor source sourceSpan info = cofree . construct withDefaultInfo $ S.While expr body construct children | DoWhile == (category info), [expr, body] <- children = withDefaultInfo $ S.DoWhile expr body + construct children | Try == category info = case children of + [body] -> withDefaultInfo $ S.Try body Nothing Nothing + [body, catch] | Catch <- category (extract catch) -> withDefaultInfo $ S.Try body (Just catch) Nothing + [body, finally] | Finally <- category (extract finally) -> withDefaultInfo $ S.Try body Nothing (Just finally) + [body, catch, finally] | Catch <- category (extract catch), + Finally <- category (extract finally) -> + withDefaultInfo $ S.Try body (Just catch) (Just finally) + _ -> S.Error sourceSpan children construct children = withDefaultInfo $ S.Indexed children From 0c8f13f396e843a90b9dcd96e2647acde3804f03 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:59:05 -0400 Subject: [PATCH 06/71] Add Try case to JSON --- src/Renderer/JSON.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Renderer/JSON.hs b/src/Renderer/JSON.hs index 2c6d726da..9da214689 100644 --- a/src/Renderer/JSON.hs +++ b/src/Renderer/JSON.hs @@ -90,6 +90,7 @@ termFields info syntax = "range" .= characterRange info : "category" .= category S.Comment _ -> [] S.Commented comments child -> childrenFields (comments <> maybeToList child) S.Error sourceSpan c -> [ "sourceSpan" .= sourceSpan ] <> childrenFields c + S.Try body catch finally -> [ "tryBody" .= body ] <> [ "tryCatch" .= catch ] <> [ "tryFinally" .= finally ] where childrenFields c = [ "children" .= c ] patchFields :: (KeyValue kv, HasField fields Category, HasField fields Range) => SplitPatch (Term leaf (Record fields)) -> [kv] From 2de0afbe959e00db904502a68f12f7ec0568a685 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:59:14 -0400 Subject: [PATCH 07/71] Add Try/Catch/Finally to Split --- src/Renderer/Split.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Renderer/Split.hs b/src/Renderer/Split.hs index 0d1f117c3..7e244f872 100644 --- a/src/Renderer/Split.hs +++ b/src/Renderer/Split.hs @@ -65,6 +65,9 @@ styleName category = "category-" <> case category of C.While -> "while" C.DoWhile -> "do_while" C.Return -> "return_statement" + C.Try -> "try_statement" + C.Catch -> "catch_statement" + C.Finally -> "finally_statement" Other string -> string -- | Pick the class name for a split patch. From ddcb6f6a1d5e695563df9cedc0ce6d9e9e35a92e Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:59:51 -0400 Subject: [PATCH 08/71] Add Try/Catch/Finally cases to defaultCategoryForNodeName --- src/TreeSitter.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 9727c0f4b..5bb0b0c2b 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -82,6 +82,9 @@ defaultCategoryForNodeName name = case name of "while_statement" -> While "do_statement" -> DoWhile "return_statement" -> Return + "try_statement" -> Try + "catch" -> Catch + "finally" -> Finally _ -> Other name -- | Return a parser for a tree sitter language & document. From 0bfa2fef2bc282a492a48f0766b07d96ea8a379e Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:02:25 -0400 Subject: [PATCH 09/71] Add Try to toTermName --- src/DiffSummary.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index dc4da3aa8..502058a54 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -68,6 +68,7 @@ toTermName source term = case unwrap term of forClauseRanges = characterRange . extract <$> exprs S.While expr _ -> toTermName' expr S.DoWhile _ expr -> toTermName' expr + S.Try expr _ _ -> toText $ Source.slice (characterRange $ extract expr) source Comment a -> toCategoryName a where toTermName' = toTermName source From d20c1658801b9c0d118b4bf6501655975e2caddf Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:02:39 -0400 Subject: [PATCH 10/71] Add Try/Catch/Finally to HasCategory instance --- src/DiffSummary.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 502058a54..b09a43f0b 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -115,6 +115,9 @@ instance HasCategory Category where C.DoWhile -> "do/while statement" C.Object -> "object" C.Return -> "return statement" + C.Catch -> "catch statement" + C.Try -> "try statement" + C.Finally -> "finally statement" instance (HasCategory leaf, HasField fields Category) => HasCategory (Term leaf (Record fields)) where toCategoryName = toCategoryName . category . extract From 3ab1501b4e8f4e236f75c4018e01a9975ffc5f7c Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:03:06 -0400 Subject: [PATCH 11/71] Add Try case to diffSummary --- src/DiffSummary.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index b09a43f0b..34075706e 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -190,6 +190,7 @@ diffSummary sources = cata $ \case (Free (infos :< S.For exprs body)) -> annotateWithCategory infos <$> join exprs <> body (Free (infos :< S.While expr body)) -> annotateWithCategory infos <$> expr <> body (Free (infos :< S.DoWhile expr body)) -> annotateWithCategory infos <$> expr <> body + (Free (infos :< S.Try expr catch finally)) -> annotateWithCategory infos <$> expr <> fromMaybe [] catch <> fromMaybe [] finally (Pure (Insert term)) -> [ DiffSummary (Insert $ termToDiffInfo afterSource term) [] ] (Pure (Delete term)) -> [ DiffSummary (Delete $ termToDiffInfo beforeSource term) [] ] (Pure (Replace t1 t2)) -> [ DiffSummary (Replace (termToDiffInfo beforeSource t1) (termToDiffInfo afterSource t2)) [] ] From 0bbc9293e9705905c67fad16b27b18c1a5c168ef Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:06:22 -0400 Subject: [PATCH 12/71] Return a CofreeF instead of Syntax --- src/Parser.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parser.hs b/src/Parser.hs index 70e839609..efb70bc78 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -108,6 +108,6 @@ termConstructor source sourceSpan info = cofree . construct [body, catch, finally] | Catch <- category (extract catch), Finally <- category (extract finally) -> withDefaultInfo $ S.Try body (Just catch) (Just finally) - _ -> S.Error sourceSpan children + _ -> withDefaultInfo $ S.Error sourceSpan children construct children = withDefaultInfo $ S.Indexed children From 04a976969e43ba2644f574dd54f19f1f4fdbff15 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:16:58 -0400 Subject: [PATCH 13/71] ++js-test --- test/repos/js-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/repos/js-test b/test/repos/js-test index 0989485a6..4a6e3d1a2 160000 --- a/test/repos/js-test +++ b/test/repos/js-test @@ -1 +1 @@ -Subproject commit 0989485a6fad0ac82c12410c6ae6c9d5453662a2 +Subproject commit 4a6e3d1a2b50d2ea285ef6f8681216bdb3442e94 From edaab80540982cc4a6fe7b5a91be08ca3e930130 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:22:41 -0400 Subject: [PATCH 14/71] Add Class to Syntax --- src/Syntax.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Syntax.hs b/src/Syntax.hs index d06897412..48d1c965f 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -60,6 +60,7 @@ data Syntax | DoWhile { doWhileBody :: f, doWhileExpr :: f } | While { whileExpr :: f, whileBody :: f } | Return (Maybe f) + | Class f (Maybe f) [f] deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable) From ef78210447f649eb674fd2db874219d7838adac9 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:28:27 -0400 Subject: [PATCH 15/71] Add a Class category --- src/Category.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Category.hs b/src/Category.hs index 24f31d4c2..f52d9de1c 100644 --- a/src/Category.hs +++ b/src/Category.hs @@ -77,6 +77,8 @@ data Category | Object -- | A return statement. | Return + -- | A class declaration. + | Class -- | A non-standard category, which can be used for comparability. | Other Text deriving (Eq, Generic, Ord, Show) From 82de031db88bc2fc09e7dac2e1e1af3057c9ee72 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:28:34 -0400 Subject: [PATCH 16/71] Construct Class nodes --- src/Parser.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Parser.hs b/src/Parser.hs index 4f408596e..1b86f3486 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -101,5 +101,12 @@ termConstructor source sourceSpan info = cofree . construct withDefaultInfo $ S.While expr body construct children | DoWhile == (category info), [expr, body] <- children = withDefaultInfo $ S.DoWhile expr body + construct children | Class == category info = case children of + [identifier, superclass, classBody] | S.Indexed definitions <- unwrap classBody -> + withDefaultInfo $ S.Class identifier (Just superclass) definitions + [identifier, classBody] | S.Indexed definitions <- unwrap classBody -> + withDefaultInfo $ S.Class identifier Nothing definitions + _ -> + withDefaultInfo $ S.Error sourceSpan children construct children = withDefaultInfo $ S.Indexed children From 1dc3fb272746953fc216ae4961118477f6efd263 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:28:51 -0400 Subject: [PATCH 17/71] Add a Class JS mapping in categoriesForLanguage --- src/TreeSitter.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 9727c0f4b..06779dd43 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -44,6 +44,7 @@ categoriesForLanguage language name = case (language, name) of (JavaScript, "void_op") -> Operator (JavaScript, "for_in_statement") -> For (JavaScript, "for_of_statement") -> For + (JavaScript, "class") -> Class (Ruby, "hash") -> Object _ -> defaultCategoryForNodeName name From 1fb7ff4016a06e737c6dacced27d586e6984e0b5 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:31:00 -0400 Subject: [PATCH 18/71] Add Class to JSON --- src/Renderer/JSON.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Renderer/JSON.hs b/src/Renderer/JSON.hs index 2c6d726da..a8cd2381c 100644 --- a/src/Renderer/JSON.hs +++ b/src/Renderer/JSON.hs @@ -90,6 +90,7 @@ termFields info syntax = "range" .= characterRange info : "category" .= category S.Comment _ -> [] S.Commented comments child -> childrenFields (comments <> maybeToList child) S.Error sourceSpan c -> [ "sourceSpan" .= sourceSpan ] <> childrenFields c + S.Class identifier superclass definitions -> [ "classIdentifier" .= identifier ] <> [ "superclass" .= superclass ] <> [ "classDefinitions" .= definitions ] where childrenFields c = [ "children" .= c ] patchFields :: (KeyValue kv, HasField fields Category, HasField fields Range) => SplitPatch (Term leaf (Record fields)) -> [kv] From ce0c19e2796ee14e9f7cfb086015d51143b9bdba Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:31:19 -0400 Subject: [PATCH 19/71] Add class to styleName --- src/Renderer/Split.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Renderer/Split.hs b/src/Renderer/Split.hs index 0d1f117c3..c973d9f82 100644 --- a/src/Renderer/Split.hs +++ b/src/Renderer/Split.hs @@ -65,6 +65,7 @@ styleName category = "category-" <> case category of C.While -> "while" C.DoWhile -> "do_while" C.Return -> "return_statement" + C.Class -> "class_statement" Other string -> string -- | Pick the class name for a split patch. From b74a2a6f795145b79a9629043c4fb8ca215d4053 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:32:52 -0400 Subject: [PATCH 20/71] Add Class to toTermName --- src/DiffSummary.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index dc4da3aa8..c49f71872 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -68,6 +68,7 @@ toTermName source term = case unwrap term of forClauseRanges = characterRange . extract <$> exprs S.While expr _ -> toTermName' expr S.DoWhile _ expr -> toTermName' expr + S.Class identifier _ _ -> toTermName' identifier Comment a -> toCategoryName a where toTermName' = toTermName source From ca563deafde05d056825dd040ab8130dbe7d1910 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:33:05 -0400 Subject: [PATCH 21/71] Add Class to HasCategory Category instance --- src/DiffSummary.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index c49f71872..b0071fc44 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -115,6 +115,7 @@ instance HasCategory Category where C.DoWhile -> "do/while statement" C.Object -> "object" C.Return -> "return statement" + C.Class -> "class" instance (HasCategory leaf, HasField fields Category) => HasCategory (Term leaf (Record fields)) where toCategoryName = toCategoryName . category . extract From cb5df9b593a2eb7959216f543208a912222cc393 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:33:12 -0400 Subject: [PATCH 22/71] Add Class to diffSummary --- src/DiffSummary.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index b0071fc44..dd3dcb6e1 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -188,6 +188,7 @@ diffSummary sources = cata $ \case (Free (infos :< S.For exprs body)) -> annotateWithCategory infos <$> join exprs <> body (Free (infos :< S.While expr body)) -> annotateWithCategory infos <$> expr <> body (Free (infos :< S.DoWhile expr body)) -> annotateWithCategory infos <$> expr <> body + (Free (infos :< S.Class identifier superclass definitions)) -> annotateWithCategory infos <$> identifier <> superclass <> join definitions (Pure (Insert term)) -> [ DiffSummary (Insert $ termToDiffInfo afterSource term) [] ] (Pure (Delete term)) -> [ DiffSummary (Delete $ termToDiffInfo beforeSource term) [] ] (Pure (Replace t1 t2)) -> [ DiffSummary (Replace (termToDiffInfo beforeSource t1) (termToDiffInfo afterSource t2)) [] ] From b242555021182e0b9309f11a8d17f111f8558a38 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:34:09 -0400 Subject: [PATCH 23/71] ++js-test --- test/repos/js-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/repos/js-test b/test/repos/js-test index 4a6e3d1a2..44c2dcac3 160000 --- a/test/repos/js-test +++ b/test/repos/js-test @@ -1 +1 @@ -Subproject commit 4a6e3d1a2b50d2ea285ef6f8681216bdb3442e94 +Subproject commit 44c2dcac37823fc6493c9226bfa15c7da1357d2c From 770c144a308a8ac8f08c9cb8384be5395d6c83a7 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:35:52 -0400 Subject: [PATCH 24/71] use fromMaybe since superclass is a Maybe --- src/DiffSummary.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index dd3dcb6e1..903da38e4 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -188,7 +188,7 @@ diffSummary sources = cata $ \case (Free (infos :< S.For exprs body)) -> annotateWithCategory infos <$> join exprs <> body (Free (infos :< S.While expr body)) -> annotateWithCategory infos <$> expr <> body (Free (infos :< S.DoWhile expr body)) -> annotateWithCategory infos <$> expr <> body - (Free (infos :< S.Class identifier superclass definitions)) -> annotateWithCategory infos <$> identifier <> superclass <> join definitions + (Free (infos :< S.Class identifier superclass definitions)) -> annotateWithCategory infos <$> identifier <> fromMaybe [] superclass <> join definitions (Pure (Insert term)) -> [ DiffSummary (Insert $ termToDiffInfo afterSource term) [] ] (Pure (Delete term)) -> [ DiffSummary (Delete $ termToDiffInfo beforeSource term) [] ] (Pure (Replace t1 t2)) -> [ DiffSummary (Replace (termToDiffInfo beforeSource t1) (termToDiffInfo afterSource t2)) [] ] From 12e8d15002488fb5239230528b15be90912e19aa Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:40:41 -0400 Subject: [PATCH 25/71] ++js-test --- test/repos/js-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/repos/js-test b/test/repos/js-test index 0989485a6..1c6b3eede 160000 --- a/test/repos/js-test +++ b/test/repos/js-test @@ -1 +1 @@ -Subproject commit 0989485a6fad0ac82c12410c6ae6c9d5453662a2 +Subproject commit 1c6b3eedec733198c32d097860fca556174e9a3d From 19b29e6beb2e5aea2a5e673d8bb1c6f3438f4a25 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:42:38 -0400 Subject: [PATCH 26/71] Add Array to Syntax --- src/Syntax.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Syntax.hs b/src/Syntax.hs index d06897412..2e4a19ce9 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -60,6 +60,7 @@ data Syntax | DoWhile { doWhileBody :: f, doWhileExpr :: f } | While { whileExpr :: f, whileBody :: f } | Return (Maybe f) + | Array [f] deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable) From bd0ac540c64f90f32819b22782f7d36425b023f9 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:43:59 -0400 Subject: [PATCH 27/71] Construct Array syntax --- src/Parser.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Parser.hs b/src/Parser.hs index 4f408596e..8751736f0 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -101,5 +101,7 @@ termConstructor source sourceSpan info = cofree . construct withDefaultInfo $ S.While expr body construct children | DoWhile == (category info), [expr, body] <- children = withDefaultInfo $ S.DoWhile expr body + construct children | ArrayLiteral == category info = + withDefaultInfo $ S.Array children construct children = withDefaultInfo $ S.Indexed children From 65c9d53c6b7b341ac68b0600346edaf2f9891547 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:45:07 -0400 Subject: [PATCH 28/71] Add ArrayLiteral to Split.styleName --- src/Renderer/JSON.hs | 1 + src/Renderer/Split.hs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Renderer/JSON.hs b/src/Renderer/JSON.hs index 2c6d726da..2cb3d64e0 100644 --- a/src/Renderer/JSON.hs +++ b/src/Renderer/JSON.hs @@ -90,6 +90,7 @@ termFields info syntax = "range" .= characterRange info : "category" .= category S.Comment _ -> [] S.Commented comments child -> childrenFields (comments <> maybeToList child) S.Error sourceSpan c -> [ "sourceSpan" .= sourceSpan ] <> childrenFields c + S.Array c -> childrenFields c where childrenFields c = [ "children" .= c ] patchFields :: (KeyValue kv, HasField fields Category, HasField fields Range) => SplitPatch (Term leaf (Record fields)) -> [kv] diff --git a/src/Renderer/Split.hs b/src/Renderer/Split.hs index 0d1f117c3..9d31a21fe 100644 --- a/src/Renderer/Split.hs +++ b/src/Renderer/Split.hs @@ -40,7 +40,6 @@ styleName category = "category-" <> case category of StringLiteral -> "string" SymbolLiteral -> "symbol" IntegerLiteral -> "integer" - ArrayLiteral -> "array" C.FunctionCall -> "function_call" C.Function -> "function" C.MethodCall -> "method_call" @@ -65,6 +64,7 @@ styleName category = "category-" <> case category of C.While -> "while" C.DoWhile -> "do_while" C.Return -> "return_statement" + C.ArrayLiteral -> "array" Other string -> string -- | Pick the class name for a split patch. From 9453f8949d627f922385b2432ed86e22276d15d2 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:46:04 -0400 Subject: [PATCH 29/71] Add Array to toTermName --- src/DiffSummary.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index dc4da3aa8..112a85865 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -68,6 +68,7 @@ toTermName source term = case unwrap term of forClauseRanges = characterRange . extract <$> exprs S.While expr _ -> toTermName' expr S.DoWhile _ expr -> toTermName' expr + S.Array _ -> toText $ Source.slice (characterRange $ extract term) source Comment a -> toCategoryName a where toTermName' = toTermName source From 5bef01097045b3ea4326d7a8003deaa6c93de9f9 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:46:16 -0400 Subject: [PATCH 30/71] Don't need to scope ArrayLiteral in styleName --- src/Renderer/Split.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Renderer/Split.hs b/src/Renderer/Split.hs index 9d31a21fe..d083c0445 100644 --- a/src/Renderer/Split.hs +++ b/src/Renderer/Split.hs @@ -64,7 +64,7 @@ styleName category = "category-" <> case category of C.While -> "while" C.DoWhile -> "do_while" C.Return -> "return_statement" - C.ArrayLiteral -> "array" + ArrayLiteral -> "array" Other string -> string -- | Pick the class name for a split patch. From 2a021201312d72cf2d167ca17fb49ee83848b8cb Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:47:08 -0400 Subject: [PATCH 31/71] Add Array to diffSummary --- src/DiffSummary.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 112a85865..bed1b84ff 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -187,6 +187,7 @@ diffSummary sources = cata $ \case (Free (infos :< S.For exprs body)) -> annotateWithCategory infos <$> join exprs <> body (Free (infos :< S.While expr body)) -> annotateWithCategory infos <$> expr <> body (Free (infos :< S.DoWhile expr body)) -> annotateWithCategory infos <$> expr <> body + (Free (infos :< S.Array children)) -> annotateWithCategory infos <$> join children (Pure (Insert term)) -> [ DiffSummary (Insert $ termToDiffInfo afterSource term) [] ] (Pure (Delete term)) -> [ DiffSummary (Delete $ termToDiffInfo beforeSource term) [] ] (Pure (Replace t1 t2)) -> [ DiffSummary (Replace (termToDiffInfo beforeSource t1) (termToDiffInfo afterSource t2)) [] ] From a18305da09555e97ed3ba96dca3660b9f94f184c Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:50:10 -0400 Subject: [PATCH 32/71] qualify Aeson.Array as A.Array --- src/Renderer/JSON.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Renderer/JSON.hs b/src/Renderer/JSON.hs index 2cb3d64e0..4e2becb68 100644 --- a/src/Renderer/JSON.hs +++ b/src/Renderer/JSON.hs @@ -7,7 +7,7 @@ module Renderer.JSON ( import Prologue hiding (toList) import Alignment import Category -import Data.Aeson hiding (json) +import Data.Aeson as A hiding (json) import Data.Bifunctor.Join import Data.ByteString.Builder import Data.Record @@ -36,13 +36,13 @@ instance ToJSON Category where toJSON (Other s) = String s toJSON s = String . T.pack $ show s instance ToJSON Range where - toJSON (Range start end) = Array . fromList $ toJSON <$> [ start, end ] + toJSON (Range start end) = A.Array . fromList $ toJSON <$> [ start, end ] toEncoding (Range start end) = foldable [ start, end ] instance ToJSON a => ToJSON (Join These a) where - toJSON (Join vs) = Array . fromList $ toJSON <$> these pure pure (\ a b -> [ a, b ]) vs + toJSON (Join vs) = A.Array . fromList $ toJSON <$> these pure pure (\ a b -> [ a, b ]) vs toEncoding = foldable instance ToJSON a => ToJSON (Join (,) a) where - toJSON (Join (a, b)) = Array . fromList $ toJSON <$> [ a, b ] + toJSON (Join (a, b)) = A.Array . fromList $ toJSON <$> [ a, b ] toEncoding = foldable instance (HasField fields Category, HasField fields Range) => ToJSON (SplitDiff leaf (Record fields)) where toJSON splitDiff = case runFree splitDiff of From b354ed61d9f94fe376f37ad18c02fa6a11bfe054 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:57:30 -0400 Subject: [PATCH 33/71] ++js-test --- test/repos/js-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/repos/js-test b/test/repos/js-test index 44c2dcac3..7a46849e3 160000 --- a/test/repos/js-test +++ b/test/repos/js-test @@ -1 +1 @@ -Subproject commit 44c2dcac37823fc6493c9226bfa15c7da1357d2c +Subproject commit 7a46849e3dca65bcb8baf099fb2c59ca151571b0 From 5b32cd254efcf39b57a3c40a35ee69401071e5c3 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 17:37:21 -0400 Subject: [PATCH 34/71] ++tree-sitter-parsers --- vendor/tree-sitter-parsers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/tree-sitter-parsers b/vendor/tree-sitter-parsers index 0fdcbafdb..1229ed83d 160000 --- a/vendor/tree-sitter-parsers +++ b/vendor/tree-sitter-parsers @@ -1 +1 @@ -Subproject commit 0fdcbafdb69853a03db28e789bb00a2f733c6990 +Subproject commit 1229ed83d0501dc3dbca9d4ceab70702763c76bb From 2985bbd25680b84aa5136f03659b31d396ed3ce0 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 17:37:51 -0400 Subject: [PATCH 35/71] Add MethodDefinition to Syntax --- src/Syntax.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Syntax.hs b/src/Syntax.hs index 48d1c965f..c82b8974d 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -61,6 +61,7 @@ data Syntax | While { whileExpr :: f, whileBody :: f } | Return (Maybe f) | Class f (Maybe f) [f] + | MethodDefinition f (Maybe f) f deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable) From 828a2163bf8ece676e933a2d7b6ac29de57cff9a Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 18:31:39 -0400 Subject: [PATCH 36/71] Add MethodDefinition --- src/Syntax.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Syntax.hs b/src/Syntax.hs index c82b8974d..3c327bb7f 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -60,8 +60,10 @@ data Syntax | DoWhile { doWhileBody :: f, doWhileExpr :: f } | While { whileExpr :: f, whileBody :: f } | Return (Maybe f) + -- | A class with an identifier, superclass, and a list of definitions. | Class f (Maybe f) [f] - | MethodDefinition f (Maybe f) f + -- | A method definition with an identifier, params, and a body. + | MethodDefinition f [f] [f] deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable) From f931031515a9a578010e164daa86cc40d32cbe34 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 18:33:01 -0400 Subject: [PATCH 37/71] s/body/list of expressions --- src/Syntax.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Syntax.hs b/src/Syntax.hs index 3c327bb7f..d83e9dbb8 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -62,7 +62,7 @@ data Syntax | Return (Maybe f) -- | A class with an identifier, superclass, and a list of definitions. | Class f (Maybe f) [f] - -- | A method definition with an identifier, params, and a body. + -- | A method definition with an identifier, params, and a list of expressions. | MethodDefinition f [f] [f] deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable) From bb630ebbb0d20be02f5fb51c983a06abc21d365b Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 18:33:09 -0400 Subject: [PATCH 38/71] Move Syntax instance up --- src/Syntax.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Syntax.hs b/src/Syntax.hs index d83e9dbb8..56da146b7 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -69,6 +69,11 @@ data Syntax -- Instances +instance (Arbitrary leaf, Arbitrary f) => Arbitrary (Syntax leaf f) where + arbitrary = sized (syntaxOfSize (`resize` arbitrary) ) + + shrink = genericShrink + syntaxOfSize :: Arbitrary leaf => (Int -> Gen f) -> Int -> Gen (Syntax leaf f) syntaxOfSize recur n | n <= 1 = oneof $ (Leaf <$> arbitrary) : branchGeneratorsOfSize n | otherwise = oneof $ branchGeneratorsOfSize n @@ -82,8 +87,3 @@ syntaxOfSize recur n | n <= 1 = oneof $ (Leaf <$> arbitrary) : branchGeneratorsO first <- recur m rest <- childrenOfSize (n - m) pure $! first : rest - -instance (Arbitrary leaf, Arbitrary f) => Arbitrary (Syntax leaf f) where - arbitrary = sized (syntaxOfSize (`resize` arbitrary) ) - - shrink = genericShrink From 1c5f94631c3e858b269cfc10df6a7e65d4a27588 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 18:37:41 -0400 Subject: [PATCH 39/71] s/diffSummary/diffSummaries --- src/DiffSummary.hs | 6 +++--- src/Renderer/Summary.hs | 2 +- test/DiffSummarySpec.hs | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 903da38e4..5854a9143 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -1,6 +1,6 @@ {-# LANGUAGE DataKinds, TypeFamilies, ScopedTypeVariables #-} -module DiffSummary (DiffSummary(..), diffSummary, DiffInfo(..), annotatedSummaries) where +module DiffSummary (DiffSummary(..), diffSummaries, DiffInfo(..), annotatedSummaries) where import Prologue hiding (snd, intercalate) import Diff @@ -159,8 +159,8 @@ maybeParentContext annotations = if null annotations toDoc :: Text -> Doc toDoc = string . toS -diffSummary :: (HasCategory leaf, HasField fields Category, HasField fields Range) => Both (Source Char) -> Diff leaf (Record fields) -> [DiffSummary DiffInfo] -diffSummary sources = cata $ \case +diffSummaries :: (HasCategory leaf, HasField fields Category, HasField fields Range) => Both (Source Char) -> Diff leaf (Record fields) -> [DiffSummary DiffInfo] +diffSummaries sources = cata $ \case -- Skip comments and leaves since they don't have any changes (Free (_ :< Leaf _)) -> [] Free (_ :< (S.Comment _)) -> [] diff --git a/src/Renderer/Summary.hs b/src/Renderer/Summary.hs index 1969da4af..68bed1987 100644 --- a/src/Renderer/Summary.hs +++ b/src/Renderer/Summary.hs @@ -11,4 +11,4 @@ import Source summary :: (HasField fields Category, HasField fields Range) => Renderer (Record fields) summary blobs diff = toS . encode $ summaries >>= annotatedSummaries - where summaries = diffSummary (source <$> blobs) diff \ No newline at end of file + where summaries = diffSummaries (source <$> blobs) diff \ No newline at end of file diff --git a/test/DiffSummarySpec.hs b/test/DiffSummarySpec.hs index dfc01e535..dc648c4bf 100644 --- a/test/DiffSummarySpec.hs +++ b/test/DiffSummarySpec.hs @@ -41,13 +41,13 @@ sources = both (fromText "[]") (fromText "[a]") spec :: Spec spec = parallel $ do - describe "diffSummary" $ do + describe "diffSummaries" $ do it "outputs a diff summary" $ do - diffSummary sources testDiff `shouldBe` [ DiffSummary { patch = Insert (LeafInfo "string" "a"), parentAnnotations = [ ArrayLiteral ] } ] + diffSummaries sources testDiff `shouldBe` [ DiffSummary { patch = Insert (LeafInfo "string" "a"), parentAnnotations = [ ArrayLiteral ] } ] prop "equal terms produce identity diffs" $ \ a -> let term = toTerm (a :: ArbitraryTerm Text (Record '[Category, Range])) in - diffSummary sources (diffTerms wrap (==) diffCost term term) `shouldBe` [] + diffSummaries sources (diffTerms wrap (==) diffCost term term) `shouldBe` [] describe "annotatedSummaries" $ do it "should print adds" $ @@ -58,7 +58,7 @@ spec = parallel $ do prop "patches in summaries match the patches in diffs" $ \a -> let diff = (toDiff (a :: ArbitraryDiff Text (Record '[Category, Cost, Range]))) - summaries = diffSummary sources diff + summaries = diffSummaries sources diff patches = toList diff in case (partition isBranchNode (patch <$> summaries), partition isIndexedOrFixed patches) of @@ -67,7 +67,7 @@ spec = parallel $ do prop "generates one LeafInfo for each child in an arbitrary branch patch" $ \a -> let diff = (toDiff (a :: ArbitraryDiff Text (Record '[Category, Range]))) - diffInfoPatches = patch <$> diffSummary sources diff + diffInfoPatches = patch <$> diffSummaries sources diff syntaxPatches = toList diff extractLeaves :: DiffInfo -> [DiffInfo] extractLeaves (BranchInfo children _ _) = join $ extractLeaves <$> children From eb3df7db6a16a1268283ad575b7cf27ef2e5c65d Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 18:39:08 -0400 Subject: [PATCH 40/71] MethodDefinition --- src/DiffSummary.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 5854a9143..005c0781b 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -189,6 +189,7 @@ diffSummaries sources = cata $ \case (Free (infos :< S.While expr body)) -> annotateWithCategory infos <$> expr <> body (Free (infos :< S.DoWhile expr body)) -> annotateWithCategory infos <$> expr <> body (Free (infos :< S.Class identifier superclass definitions)) -> annotateWithCategory infos <$> identifier <> fromMaybe [] superclass <> join definitions + (Free (infos :< S.MethodDefinition identifier params definitions)) -> annotateWithCategory infos <$> identifier <> join params <> join definitions (Pure (Insert term)) -> [ DiffSummary (Insert $ termToDiffInfo afterSource term) [] ] (Pure (Delete term)) -> [ DiffSummary (Delete $ termToDiffInfo beforeSource term) [] ] (Pure (Replace t1 t2)) -> [ DiffSummary (Replace (termToDiffInfo beforeSource t1) (termToDiffInfo afterSource t2)) [] ] From d3df14cafde3ef6b9de84280512bd3938738b36d Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 23:41:21 -0400 Subject: [PATCH 41/71] Add method definitions --- src/Category.hs | 2 ++ src/Parser.hs | 2 ++ src/Syntax.hs | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Category.hs b/src/Category.hs index f52d9de1c..68b089d89 100644 --- a/src/Category.hs +++ b/src/Category.hs @@ -79,6 +79,8 @@ data Category | Return -- | A class declaration. | Class + -- | A class method declaration. + | Method -- | A non-standard category, which can be used for comparability. | Other Text deriving (Eq, Generic, Ord, Show) diff --git a/src/Parser.hs b/src/Parser.hs index 1b86f3486..e890d16ce 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -101,6 +101,8 @@ termConstructor source sourceSpan info = cofree . construct withDefaultInfo $ S.While expr body construct children | DoWhile == (category info), [expr, body] <- children = withDefaultInfo $ S.DoWhile expr body + construct children | Method == category info, [identifier, params, definitions] <- children = + withDefaultInfo $ S.Method identifier params definitions construct children | Class == category info = case children of [identifier, superclass, classBody] | S.Indexed definitions <- unwrap classBody -> withDefaultInfo $ S.Class identifier (Just superclass) definitions diff --git a/src/Syntax.hs b/src/Syntax.hs index 56da146b7..0ab0a7cfc 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -63,7 +63,7 @@ data Syntax -- | A class with an identifier, superclass, and a list of definitions. | Class f (Maybe f) [f] -- | A method definition with an identifier, params, and a list of expressions. - | MethodDefinition f [f] [f] + | Method f [f] [f] deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable) From 69e2c99634d7976101d29148f0bd0ef3d634ba8c Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 13:26:21 -0400 Subject: [PATCH 42/71] update Method JSON --- src/Renderer/JSON.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Renderer/JSON.hs b/src/Renderer/JSON.hs index a8cd2381c..85f298859 100644 --- a/src/Renderer/JSON.hs +++ b/src/Renderer/JSON.hs @@ -15,7 +15,6 @@ import qualified Data.Text as T import Data.These import Data.Vector hiding (toList) import Info -import Range import Renderer import Source hiding (fromList) import SplitDiff @@ -90,7 +89,8 @@ termFields info syntax = "range" .= characterRange info : "category" .= category S.Comment _ -> [] S.Commented comments child -> childrenFields (comments <> maybeToList child) S.Error sourceSpan c -> [ "sourceSpan" .= sourceSpan ] <> childrenFields c - S.Class identifier superclass definitions -> [ "classIdentifier" .= identifier ] <> [ "superclass" .= superclass ] <> [ "classDefinitions" .= definitions ] + S.Class identifier superclass definitions -> [ "classIdentifier" .= identifier ] <> [ "superclass" .= superclass ] <> [ "definitions" .= definitions ] + S.Method identifier params definitions -> [ "methodIdentifier" .= identifier ] <> [ "params" .= params ] <> [ "definitions" .= definitions ] where childrenFields c = [ "children" .= c ] patchFields :: (KeyValue kv, HasField fields Category, HasField fields Range) => SplitPatch (Term leaf (Record fields)) -> [kv] From b3f523d9ef860be04c267fb9c5c895a8d944d40b Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 13:47:30 -0400 Subject: [PATCH 43/71] s/MethodDefinition/Method --- src/DiffSummary.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 005c0781b..4f8db8da8 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -189,7 +189,7 @@ diffSummaries sources = cata $ \case (Free (infos :< S.While expr body)) -> annotateWithCategory infos <$> expr <> body (Free (infos :< S.DoWhile expr body)) -> annotateWithCategory infos <$> expr <> body (Free (infos :< S.Class identifier superclass definitions)) -> annotateWithCategory infos <$> identifier <> fromMaybe [] superclass <> join definitions - (Free (infos :< S.MethodDefinition identifier params definitions)) -> annotateWithCategory infos <$> identifier <> join params <> join definitions + (Free (infos :< S.Method identifier params definitions)) -> annotateWithCategory infos <$> identifier <> join params <> join definitions (Pure (Insert term)) -> [ DiffSummary (Insert $ termToDiffInfo afterSource term) [] ] (Pure (Delete term)) -> [ DiffSummary (Delete $ termToDiffInfo beforeSource term) [] ] (Pure (Replace t1 t2)) -> [ DiffSummary (Replace (termToDiffInfo beforeSource t1) (termToDiffInfo afterSource t2)) [] ] From c8b5fb8c08b2ace5426dca333c0805b8894076e7 Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:00:47 -0400 Subject: [PATCH 44/71] Add Method to toTermName --- src/DiffSummary.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 4f8db8da8..e9b3d3a12 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -69,6 +69,7 @@ toTermName source term = case unwrap term of S.While expr _ -> toTermName' expr S.DoWhile _ expr -> toTermName' expr S.Class identifier _ _ -> toTermName' identifier + S.Method identifier _ _ -> toTermName' identifier Comment a -> toCategoryName a where toTermName' = toTermName source From 1afa6d7b0f0bcc8fdd79c68cae563daca9677eff Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:00:58 -0400 Subject: [PATCH 45/71] Add Method to HasCategory Category instance --- src/DiffSummary.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index e9b3d3a12..887949fb3 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -117,6 +117,7 @@ instance HasCategory Category where C.Object -> "object" C.Return -> "return statement" C.Class -> "class" + C.Method -> "method" instance (HasCategory leaf, HasField fields Category) => HasCategory (Term leaf (Record fields)) where toCategoryName = toCategoryName . category . extract From 792440ff56bc13e1e56846386dcaa8fe911c73c0 Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:01:15 -0400 Subject: [PATCH 46/71] Parse method definitions and method expressions better --- src/Parser.hs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/Parser.hs b/src/Parser.hs index e890d16ce..01cf22bfb 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -101,14 +101,34 @@ termConstructor source sourceSpan info = cofree . construct withDefaultInfo $ S.While expr body construct children | DoWhile == (category info), [expr, body] <- children = withDefaultInfo $ S.DoWhile expr body - construct children | Method == category info, [identifier, params, definitions] <- children = - withDefaultInfo $ S.Method identifier params definitions + construct children | Method == category info = case children of + [identifier, params, exprs] | + Params == category (extract params), + S.Indexed params' <- unwrap params, + exprs' <- expressionStatements exprs -> + withDefaultInfo $ S.Method identifier params' exprs' + [identifier, exprs] | exprs' <- expressionStatements exprs -> + withDefaultInfo $ S.Method identifier mempty exprs' + _ -> + withDefaultInfo $ S.Error sourceSpan children construct children | Class == category info = case children of - [identifier, superclass, classBody] | S.Indexed definitions <- unwrap classBody -> - withDefaultInfo $ S.Class identifier (Just superclass) definitions - [identifier, classBody] | S.Indexed definitions <- unwrap classBody -> - withDefaultInfo $ S.Class identifier Nothing definitions + [identifier, superclass, definitions] | definitions' <- methodDefinitions definitions -> + withDefaultInfo $ S.Class identifier (Just superclass) definitions' + [identifier, definitions] | definitions' <- methodDefinitions definitions -> + withDefaultInfo $ S.Class identifier Nothing definitions' _ -> withDefaultInfo $ S.Error sourceSpan children construct children = withDefaultInfo $ S.Indexed children + +expressionStatements :: HasField fields Category => Term Text (Record fields) -> [Term Text (Record fields)] +expressionStatements exprs | + Other "statement_block" == category (extract exprs), + S.Indexed exprs' <- unwrap exprs = exprs' +expressionStatements _ = mempty + +methodDefinitions :: HasField fields Category => Term Text (Record fields) -> [Term Text (Record fields)] +methodDefinitions definitions | + Other "class_body" == category (extract definitions), + S.Indexed definitions' <- unwrap definitions = definitions' +methodDefinitions _ = mempty \ No newline at end of file From 00613a034b348a54cb837c2ee7a7becc149c87df Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:01:20 -0400 Subject: [PATCH 47/71] Remove redundant import --- src/TreeSitter.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 06779dd43..6a1ef0eba 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -7,7 +7,6 @@ import Category import Info import Language import Parser -import Range import Source import Foreign import Foreign.C.String From 0e5255b7deaacdbaf104a3da93fb392d23e100e2 Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:08:46 -0400 Subject: [PATCH 48/71] Map method_definition to Method categories --- src/TreeSitter.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 6a1ef0eba..13b14a8f9 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -82,6 +82,7 @@ defaultCategoryForNodeName name = case name of "while_statement" -> While "do_statement" -> DoWhile "return_statement" -> Return + "method_definition" -> Method _ -> Other name -- | Return a parser for a tree sitter language & document. From 64dbee5cb2d98a4e39ab3a56952c7d3fdab6bb25 Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:13:36 -0400 Subject: [PATCH 49/71] ++tree-sitter-parsers ++js-test --- test/repos/js-test | 2 +- vendor/tree-sitter-parsers | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/repos/js-test b/test/repos/js-test index 0989485a6..7a46849e3 160000 --- a/test/repos/js-test +++ b/test/repos/js-test @@ -1 +1 @@ -Subproject commit 0989485a6fad0ac82c12410c6ae6c9d5453662a2 +Subproject commit 7a46849e3dca65bcb8baf099fb2c59ca151571b0 diff --git a/vendor/tree-sitter-parsers b/vendor/tree-sitter-parsers index 0fdcbafdb..1229ed83d 160000 --- a/vendor/tree-sitter-parsers +++ b/vendor/tree-sitter-parsers @@ -1 +1 @@ -Subproject commit 0fdcbafdb69853a03db28e789bb00a2f733c6990 +Subproject commit 1229ed83d0501dc3dbca9d4ceab70702763c76bb From 347f0309dd83e932866a652fd1698de920a79a6e Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:25:52 -0400 Subject: [PATCH 50/71] Add Constructor Category --- src/Category.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Category.hs b/src/Category.hs index 24f31d4c2..13303c65e 100644 --- a/src/Category.hs +++ b/src/Category.hs @@ -77,6 +77,8 @@ data Category | Object -- | A return statement. | Return + -- | A constructor statement, e.g. new Foo; + | Constructor -- | A non-standard category, which can be used for comparability. | Other Text deriving (Eq, Generic, Ord, Show) From 27941fd2ce533555ea5b4e9b70cd840170ce716f Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:26:01 -0400 Subject: [PATCH 51/71] Add Constructor to toTermName --- src/DiffSummary.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index dc4da3aa8..bc420cbe9 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -68,6 +68,7 @@ toTermName source term = case unwrap term of forClauseRanges = characterRange . extract <$> exprs S.While expr _ -> toTermName' expr S.DoWhile _ expr -> toTermName' expr + S.Constructor expr -> toTermName' expr Comment a -> toCategoryName a where toTermName' = toTermName source From 001407df2b1cff73e827a80528bf822ee2037834 Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:26:13 -0400 Subject: [PATCH 52/71] Add Constructor to HasCategory Category instance --- src/DiffSummary.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index bc420cbe9..c79704e83 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -115,6 +115,7 @@ instance HasCategory Category where C.DoWhile -> "do/while statement" C.Object -> "object" C.Return -> "return statement" + C.Constructor -> "constructor" instance (HasCategory leaf, HasField fields Category) => HasCategory (Term leaf (Record fields)) where toCategoryName = toCategoryName . category . extract From a625302391705b9ae25c18da27f4768a29a468c7 Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:26:21 -0400 Subject: [PATCH 53/71] Add Constructor to diffSummary --- src/DiffSummary.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index c79704e83..ce9f405aa 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -188,6 +188,7 @@ diffSummary sources = cata $ \case (Free (infos :< S.For exprs body)) -> annotateWithCategory infos <$> join exprs <> body (Free (infos :< S.While expr body)) -> annotateWithCategory infos <$> expr <> body (Free (infos :< S.DoWhile expr body)) -> annotateWithCategory infos <$> expr <> body + (Free (infos :< S.Constructor expr)) -> annotateWithCategory infos <$> expr (Pure (Insert term)) -> [ DiffSummary (Insert $ termToDiffInfo afterSource term) [] ] (Pure (Delete term)) -> [ DiffSummary (Delete $ termToDiffInfo beforeSource term) [] ] (Pure (Replace t1 t2)) -> [ DiffSummary (Replace (termToDiffInfo beforeSource t1) (termToDiffInfo afterSource t2)) [] ] From a456a4f64ed3598b3aeb1e67566ba660b47050d0 Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:26:32 -0400 Subject: [PATCH 54/71] Parse Constructor syntax --- src/Parser.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Parser.hs b/src/Parser.hs index 4f408596e..6cc355f0e 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -101,5 +101,7 @@ termConstructor source sourceSpan info = cofree . construct withDefaultInfo $ S.While expr body construct children | DoWhile == (category info), [expr, body] <- children = withDefaultInfo $ S.DoWhile expr body + construct children | Constructor == category info, [expr] <- children = + withDefaultInfo $ S.Constructor expr construct children = withDefaultInfo $ S.Indexed children From b68a2d8bffd8cd60ecad011207c76bd95325a243 Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:26:48 -0400 Subject: [PATCH 55/71] Add constructor to JSON --- src/Renderer/JSON.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Renderer/JSON.hs b/src/Renderer/JSON.hs index 2c6d726da..2e27c604c 100644 --- a/src/Renderer/JSON.hs +++ b/src/Renderer/JSON.hs @@ -86,7 +86,8 @@ termFields info syntax = "range" .= characterRange info : "category" .= category S.SubscriptAccess id property -> [ "subscriptId" .= id ] <> [ "property" .= property ] S.Object pairs -> childrenFields pairs S.Pair a b -> childrenFields [a, b] - S.Return expr -> [ "returnExpr" .= expr ] + S.Return expr -> [ "returnExpression" .= expr ] + S.Constructor expr -> [ "constructorExpression" .= expr ] S.Comment _ -> [] S.Commented comments child -> childrenFields (comments <> maybeToList child) S.Error sourceSpan c -> [ "sourceSpan" .= sourceSpan ] <> childrenFields c From b2c66eb5cec7ff7380ec80b81391e2e5fe04cf04 Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:26:59 -0400 Subject: [PATCH 56/71] Add Constructor to Split.styleName --- src/Renderer/Split.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Renderer/Split.hs b/src/Renderer/Split.hs index 0d1f117c3..729646340 100644 --- a/src/Renderer/Split.hs +++ b/src/Renderer/Split.hs @@ -65,6 +65,7 @@ styleName category = "category-" <> case category of C.While -> "while" C.DoWhile -> "do_while" C.Return -> "return_statement" + C.Constructor -> "constructor" Other string -> string -- | Pick the class name for a split patch. From f228ed0b6d5602006d38458f342266aa156dc1d0 Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:27:11 -0400 Subject: [PATCH 57/71] Add Constructor to Syntax --- src/Syntax.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Syntax.hs b/src/Syntax.hs index d06897412..a7eeaaece 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -60,6 +60,7 @@ data Syntax | DoWhile { doWhileBody :: f, doWhileExpr :: f } | While { whileExpr :: f, whileBody :: f } | Return (Maybe f) + | Constructor f deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable) From e2d0b01ced2ae9161d709de0908ceb5c9a73087d Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:27:34 -0400 Subject: [PATCH 58/71] Map JS new_expression to Constructor --- src/TreeSitter.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 9727c0f4b..5d5c088ad 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -44,6 +44,7 @@ categoriesForLanguage language name = case (language, name) of (JavaScript, "void_op") -> Operator (JavaScript, "for_in_statement") -> For (JavaScript, "for_of_statement") -> For + (JavaScript, "new_expression") -> Constructor (Ruby, "hash") -> Object _ -> defaultCategoryForNodeName name From 262de7f07e080987fdff03a4549fe5d36cc34f2f Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 14:27:41 -0400 Subject: [PATCH 59/71] ++js-test --- test/repos/js-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/repos/js-test b/test/repos/js-test index 7a46849e3..0e185203c 160000 --- a/test/repos/js-test +++ b/test/repos/js-test @@ -1 +1 @@ -Subproject commit 7a46849e3dca65bcb8baf099fb2c59ca151571b0 +Subproject commit 0e185203ca83e51f7fc2dbbb3b251f77b876a270 From 215310fc002b8622c60fb9ac2e00953517f2407b Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 1 Aug 2016 11:46:12 -0400 Subject: [PATCH 60/71] Extract the Operator text using its children's ranges, or with the term's range --- src/DiffSummary.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index dc4da3aa8..9c78a0b38 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -59,17 +59,17 @@ toTermName source term = case unwrap term of S.Switch expr _ -> toTermName' expr S.Ternary expr _ -> toTermName' expr S.MathAssignment id _ -> toTermName' id - S.Operator syntaxes -> mconcat $ toTermName' <$> syntaxes + S.Operator exprs -> termNameFromChildren term exprs S.Object kvs -> "{" <> intercalate ", " (toTermName' <$> kvs) <> "}" S.Pair a b -> toTermName' a <> ": " <> toTermName' b S.Return expr -> maybe "empty" toTermName' expr - S.For exprs _ -> toText $ Source.slice (unionRangesFrom forRange forClauseRanges) source - where forRange = characterRange $ extract term - forClauseRanges = characterRange . extract <$> exprs + S.For exprs _ -> termNameFromChildren term exprs S.While expr _ -> toTermName' expr S.DoWhile _ expr -> toTermName' expr Comment a -> toCategoryName a where toTermName' = toTermName source + termNameFromChildren term cs = toText $ Source.slice (unionRangesFrom (range term) (range <$> cs)) source + range term = (characterRange $ extract term) class HasCategory a where toCategoryName :: a -> Text From 8cb62b67894be74e513c1a89323457f6cb32c80b Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 1 Aug 2016 11:51:45 -0400 Subject: [PATCH 61/71] ++js-test --- test/repos/js-test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/repos/js-test b/test/repos/js-test index 0e185203c..3af143b53 160000 --- a/test/repos/js-test +++ b/test/repos/js-test @@ -1 +1 @@ -Subproject commit 0e185203ca83e51f7fc2dbbb3b251f77b876a270 +Subproject commit 3af143b53c8f9a2a6761d8e9ea91d47982cc3bc0 From 2d0d01f3c4af429ad0373daa29516405d50399f6 Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 1 Aug 2016 11:57:37 -0400 Subject: [PATCH 62/71] Don't create dummy LeafInfos for Operators --- src/DiffSummary.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 9c78a0b38..3886def90 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -207,7 +207,6 @@ termToDiffInfo blob term = case unwrap term of -- Currently we cannot express the operator for an operator production from TreeSitter. Eventually we should be able to -- use the term name of the operator identifier when we have that production value. Until then, I'm using a placeholder value -- to indicate where that value should be when constructing DiffInfos. - S.Operator _ -> LeafInfo (toCategoryName term) "x" Commented cs leaf -> BranchInfo (termToDiffInfo' <$> cs <> maybeToList leaf) (toCategoryName term) BCommented S.Error sourceSpan _ -> ErrorInfo sourceSpan (toCategoryName term) _ -> LeafInfo (toCategoryName term) (toTermName' term) From 005b384fad5c725b6bfc10f43c2b65cd6a8131f8 Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 1 Aug 2016 12:06:51 -0400 Subject: [PATCH 63/71] Extract the term name of an Operator syntax from source --- src/DiffSummary.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 3886def90..8cef888ed 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -59,7 +59,7 @@ toTermName source term = case unwrap term of S.Switch expr _ -> toTermName' expr S.Ternary expr _ -> toTermName' expr S.MathAssignment id _ -> toTermName' id - S.Operator exprs -> termNameFromChildren term exprs + S.Operator _ -> termNameFromSource term S.Object kvs -> "{" <> intercalate ", " (toTermName' <$> kvs) <> "}" S.Pair a b -> toTermName' a <> ": " <> toTermName' b S.Return expr -> maybe "empty" toTermName' expr @@ -68,8 +68,10 @@ toTermName source term = case unwrap term of S.DoWhile _ expr -> toTermName' expr Comment a -> toCategoryName a where toTermName' = toTermName source - termNameFromChildren term cs = toText $ Source.slice (unionRangesFrom (range term) (range <$> cs)) source - range term = (characterRange $ extract term) + termNameFromChildren term cs = termNameFromRange (unionRangesFrom (range term) (range <$> cs)) + termNameFromSource term = termNameFromRange (range term) + termNameFromRange range = toText $ Source.slice range source + range = characterRange . extract class HasCategory a where toCategoryName :: a -> Text From dca3628afde2f4ccd18e54e63624729b0f1ef103 Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 1 Aug 2016 12:07:04 -0400 Subject: [PATCH 64/71] Add comma_op mapping to Operator category in categoriesForLanguage --- src/TreeSitter.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 9727c0f4b..caa74c765 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -31,17 +31,18 @@ treeSitterParser language grammar blob = do categoriesForLanguage :: Language -> Text -> Category categoriesForLanguage language name = case (language, name) of (JavaScript, "object") -> Object - (JavaScript, "rel_op") -> BinaryOperator -- relational operator, e.g. >, <, <=, >=, ==, != - (JavaScript, "bool_op") -> BinaryOperator (JavaScript, "expression_statement") -> ExpressionStatements (JavaScript, "this_expression") -> Identifier (JavaScript, "null") -> Identifier (JavaScript, "undefined") -> Identifier (JavaScript, "arrow_function") -> Function (JavaScript, "generator_function") -> Function + (JavaScript, "rel_op") -> BinaryOperator -- relational operator, e.g. >, <, <=, >=, ==, != + (JavaScript, "bool_op") -> BinaryOperator (JavaScript, "delete_op") -> Operator (JavaScript, "type_op") -> Operator (JavaScript, "void_op") -> Operator + (JavaScript, "comma_op") -> Operator (JavaScript, "for_in_statement") -> For (JavaScript, "for_of_statement") -> For From d216481ca758e215ddac64b86093f809a63e95a0 Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 1 Aug 2016 12:12:35 -0400 Subject: [PATCH 65/71] Map BinaryOperator nodes to Operator syntax --- src/Parser.hs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Parser.hs b/src/Parser.hs index 4f408596e..97082e82d 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -17,13 +17,9 @@ import SourceSpan -- | and aren't pure. type Parser fields = SourceBlob -> IO (Term Text (Record fields)) --- | Categories that are treated as fixed nodes. -fixedCategories :: Set.Set Category -fixedCategories = Set.fromList [ BinaryOperator, Pair ] - --- | Should these categories be treated as fixed nodes? -isFixed :: Category -> Bool -isFixed = flip Set.member fixedCategories +-- | Whether a category is an Operator Category +isOperator :: Category -> Bool +isOperator = flip Set.member (Set.fromList [ Operator, BinaryOperator ]) -- | Given a function that maps production names to sets of categories, produce -- | a Constructor. @@ -49,7 +45,7 @@ termConstructor source sourceSpan info = cofree . construct construct children | SubscriptAccess == category info = case children of (base:element:[]) -> withDefaultInfo $ S.SubscriptAccess base element _ -> withDefaultInfo $ S.Error sourceSpan children - construct children | Operator == category info = withDefaultInfo $ S.Operator children + construct children | isOperator (category info) = withDefaultInfo $ S.Operator children construct children | Function == category info = case children of (body:[]) -> withDefaultInfo $ S.Function Nothing Nothing body (params:body:[]) | (info :< _) <- runCofree params, Params == category info -> @@ -92,7 +88,7 @@ termConstructor source sourceSpan info = cofree . construct toTuple child | S.Leaf c <- unwrap child = [cofree (extract child :< S.Comment c)] toTuple child = pure child - construct children | isFixed (category info) = withDefaultInfo $ S.Fixed children + construct children | Pair == (category info) = withDefaultInfo $ S.Fixed children construct children | C.Error == category info = withDefaultInfo $ S.Error sourceSpan children construct children | For == (category info), Just (exprs, body) <- unsnoc children = From 7c1e6677a84eaac52a9921eba6078644a41cafe9 Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 1 Aug 2016 12:19:05 -0400 Subject: [PATCH 66/71] Add math_op --- src/TreeSitter.hs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index caa74c765..70ec80ed8 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -37,12 +37,14 @@ categoriesForLanguage language name = case (language, name) of (JavaScript, "undefined") -> Identifier (JavaScript, "arrow_function") -> Function (JavaScript, "generator_function") -> Function - (JavaScript, "rel_op") -> BinaryOperator -- relational operator, e.g. >, <, <=, >=, ==, != - (JavaScript, "bool_op") -> BinaryOperator - (JavaScript, "delete_op") -> Operator - (JavaScript, "type_op") -> Operator - (JavaScript, "void_op") -> Operator - (JavaScript, "comma_op") -> Operator + (JavaScript, "math_op") -> BinaryOperator -- bitwise operator, e.g. +, -, *, /. + (JavaScript, "bool_op") -> BinaryOperator -- boolean operator, e.g. ||, &&. + (JavaScript, "bitwise_op") -> BinaryOperator -- bitwise operator, e.g. ^, &, etc. + (JavaScript, "rel_op") -> BinaryOperator -- relational operator, e.g. >, <, <=, >=, ==, !=. + (JavaScript, "comma_op") -> Operator -- comma operator, e.g. expr1, expr2. + (JavaScript, "delete_op") -> Operator -- delete operator, e.g. delete x[2]. + (JavaScript, "type_op") -> Operator -- type operator, e.g. typeof Object. + (JavaScript, "void_op") -> Operator -- void operator, e.g. void 2. (JavaScript, "for_in_statement") -> For (JavaScript, "for_of_statement") -> For From 58b2391ed829e533c16bbf36c9ddc75a486f2a93 Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 1 Aug 2016 12:22:16 -0400 Subject: [PATCH 67/71] ++js-test ++tree-sitter-parsers --- test/repos/js-test | 2 +- vendor/tree-sitter-parsers | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/repos/js-test b/test/repos/js-test index 4a6e3d1a2..3af143b53 160000 --- a/test/repos/js-test +++ b/test/repos/js-test @@ -1 +1 @@ -Subproject commit 4a6e3d1a2b50d2ea285ef6f8681216bdb3442e94 +Subproject commit 3af143b53c8f9a2a6761d8e9ea91d47982cc3bc0 diff --git a/vendor/tree-sitter-parsers b/vendor/tree-sitter-parsers index 0fdcbafdb..b32d12c13 160000 --- a/vendor/tree-sitter-parsers +++ b/vendor/tree-sitter-parsers @@ -1 +1 @@ -Subproject commit 0fdcbafdb69853a03db28e789bb00a2f733c6990 +Subproject commit b32d12c13da744d1b0edc2901988f5e29eae2e49 From 2ab3602532d7b38864416a61a493b7c8ac38f2fe Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 1 Aug 2016 12:22:58 -0400 Subject: [PATCH 68/71] ++js-test ++tree-sitter-parsers --- test/repos/js-test | 2 +- vendor/tree-sitter-parsers | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/repos/js-test b/test/repos/js-test index 1c6b3eede..3af143b53 160000 --- a/test/repos/js-test +++ b/test/repos/js-test @@ -1 +1 @@ -Subproject commit 1c6b3eedec733198c32d097860fca556174e9a3d +Subproject commit 3af143b53c8f9a2a6761d8e9ea91d47982cc3bc0 diff --git a/vendor/tree-sitter-parsers b/vendor/tree-sitter-parsers index 0fdcbafdb..b32d12c13 160000 --- a/vendor/tree-sitter-parsers +++ b/vendor/tree-sitter-parsers @@ -1 +1 @@ -Subproject commit 0fdcbafdb69853a03db28e789bb00a2f733c6990 +Subproject commit b32d12c13da744d1b0edc2901988f5e29eae2e49 From ce149af0f683a26c24003528c8d7bc4760bd40d8 Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 1 Aug 2016 12:23:15 -0400 Subject: [PATCH 69/71] ++js-test ++tree-sitter-parsers --- test/repos/js-test | 2 +- vendor/tree-sitter-parsers | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/repos/js-test b/test/repos/js-test index 7a46849e3..3af143b53 160000 --- a/test/repos/js-test +++ b/test/repos/js-test @@ -1 +1 @@ -Subproject commit 7a46849e3dca65bcb8baf099fb2c59ca151571b0 +Subproject commit 3af143b53c8f9a2a6761d8e9ea91d47982cc3bc0 diff --git a/vendor/tree-sitter-parsers b/vendor/tree-sitter-parsers index 1229ed83d..b32d12c13 160000 --- a/vendor/tree-sitter-parsers +++ b/vendor/tree-sitter-parsers @@ -1 +1 @@ -Subproject commit 1229ed83d0501dc3dbca9d4ceab70702763c76bb +Subproject commit b32d12c13da744d1b0edc2901988f5e29eae2e49 From 446f01c5a2a2a21ed640ba5281771bffcb9b43e2 Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 1 Aug 2016 12:23:51 -0400 Subject: [PATCH 70/71] ++js-test ++tree-sitter-parsers --- test/repos/js-test | 2 +- vendor/tree-sitter-parsers | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/repos/js-test b/test/repos/js-test index 0e185203c..3af143b53 160000 --- a/test/repos/js-test +++ b/test/repos/js-test @@ -1 +1 @@ -Subproject commit 0e185203ca83e51f7fc2dbbb3b251f77b876a270 +Subproject commit 3af143b53c8f9a2a6761d8e9ea91d47982cc3bc0 diff --git a/vendor/tree-sitter-parsers b/vendor/tree-sitter-parsers index 1229ed83d..b32d12c13 160000 --- a/vendor/tree-sitter-parsers +++ b/vendor/tree-sitter-parsers @@ -1 +1 @@ -Subproject commit 1229ed83d0501dc3dbca9d4ceab70702763c76bb +Subproject commit b32d12c13da744d1b0edc2901988f5e29eae2e49 From 862b554e52b8cad9b54c63e194f8ec536f4c4995 Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 1 Aug 2016 13:32:59 -0400 Subject: [PATCH 71/71] Missed a merge conflict --- src/DiffSummary.hs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 7ede08f97..efcb7a7c9 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -193,12 +193,9 @@ diffSummaries sources = cata $ \case (Free (infos :< S.For exprs body)) -> annotateWithCategory infos <$> join exprs <> body (Free (infos :< S.While expr body)) -> annotateWithCategory infos <$> expr <> body (Free (infos :< S.DoWhile expr body)) -> annotateWithCategory infos <$> expr <> body -<<<<<<< HEAD (Free (infos :< S.Array children)) -> annotateWithCategory infos <$> join children -======= (Free (infos :< S.Class identifier superclass definitions)) -> annotateWithCategory infos <$> identifier <> fromMaybe [] superclass <> join definitions (Free (infos :< S.Method identifier params definitions)) -> annotateWithCategory infos <$> identifier <> join params <> join definitions ->>>>>>> origin/master (Pure (Insert term)) -> [ DiffSummary (Insert $ termToDiffInfo afterSource term) [] ] (Pure (Delete term)) -> [ DiffSummary (Delete $ termToDiffInfo beforeSource term) [] ] (Pure (Replace t1 t2)) -> [ DiffSummary (Replace (termToDiffInfo beforeSource t1) (termToDiffInfo afterSource t2)) [] ]