From ebda2e69002e4fb941c18eafeabfbd4dff652bdc Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:31:04 -0400 Subject: [PATCH 01/14] Remove redundant import --- src/TreeSitter.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 9727c0f4b..811db5dda 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 2dbe0eca0ab99ca3415cc00f1a374d479e3d8920 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:31:11 -0400 Subject: [PATCH 02/14] Add Throw to Syntax --- src/Syntax.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Syntax.hs b/src/Syntax.hs index d06897412..e0a76d99f 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) + | Throw f deriving (Eq, Foldable, Functor, Generic, Generic1, Mergeable, Ord, Show, Traversable) From 36aee3a87b00e76e12047206374f0e7aad19a694 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:32:54 -0400 Subject: [PATCH 03/14] Add Throw category --- src/Category.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Category.hs b/src/Category.hs index 24f31d4c2..e6de322a8 100644 --- a/src/Category.hs +++ b/src/Category.hs @@ -77,6 +77,8 @@ data Category | Object -- | A return statement. | Return + -- | A throw statement. + | Throw -- | A non-standard category, which can be used for comparability. | Other Text deriving (Eq, Generic, Ord, Show) From e9a02c219d71c9ea0ce3389c01e04f11c786fe5b Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:33:02 -0400 Subject: [PATCH 04/14] Add Throw to termConstructor --- src/Parser.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Parser.hs b/src/Parser.hs index 4f408596e..54a4a7e4f 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -95,11 +95,13 @@ termConstructor source sourceSpan info = cofree . construct construct children | isFixed (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 = + construct children | For == category info, Just (exprs, body) <- unsnoc children = withDefaultInfo $ S.For exprs body - construct children | While == (category info), [expr, body] <- children = + construct children | While == category info, [expr, body] <- children = withDefaultInfo $ S.While expr body - construct children | DoWhile == (category info), [expr, body] <- children = + construct children | DoWhile == category info, [expr, body] <- children = withDefaultInfo $ S.DoWhile expr body + construct children | Throw == category info, [expr] <- children = + withDefaultInfo $ S.Throw expr construct children = withDefaultInfo $ S.Indexed children From b97da37c79d2b09a26ac7b9159ac1efb284bf7db Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:33:15 -0400 Subject: [PATCH 05/14] Add Throw to defaultCategoryForNodeName --- src/TreeSitter.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/TreeSitter.hs b/src/TreeSitter.hs index 811db5dda..7d14d539a 100644 --- a/src/TreeSitter.hs +++ b/src/TreeSitter.hs @@ -81,6 +81,7 @@ defaultCategoryForNodeName name = case name of "while_statement" -> While "do_statement" -> DoWhile "return_statement" -> Return + "throw_statement" -> Throw _ -> Other name -- | Return a parser for a tree sitter language & document. From 14c9f3f7a6ab9f8086d63e7fe1ac1d3457064f9c Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:33:51 -0400 Subject: [PATCH 06/14] Add Throw 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..5ba639749 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.Throw c -> [ "throwExpression" .= c ] where childrenFields c = [ "children" .= c ] patchFields :: (KeyValue kv, HasField fields Category, HasField fields Range) => SplitPatch (Term leaf (Record fields)) -> [kv] From c70273b899b4035a8ff379fb8482745ebb48d1d6 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:34:15 -0400 Subject: [PATCH 07/14] Add Throw to Split --- src/Renderer/Split.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Renderer/Split.hs b/src/Renderer/Split.hs index 0d1f117c3..8c88719c9 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.Throw -> "throw_statement" Other string -> string -- | Pick the class name for a split patch. From ef3c89dc4858aac5244f31aab28fcceae4b2a126 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:35:28 -0400 Subject: [PATCH 08/14] Add Throw to DiffSummary --- src/DiffSummary.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index dc4da3aa8..a3b807790 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.Throw expr -> toTermName' expr Comment a -> toCategoryName a where toTermName' = toTermName source @@ -114,6 +115,7 @@ instance HasCategory Category where C.DoWhile -> "do/while statement" C.Object -> "object" C.Return -> "return statement" + C.Throw -> "throw statement" instance (HasCategory leaf, HasField fields Category) => HasCategory (Term leaf (Record fields)) where toCategoryName = toCategoryName . category . extract @@ -186,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.Throw 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 a3d9a69f65cad5bd0a8337b43bdb78b92618d6fa Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:37:05 -0400 Subject: [PATCH 09/14] Remove redundant Range --- src/Renderer/JSON.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Renderer/JSON.hs b/src/Renderer/JSON.hs index 5ba639749..84039592a 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 From c6754c9cdc0820a839ccfa6bc30fcc1c002721d9 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:40:23 -0400 Subject: [PATCH 10/14] Extract child text for Throw diff summaries --- src/DiffSummary.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index a3b807790..e34433814 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -68,7 +68,7 @@ toTermName source term = case unwrap term of forClauseRanges = characterRange . extract <$> exprs S.While expr _ -> toTermName' expr S.DoWhile _ expr -> toTermName' expr - S.Throw expr -> toTermName' expr + S.Throw expr -> toText $ Source.slice (characterRange $ extract expr) source Comment a -> toCategoryName a where toTermName' = toTermName source From e577ff3b28d36708bff46b84e368c50176dae364 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 15:40:30 -0400 Subject: [PATCH 11/14] ++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 b07a02d102f017ec80db4fcd6a67951b7fe690ff Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 29 Jul 2016 16:14:38 -0400 Subject: [PATCH 12/14] ++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 6ecff059f9e33caf905317188f161a624d1d2c55 Mon Sep 17 00:00:00 2001 From: joshvera Date: Sat, 30 Jul 2016 22:41:02 -0400 Subject: [PATCH 13/14] ++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..0e185203c 160000 --- a/test/repos/js-test +++ b/test/repos/js-test @@ -1 +1 @@ -Subproject commit 4a6e3d1a2b50d2ea285ef6f8681216bdb3442e94 +Subproject commit 0e185203ca83e51f7fc2dbbb3b251f77b876a270 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 02573a483e6e11d83fcfbc8ab11cb72a20c94d9e Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 1 Aug 2016 12:21:31 -0400 Subject: [PATCH 14/14] ++tree-sitter-parsers ++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