From d4ac4427d32c7f4f0e284126d4fc3063ec922f7c Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 11 Oct 2016 12:02:52 -0500 Subject: [PATCH 01/16] Add comment --- src/Syntax.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Syntax.hs b/src/Syntax.hs index fa1cc5f97..30ce08ba6 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -71,6 +71,7 @@ data Syntax a f | Class f (Maybe f) [f] -- | A method definition with an identifier, params, and a list of expressions. | Method f [f] [f] + -- | An if statement with an expression, a clause, and maybe more expressions, clauses. | If f f (Maybe f) -- | A module with an identifier, and a list of syntaxes. | Module { moduleId:: f, moduleBody :: [f] } From 76bba89d3c2f2ff65d8feb743008f7341b9f4e4f Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 12 Oct 2016 09:39:48 -0500 Subject: [PATCH 02/16] WIP updates --- src/DiffSummary.hs | 7 +++++-- test/corpus/repos/javascript | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index e3cf92630..e7dd288fe 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -58,7 +58,7 @@ data DiffInfo = LeafInfo { categoryName :: Text, termName :: Text } | ErrorInfo { errorSpan :: SourceSpan, termName :: Text } deriving (Eq, Show) -data Branch = BIndexed | BFixed | BCommented deriving (Show, Eq, Generic) +data Branch = BIndexed | BFixed | BCommented | BIf deriving (Show, Eq, Generic) data DiffSummary a = DiffSummary { patch :: Patch a, @@ -173,7 +173,9 @@ toTermName source term = case unwrap term of S.Pair a _ -> toTermName' a <> ": …" S.Return expr -> maybe "empty" toTermName' expr S.Error _ _ -> termNameFromSource term - S.If expr _ _ -> termNameFromSource expr +-- S.If expr _ _ -> termNameFromSource expr + S.If expr _ Nothing -> termNameFromSource expr + S.If expr _ (Just expr') -> termNameFromSource expr S.For clauses _ -> termNameFromChildren term clauses S.While expr _ -> toTermName' expr S.DoWhile _ expr -> toTermName' expr @@ -221,6 +223,7 @@ termToDiffInfo blob term = case unwrap term of S.AnonymousFunction _ _ -> LeafInfo "anonymous function" (toTermName' term) Commented cs leaf -> BranchInfo (termToDiffInfo' <$> cs <> maybeToList leaf) (toCategoryName term) BCommented S.Error sourceSpan _ -> ErrorInfo sourceSpan (toTermName' term) + -- S.If expr _ (Just expr') -> BranchInfo [(termToDiffInfo' expr), (termToDiffInfo' expr')] (toCategoryName term) BIf _ -> LeafInfo (toCategoryName term) (toTermName' term) where toTermName' = toTermName blob termToDiffInfo' = termToDiffInfo blob diff --git a/test/corpus/repos/javascript b/test/corpus/repos/javascript index 7e9421a0f..dce5b472e 160000 --- a/test/corpus/repos/javascript +++ b/test/corpus/repos/javascript @@ -1 +1 @@ -Subproject commit 7e9421a0f261a2de196d05d153a86dc4c8340351 +Subproject commit dce5b472e5bcc43861e65b412644c7931f12d313 From ddb39bdbcc4b9853004d0163990c80cf7b2f5d52 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 12 Oct 2016 12:32:55 -0500 Subject: [PATCH 03/16] Update If Syntax to use a list to represent else conditions - This lets us use a simple structure to break apart nested else-ifs --- src/Syntax.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Syntax.hs b/src/Syntax.hs index aa986fd32..3baf604f6 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -71,7 +71,7 @@ data Syntax a f -- | A method definition with an identifier, params, and a list of expressions. | Method f [f] [f] -- | An if statement with an expression, a clause, and maybe more expressions, clauses. - | If f f (Maybe f) + | If f f [f] -- | A module with an identifier, and a list of syntaxes. | Module { moduleId:: f, moduleBody :: [f] } | Import f [f] From a9d28f95c1c9ef11194f85396a3153d634fe9734 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 12 Oct 2016 12:35:20 -0500 Subject: [PATCH 04/16] Break apart else clauses for If syntax nodes - This is an intermediate step and not complete. We currently only handle one level of else-if, rather than arbitrary levels of else-if. --- src/Language/JavaScript.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Language/JavaScript.hs b/src/Language/JavaScript.hs index 0f3c7e9a9..0d7207523 100644 --- a/src/Language/JavaScript.hs +++ b/src/Language/JavaScript.hs @@ -49,8 +49,10 @@ termConstructor source sourceSpan name range children ("case", [ expr, body ]) -> S.Case expr body ("object", _) -> S.Object $ foldMap toTuple children ("pair", _) -> S.Fixed children - ("if_statement", [ expr, clause1, clause2 ]) -> S.If expr clause1 (Just clause2) - ("if_statement", [ expr, clause ]) -> S.If expr clause Nothing + ("if_statement", [ expr, thenClause, elseClause ]) -> case unwrap elseClause of + S.If{} -> S.If expr thenClause [(toElseIf elseClause)] + _ -> S.If expr thenClause [elseClause] + ("if_statement", [ expr, thenClause ]) -> S.If expr thenClause [] ("while_statement", [ expr, body ]) -> S.While expr body ("do_statement", [ expr, body ]) -> S.DoWhile expr body ("throw_statement", [ expr ]) -> S.Throw expr @@ -156,6 +158,9 @@ categoryForJavaScriptProductionName name = case name of toVarDecl :: (HasField fields Category) => Term (S.Syntax Text) (Record fields) -> Term (S.Syntax Text) (Record fields) toVarDecl child = cofree $ setCategory (extract child) VarDecl :< S.VarDecl child +toElseIf :: (HasField fields Category) => Term (S.Syntax Text) (Record fields) -> Term (S.Syntax Text) (Record fields) +toElseIf child = cofree $ setCategory (extract child) If :< S.If child child [] + toTuple :: Term (S.Syntax Text) (Record fields) -> [Term (S.Syntax Text) (Record fields)] toTuple child | S.Indexed [key,value] <- unwrap child = [cofree (extract child :< S.Pair key value)] toTuple child | S.Fixed [key,value] <- unwrap child = [cofree (extract child :< S.Pair key value)] From e4ac39547b2e360e193f0983e01710555e811adf Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 12 Oct 2016 12:38:21 -0500 Subject: [PATCH 05/16] Construct BranchInfo for If nodes containing else-if clauses - If a If node does not contain else-if clauses, we fall through and construct LeafInfos --- src/DiffSummary.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index ce721d75a..a1dbb5209 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -195,9 +195,7 @@ toTermName source term = case unwrap term of S.Pair a _ -> toTermName' a <> ": …" S.Return expr -> maybe "empty" toTermName' expr S.Error _ -> termNameFromSource term --- S.If expr _ _ -> termNameFromSource expr - S.If expr _ Nothing -> termNameFromSource expr - S.If expr _ (Just expr') -> termNameFromSource expr + S.If expr _ _ -> termNameFromSource expr S.For clauses _ -> termNameFromChildren term clauses S.While expr _ -> toTermName' expr S.DoWhile _ expr -> toTermName' expr @@ -244,6 +242,7 @@ termToDiffInfo blob term = case unwrap term of S.Fixed children -> BranchInfo (termToDiffInfo' <$> children) (toCategoryName term) BFixed S.AnonymousFunction _ _ -> LeafInfo "anonymous function" (toTermName' term) (getField $ extract term) Commented cs leaf -> BranchInfo (termToDiffInfo' <$> cs <> maybeToList leaf) (toCategoryName term) BCommented + S.If expr _ elseIfs -> BranchInfo ([LeafInfo (toCategoryName term) (toTermName' expr) (getField $ extract term)] ++ (termToDiffInfo' <$> elseIfs)) (toCategoryName term) BIf S.Error _ -> ErrorInfo (getField $ extract term) (toTermName' term) -- S.If expr _ (Just expr') -> BranchInfo [(termToDiffInfo' expr), (termToDiffInfo' expr')] (toCategoryName term) BIf _ -> LeafInfo (toCategoryName term) (toTermName' term) (getField $ extract term) From d12a8d8e1b49cc8b79c84b822b8b87454bdd37ca Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 12 Oct 2016 14:55:25 -0500 Subject: [PATCH 06/16] Recursively construct If Syntaxes for nested If Terms - Also adds Data.List (head) --- src/Language/JavaScript.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Language/JavaScript.hs b/src/Language/JavaScript.hs index 0d7207523..43f53dc9d 100644 --- a/src/Language/JavaScript.hs +++ b/src/Language/JavaScript.hs @@ -3,10 +3,11 @@ module Language.JavaScript where import Data.Record import Info -import Prologue +import Prologue hiding (head) import Source import qualified Syntax as S import Term +import Data.List (head) operators :: [Text] operators = [ "op", "bool_op", "math_op", "delete_op", "type_op", "void_op", "rel_op", "bitwise_op" ] @@ -159,7 +160,12 @@ toVarDecl :: (HasField fields Category) => Term (S.Syntax Text) (Record fields) toVarDecl child = cofree $ setCategory (extract child) VarDecl :< S.VarDecl child toElseIf :: (HasField fields Category) => Term (S.Syntax Text) (Record fields) -> Term (S.Syntax Text) (Record fields) -toElseIf child = cofree $ setCategory (extract child) If :< S.If child child [] +toElseIf child = case unwrap child of + S.If expr thenClause [] -> cofree $ setCategory (extract child) If :< S.If expr thenClause [] + S.If expr thenClause elseClause -> case unwrap . head $ elseClause of + S.If{} -> cofree $ setCategory (extract child) If :< S.If expr thenClause (toElseIf <$> elseClause) + _ -> cofree $ setCategory (extract child) If :< S.If expr thenClause [] + _ -> cofree $ setCategory (extract child) If :< S.If child child [] toTuple :: Term (S.Syntax Text) (Record fields) -> [Term (S.Syntax Text) (Record fields)] toTuple child | S.Indexed [key,value] <- unwrap child = [cofree (extract child :< S.Pair key value)] From 17e29de931c400a8cc9e54d33be7d5bcfaa4da9a Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 12 Oct 2016 14:55:34 -0500 Subject: [PATCH 07/16] :memo: --- src/Language/JavaScript.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Language/JavaScript.hs b/src/Language/JavaScript.hs index 43f53dc9d..efab5d765 100644 --- a/src/Language/JavaScript.hs +++ b/src/Language/JavaScript.hs @@ -159,12 +159,19 @@ categoryForJavaScriptProductionName name = case name of toVarDecl :: (HasField fields Category) => Term (S.Syntax Text) (Record fields) -> Term (S.Syntax Text) (Record fields) toVarDecl child = cofree $ setCategory (extract child) VarDecl :< S.VarDecl child +-- | Convert a If Term to If Syntax. This handles nested else-if clauses recursively, +-- | and satisfies arbitrarily long else-if clauses. toElseIf :: (HasField fields Category) => Term (S.Syntax Text) (Record fields) -> Term (S.Syntax Text) (Record fields) toElseIf child = case unwrap child of + -- Base case, this stops the recursive toElseIf calls. S.If expr thenClause [] -> cofree $ setCategory (extract child) If :< S.If expr thenClause [] + -- For each If term, determine if the else clause contains another If term. + -- For each nested If term, recursively construct If Syntaxes until the else clause + -- is empty, or the else clause is not a nested If term. S.If expr thenClause elseClause -> case unwrap . head $ elseClause of S.If{} -> cofree $ setCategory (extract child) If :< S.If expr thenClause (toElseIf <$> elseClause) _ -> cofree $ setCategory (extract child) If :< S.If expr thenClause [] + -- This is bottom, to satisfy exhuastive pattern matching. _ -> cofree $ setCategory (extract child) If :< S.If child child [] toTuple :: Term (S.Syntax Text) (Record fields) -> [Term (S.Syntax Text) (Record fields)] From d222090c37f45f3061d797a9ea38cbd2294f9de7 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 12 Oct 2016 14:55:59 -0500 Subject: [PATCH 08/16] Update if-else.json tests --- .../diff-summaries/javascript/if-else.json | 838 +++++++++++++++++- test/corpus/generated/javascript.json | 4 +- test/corpus/repos/javascript | 2 +- 3 files changed, 797 insertions(+), 47 deletions(-) diff --git a/test/corpus/diff-summaries/javascript/if-else.json b/test/corpus/diff-summaries/javascript/if-else.json index fa28d3b31..ec710a054 100644 --- a/test/corpus/diff-summaries/javascript/if-else.json +++ b/test/corpus/diff-summaries/javascript/if-else.json @@ -11,12 +11,57 @@ 1 ], "end": [ - 1, - 25 + 2, + 1 ] } }, "summary": "Added the 'x' if statement" + }, + { + "span": { + "insert": { + "start": [ + 1, + 16 + ], + "end": [ + 2, + 1 + ] + } + }, + "summary": "Added the 'a' if statement" + }, + { + "span": { + "insert": { + "start": [ + 1, + 31 + ], + "end": [ + 2, + 1 + ] + } + }, + "summary": "Added the 'c' if statement" + }, + { + "span": { + "insert": { + "start": [ + 1, + 46 + ], + "end": [ + 2, + 1 + ] + } + }, + "summary": "Added the 'e' if statement" } ] }, @@ -25,9 +70,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "177b3db7ca070dc750876553a0cd7fde8b5df54c", + "sha1": "ce33777b1fadcab50214296b9a9207ef9d901987", "gitDir": "test/corpus/repos/javascript", - "sha2": "fd499e58d749df1da475f0d6033825f265734210" + "sha2": "840236a7547f74664f3418e52d71af8012b24460" } ,{ "testCaseDescription": "javascript-if-else-replacement-insert-test", @@ -42,8 +87,83 @@ 1 ], "end": [ + 2, + 1 + ] + } + }, + "summary": "Added the 'g' if statement" + }, + { + "span": { + "insert": { + "start": [ 1, - 29 + 16 + ], + "end": [ + 2, + 1 + ] + } + }, + "summary": "Added the 'i' if statement" + }, + { + "span": { + "insert": { + "start": [ + 1, + 35 + ], + "end": [ + 2, + 1 + ] + } + }, + "summary": "Added the 'k' if statement" + }, + { + "span": { + "insert": { + "start": [ + 1, + 50 + ], + "end": [ + 2, + 1 + ] + } + }, + "summary": "Added the 'm' if statement" + }, + { + "span": { + "insert": { + "start": [ + 2, + 1 + ], + "end": [ + 3, + 1 + ] + } + }, + "summary": "Added the 'x' if statement" + }, + { + "span": { + "insert": { + "start": [ + 2, + 16 + ], + "end": [ + 3, + 1 ] } }, @@ -54,15 +174,30 @@ "insert": { "start": [ 2, - 1 + 31 ], "end": [ - 2, - 25 + 3, + 1 ] } }, - "summary": "Added the 'x' if statement" + "summary": "Added the 'c' if statement" + }, + { + "span": { + "insert": { + "start": [ + 2, + 46 + ], + "end": [ + 3, + 1 + ] + } + }, + "summary": "Added the 'e' if statement" } ] }, @@ -71,9 +206,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "fd499e58d749df1da475f0d6033825f265734210", + "sha1": "840236a7547f74664f3418e52d71af8012b24460", "gitDir": "test/corpus/repos/javascript", - "sha2": "1f6c19a2b78ca415ac6e06f69c051ba6c23a250e" + "sha2": "189ebb6708f47ab75e37645b2b751199241c907c" } ,{ "testCaseDescription": "javascript-if-else-delete-insert-test", @@ -86,26 +221,221 @@ { "start": [ 1, - 1 + 5 ], "end": [ 1, - 29 + 6 ] }, { "start": [ 1, - 1 + 5 ], "end": [ 1, - 25 + 6 ] } ] }, - "summary": "Replaced the 'a' if statement with the 'x' if statement" + "summary": "Replaced the 'g' identifier with the 'x' identifier" + }, + { + "span": { + "replace": [ + { + "start": [ + 1, + 8 + ], + "end": [ + 1, + 9 + ] + }, + { + "start": [ + 1, + 8 + ], + "end": [ + 1, + 9 + ] + } + ] + }, + "summary": "Replaced the 'h' identifier with the 'y' identifier" + }, + { + "span": { + "replace": [ + { + "start": [ + 1, + 20 + ], + "end": [ + 1, + 21 + ] + }, + { + "start": [ + 1, + 20 + ], + "end": [ + 1, + 21 + ] + } + ] + }, + "summary": "Replaced the 'i' identifier with the 'a' identifier" + }, + { + "span": { + "insert": { + "start": [ + 1, + 23 + ], + "end": [ + 1, + 24 + ] + } + }, + "summary": "Added the 'b' identifier" + }, + { + "span": { + "delete": { + "start": [ + 1, + 25 + ], + "end": [ + 1, + 26 + ] + } + }, + "summary": "Deleted the 'j' identifier" + }, + { + "span": { + "replace": [ + { + "start": [ + 1, + 39 + ], + "end": [ + 1, + 40 + ] + }, + { + "start": [ + 1, + 35 + ], + "end": [ + 1, + 36 + ] + } + ] + }, + "summary": "Replaced the 'k' identifier with the 'c' identifier" + }, + { + "span": { + "replace": [ + { + "start": [ + 1, + 42 + ], + "end": [ + 1, + 43 + ] + }, + { + "start": [ + 1, + 38 + ], + "end": [ + 1, + 39 + ] + } + ] + }, + "summary": "Replaced the 'l' identifier with the 'd' identifier" + }, + { + "span": { + "replace": [ + { + "start": [ + 1, + 54 + ], + "end": [ + 1, + 55 + ] + }, + { + "start": [ + 1, + 50 + ], + "end": [ + 1, + 51 + ] + } + ] + }, + "summary": "Replaced the 'm' identifier with the 'e' identifier" + }, + { + "span": { + "insert": { + "start": [ + 1, + 53 + ], + "end": [ + 1, + 54 + ] + } + }, + "summary": "Added the 'f' identifier" + }, + { + "span": { + "delete": { + "start": [ + 1, + 59 + ], + "end": [ + 1, + 60 + ] + } + }, + "summary": "Deleted the 'n' identifier" } ] }, @@ -114,9 +444,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "1f6c19a2b78ca415ac6e06f69c051ba6c23a250e", + "sha1": "189ebb6708f47ab75e37645b2b751199241c907c", "gitDir": "test/corpus/repos/javascript", - "sha2": "946c2d3269de0a2f284a9922b8da111323729827" + "sha2": "9ff856699be8300fc54028028dd8984ec9dbe985" } ,{ "testCaseDescription": "javascript-if-else-replacement-test", @@ -129,26 +459,221 @@ { "start": [ 1, - 1 + 5 ], "end": [ 1, - 25 + 6 ] }, { "start": [ 1, - 1 + 5 ], "end": [ 1, - 29 + 6 ] } ] }, - "summary": "Replaced the 'x' if statement with the 'a' if statement" + "summary": "Replaced the 'x' identifier with the 'g' identifier" + }, + { + "span": { + "replace": [ + { + "start": [ + 1, + 8 + ], + "end": [ + 1, + 9 + ] + }, + { + "start": [ + 1, + 8 + ], + "end": [ + 1, + 9 + ] + } + ] + }, + "summary": "Replaced the 'y' identifier with the 'h' identifier" + }, + { + "span": { + "replace": [ + { + "start": [ + 1, + 20 + ], + "end": [ + 1, + 21 + ] + }, + { + "start": [ + 1, + 20 + ], + "end": [ + 1, + 21 + ] + } + ] + }, + "summary": "Replaced the 'a' identifier with the 'i' identifier" + }, + { + "span": { + "insert": { + "start": [ + 1, + 25 + ], + "end": [ + 1, + 26 + ] + } + }, + "summary": "Added the 'j' identifier" + }, + { + "span": { + "delete": { + "start": [ + 1, + 23 + ], + "end": [ + 1, + 24 + ] + } + }, + "summary": "Deleted the 'b' identifier" + }, + { + "span": { + "replace": [ + { + "start": [ + 1, + 35 + ], + "end": [ + 1, + 36 + ] + }, + { + "start": [ + 1, + 39 + ], + "end": [ + 1, + 40 + ] + } + ] + }, + "summary": "Replaced the 'c' identifier with the 'k' identifier" + }, + { + "span": { + "replace": [ + { + "start": [ + 1, + 38 + ], + "end": [ + 1, + 39 + ] + }, + { + "start": [ + 1, + 42 + ], + "end": [ + 1, + 43 + ] + } + ] + }, + "summary": "Replaced the 'd' identifier with the 'l' identifier" + }, + { + "span": { + "replace": [ + { + "start": [ + 1, + 50 + ], + "end": [ + 1, + 51 + ] + }, + { + "start": [ + 1, + 54 + ], + "end": [ + 1, + 55 + ] + } + ] + }, + "summary": "Replaced the 'e' identifier with the 'm' identifier" + }, + { + "span": { + "insert": { + "start": [ + 1, + 59 + ], + "end": [ + 1, + 60 + ] + } + }, + "summary": "Added the 'n' identifier" + }, + { + "span": { + "delete": { + "start": [ + 1, + 53 + ], + "end": [ + 1, + 54 + ] + } + }, + "summary": "Deleted the 'f' identifier" } ] }, @@ -157,9 +682,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "946c2d3269de0a2f284a9922b8da111323729827", + "sha1": "9ff856699be8300fc54028028dd8984ec9dbe985", "gitDir": "test/corpus/repos/javascript", - "sha2": "71792b4ff0291e41c9e3ec3157abfea9cd67daa7" + "sha2": "0a9be6ebc48c3d58a76a5bb95043b9c0d02307b3" } ,{ "testCaseDescription": "javascript-if-else-delete-replacement-test", @@ -174,8 +699,83 @@ 1 ], "end": [ + 2, + 1 + ] + } + }, + "summary": "Deleted the 'g' if statement" + }, + { + "span": { + "delete": { + "start": [ 1, - 29 + 16 + ], + "end": [ + 2, + 1 + ] + } + }, + "summary": "Deleted the 'i' if statement" + }, + { + "span": { + "delete": { + "start": [ + 1, + 35 + ], + "end": [ + 2, + 1 + ] + } + }, + "summary": "Deleted the 'k' if statement" + }, + { + "span": { + "delete": { + "start": [ + 1, + 50 + ], + "end": [ + 2, + 1 + ] + } + }, + "summary": "Deleted the 'm' if statement" + }, + { + "span": { + "delete": { + "start": [ + 2, + 1 + ], + "end": [ + 3, + 1 + ] + } + }, + "summary": "Deleted the 'x' if statement" + }, + { + "span": { + "delete": { + "start": [ + 2, + 16 + ], + "end": [ + 3, + 1 ] } }, @@ -186,15 +786,30 @@ "delete": { "start": [ 2, - 1 + 31 ], "end": [ - 2, - 25 + 3, + 1 ] } }, - "summary": "Deleted the 'x' if statement" + "summary": "Deleted the 'c' if statement" + }, + { + "span": { + "delete": { + "start": [ + 2, + 46 + ], + "end": [ + 3, + 1 + ] + } + }, + "summary": "Deleted the 'e' if statement" }, { "span": { @@ -204,12 +819,57 @@ 1 ], "end": [ - 2, - 29 + 3, + 1 ] } }, - "summary": "Added the 'a' if statement" + "summary": "Added the 'g' if statement" + }, + { + "span": { + "insert": { + "start": [ + 2, + 16 + ], + "end": [ + 3, + 1 + ] + } + }, + "summary": "Added the 'i' if statement" + }, + { + "span": { + "insert": { + "start": [ + 2, + 35 + ], + "end": [ + 3, + 1 + ] + } + }, + "summary": "Added the 'k' if statement" + }, + { + "span": { + "insert": { + "start": [ + 2, + 50 + ], + "end": [ + 3, + 1 + ] + } + }, + "summary": "Added the 'm' if statement" } ] }, @@ -218,9 +878,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "71792b4ff0291e41c9e3ec3157abfea9cd67daa7", + "sha1": "0a9be6ebc48c3d58a76a5bb95043b9c0d02307b3", "gitDir": "test/corpus/repos/javascript", - "sha2": "95edd1d597a111bbe508c047a0f75d0342b35cea" + "sha2": "f6f6cc50166c8003c2d4c4b164d0bd54860ac4b1" } ,{ "testCaseDescription": "javascript-if-else-delete-test", @@ -235,12 +895,57 @@ 1 ], "end": [ - 1, - 25 + 2, + 1 ] } }, "summary": "Deleted the 'x' if statement" + }, + { + "span": { + "delete": { + "start": [ + 1, + 16 + ], + "end": [ + 2, + 1 + ] + } + }, + "summary": "Deleted the 'a' if statement" + }, + { + "span": { + "delete": { + "start": [ + 1, + 31 + ], + "end": [ + 2, + 1 + ] + } + }, + "summary": "Deleted the 'c' if statement" + }, + { + "span": { + "delete": { + "start": [ + 1, + 46 + ], + "end": [ + 2, + 1 + ] + } + }, + "summary": "Deleted the 'e' if statement" } ] }, @@ -249,9 +954,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "95edd1d597a111bbe508c047a0f75d0342b35cea", + "sha1": "f6f6cc50166c8003c2d4c4b164d0bd54860ac4b1", "gitDir": "test/corpus/repos/javascript", - "sha2": "58fd81ed8b29ab258997ccdcb2a0602e64748fc8" + "sha2": "685c144290a73c4cc3a884b027020ece337e977e" } ,{ "testCaseDescription": "javascript-if-else-delete-rest-test", @@ -266,12 +971,57 @@ 1 ], "end": [ - 1, - 29 + 2, + 1 ] } }, - "summary": "Deleted the 'a' if statement" + "summary": "Deleted the 'g' if statement" + }, + { + "span": { + "delete": { + "start": [ + 1, + 16 + ], + "end": [ + 2, + 1 + ] + } + }, + "summary": "Deleted the 'i' if statement" + }, + { + "span": { + "delete": { + "start": [ + 1, + 35 + ], + "end": [ + 2, + 1 + ] + } + }, + "summary": "Deleted the 'k' if statement" + }, + { + "span": { + "delete": { + "start": [ + 1, + 50 + ], + "end": [ + 2, + 1 + ] + } + }, + "summary": "Deleted the 'm' if statement" } ] }, @@ -280,7 +1030,7 @@ "filePaths": [ "if-else.js" ], - "sha1": "58fd81ed8b29ab258997ccdcb2a0602e64748fc8", + "sha1": "685c144290a73c4cc3a884b027020ece337e977e", "gitDir": "test/corpus/repos/javascript", - "sha2": "73e8a48299a8c408fadbf83077ab1e56ea81b5b0" + "sha2": "fff6323d021499933be7ea2e85391d2d8bb9a65a" }] diff --git a/test/corpus/generated/javascript.json b/test/corpus/generated/javascript.json index b52646b51..be4b4d739 100644 --- a/test/corpus/generated/javascript.json +++ b/test/corpus/generated/javascript.json @@ -385,8 +385,8 @@ { "syntax": "if-else", "repoFilePath": "if-else.js", - "insert": "if (x) y; else if (a) b;", - "replacement": "if (a) { c; d; } else { e; }", + "insert": "if (x) y; else if (a) b; else if (c) d; else if (e) f; else g", + "replacement": "if (g) h; else if (i) { j; } else if (k) l; else if (m) { n; } else o", "testCaseFilePath": "test/corpus/diff-summaries/javascript/if-else.json" }, { diff --git a/test/corpus/repos/javascript b/test/corpus/repos/javascript index dce5b472e..fff6323d0 160000 --- a/test/corpus/repos/javascript +++ b/test/corpus/repos/javascript @@ -1 +1 @@ -Subproject commit dce5b472e5bcc43861e65b412644c7931f12d313 +Subproject commit fff6323d021499933be7ea2e85391d2d8bb9a65a From 1234f5dbc337ce60cfb01e00f61b6c83dc44ea09 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 12 Oct 2016 14:59:58 -0500 Subject: [PATCH 09/16] ++javascript tests --- .../diff-summaries/javascript/if-else.json | 28 +++++++++---------- test/corpus/repos/javascript | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test/corpus/diff-summaries/javascript/if-else.json b/test/corpus/diff-summaries/javascript/if-else.json index ec710a054..a0f63f7cb 100644 --- a/test/corpus/diff-summaries/javascript/if-else.json +++ b/test/corpus/diff-summaries/javascript/if-else.json @@ -70,9 +70,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "ce33777b1fadcab50214296b9a9207ef9d901987", + "sha1": "fff6323d021499933be7ea2e85391d2d8bb9a65a", "gitDir": "test/corpus/repos/javascript", - "sha2": "840236a7547f74664f3418e52d71af8012b24460" + "sha2": "93de851722b5e93b2834dfa599e90148d2397e57" } ,{ "testCaseDescription": "javascript-if-else-replacement-insert-test", @@ -206,9 +206,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "840236a7547f74664f3418e52d71af8012b24460", + "sha1": "93de851722b5e93b2834dfa599e90148d2397e57", "gitDir": "test/corpus/repos/javascript", - "sha2": "189ebb6708f47ab75e37645b2b751199241c907c" + "sha2": "008c01d9f651d4927ed8fd6e4715ed7fc4aa4e11" } ,{ "testCaseDescription": "javascript-if-else-delete-insert-test", @@ -444,9 +444,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "189ebb6708f47ab75e37645b2b751199241c907c", + "sha1": "008c01d9f651d4927ed8fd6e4715ed7fc4aa4e11", "gitDir": "test/corpus/repos/javascript", - "sha2": "9ff856699be8300fc54028028dd8984ec9dbe985" + "sha2": "0d08ea7dcaa25c97baf823149bd4a6cd7278f286" } ,{ "testCaseDescription": "javascript-if-else-replacement-test", @@ -682,9 +682,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "9ff856699be8300fc54028028dd8984ec9dbe985", + "sha1": "0d08ea7dcaa25c97baf823149bd4a6cd7278f286", "gitDir": "test/corpus/repos/javascript", - "sha2": "0a9be6ebc48c3d58a76a5bb95043b9c0d02307b3" + "sha2": "ce82032008af2ba3f4fbdb1660a5ff7559d833f6" } ,{ "testCaseDescription": "javascript-if-else-delete-replacement-test", @@ -878,9 +878,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "0a9be6ebc48c3d58a76a5bb95043b9c0d02307b3", + "sha1": "ce82032008af2ba3f4fbdb1660a5ff7559d833f6", "gitDir": "test/corpus/repos/javascript", - "sha2": "f6f6cc50166c8003c2d4c4b164d0bd54860ac4b1" + "sha2": "14dd7a551904082078df077f2be64632f828edc0" } ,{ "testCaseDescription": "javascript-if-else-delete-test", @@ -954,9 +954,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "f6f6cc50166c8003c2d4c4b164d0bd54860ac4b1", + "sha1": "14dd7a551904082078df077f2be64632f828edc0", "gitDir": "test/corpus/repos/javascript", - "sha2": "685c144290a73c4cc3a884b027020ece337e977e" + "sha2": "79b0c2bdef22996d3626e285fc4e078c03bbaa86" } ,{ "testCaseDescription": "javascript-if-else-delete-rest-test", @@ -1030,7 +1030,7 @@ "filePaths": [ "if-else.js" ], - "sha1": "685c144290a73c4cc3a884b027020ece337e977e", + "sha1": "79b0c2bdef22996d3626e285fc4e078c03bbaa86", "gitDir": "test/corpus/repos/javascript", - "sha2": "fff6323d021499933be7ea2e85391d2d8bb9a65a" + "sha2": "3903cb97b8c7fe507a17fa52ec09e6eaa1e95ad8" }] diff --git a/test/corpus/repos/javascript b/test/corpus/repos/javascript index fff6323d0..3903cb97b 160000 --- a/test/corpus/repos/javascript +++ b/test/corpus/repos/javascript @@ -1 +1 @@ -Subproject commit fff6323d021499933be7ea2e85391d2d8bb9a65a +Subproject commit 3903cb97b8c7fe507a17fa52ec09e6eaa1e95ad8 From 6894bdcd55fbba1d94d738624a016c6bf55aa4cb Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 12 Oct 2016 15:34:46 -0500 Subject: [PATCH 10/16] <> over ++ --- src/DiffSummary.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index a1dbb5209..28a37c280 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -242,7 +242,7 @@ termToDiffInfo blob term = case unwrap term of S.Fixed children -> BranchInfo (termToDiffInfo' <$> children) (toCategoryName term) BFixed S.AnonymousFunction _ _ -> LeafInfo "anonymous function" (toTermName' term) (getField $ extract term) Commented cs leaf -> BranchInfo (termToDiffInfo' <$> cs <> maybeToList leaf) (toCategoryName term) BCommented - S.If expr _ elseIfs -> BranchInfo ([LeafInfo (toCategoryName term) (toTermName' expr) (getField $ extract term)] ++ (termToDiffInfo' <$> elseIfs)) (toCategoryName term) BIf + S.If expr _ elseIfs -> BranchInfo ([LeafInfo (toCategoryName term) (toTermName' expr) (getField $ extract term)] <> (termToDiffInfo' <$> elseIfs)) (toCategoryName term) BIf S.Error _ -> ErrorInfo (getField $ extract term) (toTermName' term) -- S.If expr _ (Just expr') -> BranchInfo [(termToDiffInfo' expr), (termToDiffInfo' expr')] (toCategoryName term) BIf _ -> LeafInfo (toCategoryName term) (toTermName' term) (getField $ extract term) From e3f672674cb76fdbc12227cbe375db14e1305b8b Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 12 Oct 2016 15:35:09 -0500 Subject: [PATCH 11/16] Remove previous idea --- src/DiffSummary.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 28a37c280..270f6c323 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -244,7 +244,6 @@ termToDiffInfo blob term = case unwrap term of Commented cs leaf -> BranchInfo (termToDiffInfo' <$> cs <> maybeToList leaf) (toCategoryName term) BCommented S.If expr _ elseIfs -> BranchInfo ([LeafInfo (toCategoryName term) (toTermName' expr) (getField $ extract term)] <> (termToDiffInfo' <$> elseIfs)) (toCategoryName term) BIf S.Error _ -> ErrorInfo (getField $ extract term) (toTermName' term) - -- S.If expr _ (Just expr') -> BranchInfo [(termToDiffInfo' expr), (termToDiffInfo' expr')] (toCategoryName term) BIf _ -> LeafInfo (toCategoryName term) (toTermName' term) (getField $ extract term) where toTermName' = toTermName blob termToDiffInfo' = termToDiffInfo blob From 62db2939f8492f1a152383e9e525e86e9473c7b7 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Thu, 13 Oct 2016 12:34:48 -0500 Subject: [PATCH 12/16] Clean and retain elseClause for If statements that are not If statements --- src/Language/JavaScript.hs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Language/JavaScript.hs b/src/Language/JavaScript.hs index efab5d765..9859b127f 100644 --- a/src/Language/JavaScript.hs +++ b/src/Language/JavaScript.hs @@ -163,16 +163,8 @@ toVarDecl child = cofree $ setCategory (extract child) VarDecl :< S.VarDecl chil -- | and satisfies arbitrarily long else-if clauses. toElseIf :: (HasField fields Category) => Term (S.Syntax Text) (Record fields) -> Term (S.Syntax Text) (Record fields) toElseIf child = case unwrap child of - -- Base case, this stops the recursive toElseIf calls. - S.If expr thenClause [] -> cofree $ setCategory (extract child) If :< S.If expr thenClause [] - -- For each If term, determine if the else clause contains another If term. - -- For each nested If term, recursively construct If Syntaxes until the else clause - -- is empty, or the else clause is not a nested If term. - S.If expr thenClause elseClause -> case unwrap . head $ elseClause of - S.If{} -> cofree $ setCategory (extract child) If :< S.If expr thenClause (toElseIf <$> elseClause) - _ -> cofree $ setCategory (extract child) If :< S.If expr thenClause [] - -- This is bottom, to satisfy exhuastive pattern matching. - _ -> cofree $ setCategory (extract child) If :< S.If child child [] + S.If expr thenClause elseClause -> cofree $ setCategory (extract child) If :< S.If expr thenClause (toElseIf <$> elseClause) + _ -> child toTuple :: Term (S.Syntax Text) (Record fields) -> [Term (S.Syntax Text) (Record fields)] toTuple child | S.Indexed [key,value] <- unwrap child = [cofree (extract child :< S.Pair key value)] From a80cb67b899feb58c4caff3fbb04eb6f3f9364fd Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Thu, 13 Oct 2016 12:36:18 -0500 Subject: [PATCH 13/16] Extract toLeafInfo function --- src/DiffSummary.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 270f6c323..c06104742 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -242,11 +242,12 @@ termToDiffInfo blob term = case unwrap term of S.Fixed children -> BranchInfo (termToDiffInfo' <$> children) (toCategoryName term) BFixed S.AnonymousFunction _ _ -> LeafInfo "anonymous function" (toTermName' term) (getField $ extract term) Commented cs leaf -> BranchInfo (termToDiffInfo' <$> cs <> maybeToList leaf) (toCategoryName term) BCommented - S.If expr _ elseIfs -> BranchInfo ([LeafInfo (toCategoryName term) (toTermName' expr) (getField $ extract term)] <> (termToDiffInfo' <$> elseIfs)) (toCategoryName term) BIf + S.If _ _ elseIfs -> BranchInfo ([toLeafInfo term] <> (termToDiffInfo' <$> elseIfs)) (toCategoryName term) BIf S.Error _ -> ErrorInfo (getField $ extract term) (toTermName' term) - _ -> LeafInfo (toCategoryName term) (toTermName' term) (getField $ extract term) + _ -> toLeafInfo term where toTermName' = toTermName blob termToDiffInfo' = termToDiffInfo blob + toLeafInfo term = LeafInfo (toCategoryName term) (toTermName' term) (getField $ extract term) -- | Append a parentAnnotation to the current DiffSummary instance. -- | For a DiffSummary without a parentAnnotation, we append a parentAnnotation with the first identifiable term. From 59a2531889526520fe03176c03a393f67469a8a6 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Thu, 13 Oct 2016 16:33:57 -0500 Subject: [PATCH 14/16] Update toElseIf so we don't drop the elseClause for non If syntax clauses --- src/Language/JavaScript.hs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Language/JavaScript.hs b/src/Language/JavaScript.hs index 9859b127f..8c01b03b1 100644 --- a/src/Language/JavaScript.hs +++ b/src/Language/JavaScript.hs @@ -3,11 +3,10 @@ module Language.JavaScript where import Data.Record import Info -import Prologue hiding (head) +import Prologue import Source import qualified Syntax as S import Term -import Data.List (head) operators :: [Text] operators = [ "op", "bool_op", "math_op", "delete_op", "type_op", "void_op", "rel_op", "bitwise_op" ] @@ -50,9 +49,7 @@ termConstructor source sourceSpan name range children ("case", [ expr, body ]) -> S.Case expr body ("object", _) -> S.Object $ foldMap toTuple children ("pair", _) -> S.Fixed children - ("if_statement", [ expr, thenClause, elseClause ]) -> case unwrap elseClause of - S.If{} -> S.If expr thenClause [(toElseIf elseClause)] - _ -> S.If expr thenClause [elseClause] + ("if_statement", [ expr, thenClause, elseClause ]) -> toElseIf expr thenClause elseClause ("if_statement", [ expr, thenClause ]) -> S.If expr thenClause [] ("while_statement", [ expr, body ]) -> S.While expr body ("do_statement", [ expr, body ]) -> S.DoWhile expr body @@ -161,10 +158,16 @@ toVarDecl child = cofree $ setCategory (extract child) VarDecl :< S.VarDecl chil -- | Convert a If Term to If Syntax. This handles nested else-if clauses recursively, -- | and satisfies arbitrarily long else-if clauses. -toElseIf :: (HasField fields Category) => Term (S.Syntax Text) (Record fields) -> Term (S.Syntax Text) (Record fields) -toElseIf child = case unwrap child of - S.If expr thenClause elseClause -> cofree $ setCategory (extract child) If :< S.If expr thenClause (toElseIf <$> elseClause) - _ -> child +toElseIf :: Term (S.Syntax Text) (Record fields) + -> Term (S.Syntax Text) (Record fields) + -> Term (S.Syntax Text) (Record fields) + -> S.Syntax Text (Term (S.Syntax Text) (Record fields)) +toElseIf expr thenClause elseClause = S.If expr thenClause (elseClause' elseClause) + where + elseClause' term = case unwrap term of + S.If _ _ [] -> [ term ] + S.If then' else' children -> [ cofree (extract term :< S.If then' else' []) ] <> (elseClause' =<< children) + _ -> [ term ] toTuple :: Term (S.Syntax Text) (Record fields) -> [Term (S.Syntax Text) (Record fields)] toTuple child | S.Indexed [key,value] <- unwrap child = [cofree (extract child :< S.Pair key value)] From 5cc26fcc342856a33239ab6eb751a6c62f4e81b7 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Thu, 13 Oct 2016 16:42:49 -0500 Subject: [PATCH 15/16] Remove BranchInfo for If Syntaxes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Although this allowed us to report a list of summary statements for each if / else-if condition, we don’t append parent contexts to Patches. Because we lose that parent context, it makes replacement summary statements devoid of context. Taking a step back, @joshvera and I decided to leave if summary statements as they are now, but revisit this when we explore rollups. Although diff summary statements do not include else-if clauses now in Syntax If accurately. So we have the info, but as it stands, a long list of summary statements for each else-if clause we determined to be less helpful, but will set us up for success when we add rollups. --- src/DiffSummary.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index c06104742..2e1b54742 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -242,7 +242,6 @@ termToDiffInfo blob term = case unwrap term of S.Fixed children -> BranchInfo (termToDiffInfo' <$> children) (toCategoryName term) BFixed S.AnonymousFunction _ _ -> LeafInfo "anonymous function" (toTermName' term) (getField $ extract term) Commented cs leaf -> BranchInfo (termToDiffInfo' <$> cs <> maybeToList leaf) (toCategoryName term) BCommented - S.If _ _ elseIfs -> BranchInfo ([toLeafInfo term] <> (termToDiffInfo' <$> elseIfs)) (toCategoryName term) BIf S.Error _ -> ErrorInfo (getField $ extract term) (toTermName' term) _ -> toLeafInfo term where toTermName' = toTermName blob From 80ebddae5ce92af4fa8953f8abd0685d02743be1 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Thu, 13 Oct 2016 16:44:36 -0500 Subject: [PATCH 16/16] Bump tests --- .../diff-summaries/javascript/if-else.json | 442 +++--------------- test/corpus/repos/javascript | 2 +- 2 files changed, 69 insertions(+), 375 deletions(-) diff --git a/test/corpus/diff-summaries/javascript/if-else.json b/test/corpus/diff-summaries/javascript/if-else.json index a0f63f7cb..40a3cd790 100644 --- a/test/corpus/diff-summaries/javascript/if-else.json +++ b/test/corpus/diff-summaries/javascript/if-else.json @@ -17,51 +17,6 @@ } }, "summary": "Added the 'x' if statement" - }, - { - "span": { - "insert": { - "start": [ - 1, - 16 - ], - "end": [ - 2, - 1 - ] - } - }, - "summary": "Added the 'a' if statement" - }, - { - "span": { - "insert": { - "start": [ - 1, - 31 - ], - "end": [ - 2, - 1 - ] - } - }, - "summary": "Added the 'c' if statement" - }, - { - "span": { - "insert": { - "start": [ - 1, - 46 - ], - "end": [ - 2, - 1 - ] - } - }, - "summary": "Added the 'e' if statement" } ] }, @@ -70,9 +25,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "fff6323d021499933be7ea2e85391d2d8bb9a65a", + "sha1": "3903cb97b8c7fe507a17fa52ec09e6eaa1e95ad8", "gitDir": "test/corpus/repos/javascript", - "sha2": "93de851722b5e93b2834dfa599e90148d2397e57" + "sha2": "182d895f1ed34f6ea3f5e01ebec34f3872486ae2" } ,{ "testCaseDescription": "javascript-if-else-replacement-insert-test", @@ -94,51 +49,6 @@ }, "summary": "Added the 'g' if statement" }, - { - "span": { - "insert": { - "start": [ - 1, - 16 - ], - "end": [ - 2, - 1 - ] - } - }, - "summary": "Added the 'i' if statement" - }, - { - "span": { - "insert": { - "start": [ - 1, - 35 - ], - "end": [ - 2, - 1 - ] - } - }, - "summary": "Added the 'k' if statement" - }, - { - "span": { - "insert": { - "start": [ - 1, - 50 - ], - "end": [ - 2, - 1 - ] - } - }, - "summary": "Added the 'm' if statement" - }, { "span": { "insert": { @@ -153,51 +63,6 @@ } }, "summary": "Added the 'x' if statement" - }, - { - "span": { - "insert": { - "start": [ - 2, - 16 - ], - "end": [ - 3, - 1 - ] - } - }, - "summary": "Added the 'a' if statement" - }, - { - "span": { - "insert": { - "start": [ - 2, - 31 - ], - "end": [ - 3, - 1 - ] - } - }, - "summary": "Added the 'c' if statement" - }, - { - "span": { - "insert": { - "start": [ - 2, - 46 - ], - "end": [ - 3, - 1 - ] - } - }, - "summary": "Added the 'e' if statement" } ] }, @@ -206,9 +71,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "93de851722b5e93b2834dfa599e90148d2397e57", + "sha1": "182d895f1ed34f6ea3f5e01ebec34f3872486ae2", "gitDir": "test/corpus/repos/javascript", - "sha2": "008c01d9f651d4927ed8fd6e4715ed7fc4aa4e11" + "sha2": "b27dbe99809ec3a3cff8c1bdac1829a7ec7f3a2a" } ,{ "testCaseDescription": "javascript-if-else-delete-insert-test", @@ -436,6 +301,33 @@ } }, "summary": "Deleted the 'n' identifier" + }, + { + "span": { + "replace": [ + { + "start": [ + 1, + 69 + ], + "end": [ + 1, + 70 + ] + }, + { + "start": [ + 1, + 61 + ], + "end": [ + 1, + 62 + ] + } + ] + }, + "summary": "Replaced the 'o' identifier with the 'g' identifier" } ] }, @@ -444,9 +336,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "008c01d9f651d4927ed8fd6e4715ed7fc4aa4e11", + "sha1": "b27dbe99809ec3a3cff8c1bdac1829a7ec7f3a2a", "gitDir": "test/corpus/repos/javascript", - "sha2": "0d08ea7dcaa25c97baf823149bd4a6cd7278f286" + "sha2": "2713de071b224835fcb35bf709342334422c4fb7" } ,{ "testCaseDescription": "javascript-if-else-replacement-test", @@ -674,6 +566,33 @@ } }, "summary": "Deleted the 'f' identifier" + }, + { + "span": { + "replace": [ + { + "start": [ + 1, + 61 + ], + "end": [ + 1, + 62 + ] + }, + { + "start": [ + 1, + 69 + ], + "end": [ + 1, + 70 + ] + } + ] + }, + "summary": "Replaced the 'g' identifier with the 'o' identifier" } ] }, @@ -682,9 +601,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "0d08ea7dcaa25c97baf823149bd4a6cd7278f286", + "sha1": "2713de071b224835fcb35bf709342334422c4fb7", "gitDir": "test/corpus/repos/javascript", - "sha2": "ce82032008af2ba3f4fbdb1660a5ff7559d833f6" + "sha2": "acdc250e3e92d45007edc022e7a46bd7c8870264" } ,{ "testCaseDescription": "javascript-if-else-delete-replacement-test", @@ -706,51 +625,6 @@ }, "summary": "Deleted the 'g' if statement" }, - { - "span": { - "delete": { - "start": [ - 1, - 16 - ], - "end": [ - 2, - 1 - ] - } - }, - "summary": "Deleted the 'i' if statement" - }, - { - "span": { - "delete": { - "start": [ - 1, - 35 - ], - "end": [ - 2, - 1 - ] - } - }, - "summary": "Deleted the 'k' if statement" - }, - { - "span": { - "delete": { - "start": [ - 1, - 50 - ], - "end": [ - 2, - 1 - ] - } - }, - "summary": "Deleted the 'm' if statement" - }, { "span": { "delete": { @@ -766,51 +640,6 @@ }, "summary": "Deleted the 'x' if statement" }, - { - "span": { - "delete": { - "start": [ - 2, - 16 - ], - "end": [ - 3, - 1 - ] - } - }, - "summary": "Deleted the 'a' if statement" - }, - { - "span": { - "delete": { - "start": [ - 2, - 31 - ], - "end": [ - 3, - 1 - ] - } - }, - "summary": "Deleted the 'c' if statement" - }, - { - "span": { - "delete": { - "start": [ - 2, - 46 - ], - "end": [ - 3, - 1 - ] - } - }, - "summary": "Deleted the 'e' if statement" - }, { "span": { "insert": { @@ -825,51 +654,6 @@ } }, "summary": "Added the 'g' if statement" - }, - { - "span": { - "insert": { - "start": [ - 2, - 16 - ], - "end": [ - 3, - 1 - ] - } - }, - "summary": "Added the 'i' if statement" - }, - { - "span": { - "insert": { - "start": [ - 2, - 35 - ], - "end": [ - 3, - 1 - ] - } - }, - "summary": "Added the 'k' if statement" - }, - { - "span": { - "insert": { - "start": [ - 2, - 50 - ], - "end": [ - 3, - 1 - ] - } - }, - "summary": "Added the 'm' if statement" } ] }, @@ -878,9 +662,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "ce82032008af2ba3f4fbdb1660a5ff7559d833f6", + "sha1": "acdc250e3e92d45007edc022e7a46bd7c8870264", "gitDir": "test/corpus/repos/javascript", - "sha2": "14dd7a551904082078df077f2be64632f828edc0" + "sha2": "c05504705f6307d70ec027ce0da03266c41b4333" } ,{ "testCaseDescription": "javascript-if-else-delete-test", @@ -901,51 +685,6 @@ } }, "summary": "Deleted the 'x' if statement" - }, - { - "span": { - "delete": { - "start": [ - 1, - 16 - ], - "end": [ - 2, - 1 - ] - } - }, - "summary": "Deleted the 'a' if statement" - }, - { - "span": { - "delete": { - "start": [ - 1, - 31 - ], - "end": [ - 2, - 1 - ] - } - }, - "summary": "Deleted the 'c' if statement" - }, - { - "span": { - "delete": { - "start": [ - 1, - 46 - ], - "end": [ - 2, - 1 - ] - } - }, - "summary": "Deleted the 'e' if statement" } ] }, @@ -954,9 +693,9 @@ "filePaths": [ "if-else.js" ], - "sha1": "14dd7a551904082078df077f2be64632f828edc0", + "sha1": "c05504705f6307d70ec027ce0da03266c41b4333", "gitDir": "test/corpus/repos/javascript", - "sha2": "79b0c2bdef22996d3626e285fc4e078c03bbaa86" + "sha2": "dbba6da8532f1191731609e596468ea525643576" } ,{ "testCaseDescription": "javascript-if-else-delete-rest-test", @@ -977,51 +716,6 @@ } }, "summary": "Deleted the 'g' if statement" - }, - { - "span": { - "delete": { - "start": [ - 1, - 16 - ], - "end": [ - 2, - 1 - ] - } - }, - "summary": "Deleted the 'i' if statement" - }, - { - "span": { - "delete": { - "start": [ - 1, - 35 - ], - "end": [ - 2, - 1 - ] - } - }, - "summary": "Deleted the 'k' if statement" - }, - { - "span": { - "delete": { - "start": [ - 1, - 50 - ], - "end": [ - 2, - 1 - ] - } - }, - "summary": "Deleted the 'm' if statement" } ] }, @@ -1030,7 +724,7 @@ "filePaths": [ "if-else.js" ], - "sha1": "79b0c2bdef22996d3626e285fc4e078c03bbaa86", + "sha1": "dbba6da8532f1191731609e596468ea525643576", "gitDir": "test/corpus/repos/javascript", - "sha2": "3903cb97b8c7fe507a17fa52ec09e6eaa1e95ad8" + "sha2": "4c75eac553b89390d3a122886e4797b7e470dc3f" }] diff --git a/test/corpus/repos/javascript b/test/corpus/repos/javascript index 3903cb97b..0fcaa2c97 160000 --- a/test/corpus/repos/javascript +++ b/test/corpus/repos/javascript @@ -1 +1 @@ -Subproject commit 3903cb97b8c7fe507a17fa52ec09e6eaa1e95ad8 +Subproject commit 0fcaa2c972c37d8b90d03e71ec04376f26c8ef22