diff --git a/src/DiffSummary.hs b/src/DiffSummary.hs index 7f2cc40f2..e91eb7ce9 100644 --- a/src/DiffSummary.hs +++ b/src/DiffSummary.hs @@ -54,6 +54,7 @@ identifiable term = isIdentifiable (unwrap term) term S.Import{} -> Identifiable S.Export{} -> Identifiable S.Begin{} -> Identifiable + S.Else{} -> Identifiable _ -> Unidentifiable data JSONSummary summary span = JSONSummary { summary :: summary, span :: span } @@ -251,6 +252,7 @@ parentContexts contexts = hsep $ either identifiableDoc annotatableDoc <$> conte where identifiableDoc (c, t) = case c of C.Assignment -> "in an" <+> catName c <+> "to" <+> termName t + C.Else -> "in an" <+> catName c C.Begin -> "in a" <+> catName c _ -> "in the" <+> catName c annotatableDoc (c, t) = "of the" <+> squotes (termName t) <+> catName c diff --git a/test/corpus/diff-summaries/ruby/case-statement.json b/test/corpus/diff-summaries/ruby/case-statement.json index 387520ef8..a81e62b38 100644 --- a/test/corpus/diff-summaries/ruby/case-statement.json +++ b/test/corpus/diff-summaries/ruby/case-statement.json @@ -25,9 +25,9 @@ "filePaths": [ "case-statement.rb" ], - "sha1": "bb70f837f1c22fd8e973e46a7e6cb497139d97c4", + "sha1": "c6074d2900bc75792281ccca5e4cf1385ffd61f4", "gitDir": "test/corpus/repos/ruby", - "sha2": "f6ca35d6d4560531067b97ba9e68a3815579254a" + "sha2": "3288ef6a638a3a2757505d9b23d4c44abe33c29b" } ,{ "testCaseDescription": "ruby-case-statement-replacement-insert-test", @@ -71,9 +71,9 @@ "filePaths": [ "case-statement.rb" ], - "sha1": "f6ca35d6d4560531067b97ba9e68a3815579254a", + "sha1": "3288ef6a638a3a2757505d9b23d4c44abe33c29b", "gitDir": "test/corpus/repos/ruby", - "sha2": "baba4d8eec4f7da5b4e82c7a2e9b3c1a0851aeff" + "sha2": "a676c60cf58f985d18682c713b79b5463851f675" } ,{ "testCaseDescription": "ruby-case-statement-delete-insert-test", @@ -93,7 +93,7 @@ ] } }, - "summary": "Deleted the 'else' expression statements" + "summary": "Deleted an else block" } ] }, @@ -102,9 +102,9 @@ "filePaths": [ "case-statement.rb" ], - "sha1": "baba4d8eec4f7da5b4e82c7a2e9b3c1a0851aeff", + "sha1": "a676c60cf58f985d18682c713b79b5463851f675", "gitDir": "test/corpus/repos/ruby", - "sha2": "bc8508f454d9570d8887f8128a3e9c2e0458c397" + "sha2": "abaca6882e5f28164dfc23d785202e29a2a1579c" } ,{ "testCaseDescription": "ruby-case-statement-replacement-test", @@ -124,7 +124,7 @@ ] } }, - "summary": "Added the 'else' expression statements" + "summary": "Added an else block" } ] }, @@ -133,9 +133,9 @@ "filePaths": [ "case-statement.rb" ], - "sha1": "bc8508f454d9570d8887f8128a3e9c2e0458c397", + "sha1": "abaca6882e5f28164dfc23d785202e29a2a1579c", "gitDir": "test/corpus/repos/ruby", - "sha2": "06f52e9ee228d6a684ae634b7892b0646f3b74f1" + "sha2": "dd16b53bc99dbfbdfd31b99fc6c35674df291fc3" } ,{ "testCaseDescription": "ruby-case-statement-delete-replacement-test", @@ -194,9 +194,9 @@ "filePaths": [ "case-statement.rb" ], - "sha1": "06f52e9ee228d6a684ae634b7892b0646f3b74f1", + "sha1": "dd16b53bc99dbfbdfd31b99fc6c35674df291fc3", "gitDir": "test/corpus/repos/ruby", - "sha2": "b7b65f2b0ba1847953a6e5d1e4bfeb7ec5b00bcd" + "sha2": "f9c9a56769aecf7ff7917fdf5b2c6dc102001af4" } ,{ "testCaseDescription": "ruby-case-statement-delete-test", @@ -225,9 +225,9 @@ "filePaths": [ "case-statement.rb" ], - "sha1": "b7b65f2b0ba1847953a6e5d1e4bfeb7ec5b00bcd", + "sha1": "f9c9a56769aecf7ff7917fdf5b2c6dc102001af4", "gitDir": "test/corpus/repos/ruby", - "sha2": "2e20ab2e4c6cdbe088dd649d369efe5cbabc6570" + "sha2": "bbfee7639ee0c9382aaa6d4fd99aa16004b0d382" } ,{ "testCaseDescription": "ruby-case-statement-delete-rest-test", @@ -256,7 +256,7 @@ "filePaths": [ "case-statement.rb" ], - "sha1": "2e20ab2e4c6cdbe088dd649d369efe5cbabc6570", + "sha1": "bbfee7639ee0c9382aaa6d4fd99aa16004b0d382", "gitDir": "test/corpus/repos/ruby", - "sha2": "9af6525d466cb43bfc5674e74cf68d02b5bea736" + "sha2": "f39262cb00c1a446c3fb7bcb435732e9ab0384a3" }] diff --git a/test/corpus/diff-summaries/ruby/else.json b/test/corpus/diff-summaries/ruby/else.json new file mode 100644 index 000000000..70963d932 --- /dev/null +++ b/test/corpus/diff-summaries/ruby/else.json @@ -0,0 +1,262 @@ +[{ + "testCaseDescription": "ruby-else-insert-test", + "expectedResult": { + "changes": { + "else.rb": [ + { + "span": { + "insert": { + "start": [ + 1, + 1 + ], + "end": [ + 4, + 4 + ] + } + }, + "summary": "Added a begin statement" + } + ] + }, + "errors": {} + }, + "filePaths": [ + "else.rb" + ], + "sha1": "264e8a80aee14d0effd8b560eba0b756fc977f49", + "gitDir": "test/corpus/repos/ruby", + "sha2": "f94104abf315362c00c98ec8983bc10c015f423e" +} +,{ + "testCaseDescription": "ruby-else-replacement-insert-test", + "expectedResult": { + "changes": { + "else.rb": [ + { + "span": { + "insert": { + "start": [ + 1, + 1 + ], + "end": [ + 5, + 4 + ] + } + }, + "summary": "Added a begin statement" + }, + { + "span": { + "insert": { + "start": [ + 6, + 1 + ], + "end": [ + 9, + 4 + ] + } + }, + "summary": "Added a begin statement" + } + ] + }, + "errors": {} + }, + "filePaths": [ + "else.rb" + ], + "sha1": "f94104abf315362c00c98ec8983bc10c015f423e", + "gitDir": "test/corpus/repos/ruby", + "sha2": "416c6e8a826c994180e96da45cfc165a9ad39998" +} +,{ + "testCaseDescription": "ruby-else-delete-insert-test", + "expectedResult": { + "changes": { + "else.rb": [ + { + "span": { + "delete": { + "start": [ + 4, + 3 + ], + "end": [ + 4, + 8 + ] + } + }, + "summary": "Deleted the 'bar()' function call in an else block" + } + ] + }, + "errors": {} + }, + "filePaths": [ + "else.rb" + ], + "sha1": "416c6e8a826c994180e96da45cfc165a9ad39998", + "gitDir": "test/corpus/repos/ruby", + "sha2": "1309e64764df58212ef4e2ae14dd40b6e213ad6e" +} +,{ + "testCaseDescription": "ruby-else-replacement-test", + "expectedResult": { + "changes": { + "else.rb": [ + { + "span": { + "insert": { + "start": [ + 4, + 3 + ], + "end": [ + 4, + 8 + ] + } + }, + "summary": "Added the 'bar()' function call in an else block" + } + ] + }, + "errors": {} + }, + "filePaths": [ + "else.rb" + ], + "sha1": "1309e64764df58212ef4e2ae14dd40b6e213ad6e", + "gitDir": "test/corpus/repos/ruby", + "sha2": "57b4e2e412d9b1fdd7b78db5fadcac2264d0a8f1" +} +,{ + "testCaseDescription": "ruby-else-delete-replacement-test", + "expectedResult": { + "changes": { + "else.rb": [ + { + "span": { + "delete": { + "start": [ + 1, + 1 + ], + "end": [ + 5, + 4 + ] + } + }, + "summary": "Deleted a begin statement" + }, + { + "span": { + "delete": { + "start": [ + 6, + 1 + ], + "end": [ + 9, + 4 + ] + } + }, + "summary": "Deleted a begin statement" + }, + { + "span": { + "insert": { + "start": [ + 5, + 1 + ], + "end": [ + 9, + 4 + ] + } + }, + "summary": "Added a begin statement" + } + ] + }, + "errors": {} + }, + "filePaths": [ + "else.rb" + ], + "sha1": "57b4e2e412d9b1fdd7b78db5fadcac2264d0a8f1", + "gitDir": "test/corpus/repos/ruby", + "sha2": "bdfec68ee7acf98cfa10de9f46bcf3891f030f66" +} +,{ + "testCaseDescription": "ruby-else-delete-test", + "expectedResult": { + "changes": { + "else.rb": [ + { + "span": { + "delete": { + "start": [ + 1, + 1 + ], + "end": [ + 4, + 4 + ] + } + }, + "summary": "Deleted a begin statement" + } + ] + }, + "errors": {} + }, + "filePaths": [ + "else.rb" + ], + "sha1": "bdfec68ee7acf98cfa10de9f46bcf3891f030f66", + "gitDir": "test/corpus/repos/ruby", + "sha2": "24bbe6d5af40f9c36cdb928aeaa925da59b6a498" +} +,{ + "testCaseDescription": "ruby-else-delete-rest-test", + "expectedResult": { + "changes": { + "else.rb": [ + { + "span": { + "delete": { + "start": [ + 1, + 1 + ], + "end": [ + 5, + 4 + ] + } + }, + "summary": "Deleted a begin statement" + } + ] + }, + "errors": {} + }, + "filePaths": [ + "else.rb" + ], + "sha1": "24bbe6d5af40f9c36cdb928aeaa925da59b6a498", + "gitDir": "test/corpus/repos/ruby", + "sha2": "47b6616835e1b178e9cd9191c1259fcfcbb7aab3" +}] diff --git a/test/corpus/diff-summaries/ruby/if.json b/test/corpus/diff-summaries/ruby/if.json index fd1d697b7..8ddba768f 100644 --- a/test/corpus/diff-summaries/ruby/if.json +++ b/test/corpus/diff-summaries/ruby/if.json @@ -25,9 +25,9 @@ "filePaths": [ "if.rb" ], - "sha1": "662fccf89bd39a15900856298a1465bf2a88811f", + "sha1": "47b6616835e1b178e9cd9191c1259fcfcbb7aab3", "gitDir": "test/corpus/repos/ruby", - "sha2": "c1d891b5dde86165cdd9cc56844ed76ad894f596" + "sha2": "eb80253d00eb9a4187c5ece2b00f8977a83f46fb" } ,{ "testCaseDescription": "ruby-if-replacement-insert-test", @@ -86,9 +86,9 @@ "filePaths": [ "if.rb" ], - "sha1": "c1d891b5dde86165cdd9cc56844ed76ad894f596", + "sha1": "eb80253d00eb9a4187c5ece2b00f8977a83f46fb", "gitDir": "test/corpus/repos/ruby", - "sha2": "222f026c2ec101bcff5e740ee130407e63d536d1" + "sha2": "ef60e4a5ed805bef8225af98c89faf70006fa392" } ,{ "testCaseDescription": "ruby-if-delete-insert-test", @@ -183,16 +183,16 @@ "span": { "insert": { "start": [ - 6, - 3 + 5, + 1 ], "end": [ - 6, - 6 + 7, + 1 ] } }, - "summary": "Added the 'bat' identifier" + "summary": "Added an else block" }, { "span": { @@ -216,9 +216,9 @@ "filePaths": [ "if.rb" ], - "sha1": "222f026c2ec101bcff5e740ee130407e63d536d1", + "sha1": "ef60e4a5ed805bef8225af98c89faf70006fa392", "gitDir": "test/corpus/repos/ruby", - "sha2": "bcd03dee391efa42a2ef44976f167e75deacb882" + "sha2": "09b5b42107d0eb08903884b9d68eb610895222f5" } ,{ "testCaseDescription": "ruby-if-replacement-test", @@ -313,16 +313,16 @@ "span": { "delete": { "start": [ - 6, - 3 + 5, + 1 ], "end": [ - 6, - 6 + 7, + 1 ] } }, - "summary": "Deleted the 'bat' identifier" + "summary": "Deleted an else block" }, { "span": { @@ -346,9 +346,9 @@ "filePaths": [ "if.rb" ], - "sha1": "bcd03dee391efa42a2ef44976f167e75deacb882", + "sha1": "09b5b42107d0eb08903884b9d68eb610895222f5", "gitDir": "test/corpus/repos/ruby", - "sha2": "5d074e53ba8f92574242ea397b06b5d1a57894ba" + "sha2": "fc5bf170f600299d00bf2812ba3612cd2bf0778a" } ,{ "testCaseDescription": "ruby-if-delete-replacement-test", @@ -377,9 +377,9 @@ "filePaths": [ "if.rb" ], - "sha1": "5d074e53ba8f92574242ea397b06b5d1a57894ba", + "sha1": "fc5bf170f600299d00bf2812ba3612cd2bf0778a", "gitDir": "test/corpus/repos/ruby", - "sha2": "f0fab5a5cae0117c7262aa1839739da9c153f214" + "sha2": "ceba7b50c2ba6b2493a0b09ae0c2a394a8a3e56b" } ,{ "testCaseDescription": "ruby-if-delete-test", @@ -408,9 +408,9 @@ "filePaths": [ "if.rb" ], - "sha1": "f0fab5a5cae0117c7262aa1839739da9c153f214", + "sha1": "ceba7b50c2ba6b2493a0b09ae0c2a394a8a3e56b", "gitDir": "test/corpus/repos/ruby", - "sha2": "dc09bed9471bfb13127c7899fb02735f4fdfae07" + "sha2": "ffc5bf82a50419a853f01325ef94d5f73927a44c" } ,{ "testCaseDescription": "ruby-if-delete-rest-test", @@ -454,7 +454,7 @@ "filePaths": [ "if.rb" ], - "sha1": "dc09bed9471bfb13127c7899fb02735f4fdfae07", + "sha1": "ffc5bf82a50419a853f01325ef94d5f73927a44c", "gitDir": "test/corpus/repos/ruby", - "sha2": "0e62e928c71f53e67a74423a229b59f2c43c4ff1" + "sha2": "4d1e872d4f7e282f5904bb57c2093a74ccbbebf2" }] diff --git a/test/corpus/diff-summaries/ruby/unless.json b/test/corpus/diff-summaries/ruby/unless.json index 2565b343b..2937f4cd2 100644 --- a/test/corpus/diff-summaries/ruby/unless.json +++ b/test/corpus/diff-summaries/ruby/unless.json @@ -25,9 +25,9 @@ "filePaths": [ "unless.rb" ], - "sha1": "0e62e928c71f53e67a74423a229b59f2c43c4ff1", + "sha1": "4d1e872d4f7e282f5904bb57c2093a74ccbbebf2", "gitDir": "test/corpus/repos/ruby", - "sha2": "54cd53fa306130753ad60013aaac3e08c444eee8" + "sha2": "d27597a1f9e2117a042bc3b3fc30b569f80556fd" } ,{ "testCaseDescription": "ruby-unless-replacement-insert-test", @@ -86,9 +86,9 @@ "filePaths": [ "unless.rb" ], - "sha1": "54cd53fa306130753ad60013aaac3e08c444eee8", + "sha1": "d27597a1f9e2117a042bc3b3fc30b569f80556fd", "gitDir": "test/corpus/repos/ruby", - "sha2": "01cf5c615c3b4fec25a486c16506e5d5548059c5" + "sha2": "4b4401af331c83374b89e5c75800b3674bfaec96" } ,{ "testCaseDescription": "ruby-unless-delete-insert-test", @@ -153,16 +153,16 @@ "span": { "insert": { "start": [ - 4, - 3 + 3, + 1 ], "end": [ - 4, - 6 + 5, + 1 ] } }, - "summary": "Added the 'bat' identifier" + "summary": "Added an else block" }, { "span": { @@ -186,9 +186,9 @@ "filePaths": [ "unless.rb" ], - "sha1": "01cf5c615c3b4fec25a486c16506e5d5548059c5", + "sha1": "4b4401af331c83374b89e5c75800b3674bfaec96", "gitDir": "test/corpus/repos/ruby", - "sha2": "51517b9e75ca318ce36c8871594bf2d90e23ef21" + "sha2": "d8805a48c72674afaed694c37593465218485333" } ,{ "testCaseDescription": "ruby-unless-replacement-test", @@ -253,16 +253,16 @@ "span": { "delete": { "start": [ - 4, - 3 + 3, + 1 ], "end": [ - 4, - 6 + 5, + 1 ] } }, - "summary": "Deleted the 'bat' identifier" + "summary": "Deleted an else block" }, { "span": { @@ -286,9 +286,9 @@ "filePaths": [ "unless.rb" ], - "sha1": "51517b9e75ca318ce36c8871594bf2d90e23ef21", + "sha1": "d8805a48c72674afaed694c37593465218485333", "gitDir": "test/corpus/repos/ruby", - "sha2": "5bd7e958226f61794ac3433ef4c52bb6c7d6e868" + "sha2": "b511bbeae76feabb464f4d2c26b040c69839009a" } ,{ "testCaseDescription": "ruby-unless-delete-replacement-test", @@ -317,9 +317,9 @@ "filePaths": [ "unless.rb" ], - "sha1": "5bd7e958226f61794ac3433ef4c52bb6c7d6e868", + "sha1": "b511bbeae76feabb464f4d2c26b040c69839009a", "gitDir": "test/corpus/repos/ruby", - "sha2": "3d57c40457ac55fbdf650f5bb7b2955d50e866a2" + "sha2": "9661099b4f9b40467e0e2736e04a34ec85b7a742" } ,{ "testCaseDescription": "ruby-unless-delete-test", @@ -348,9 +348,9 @@ "filePaths": [ "unless.rb" ], - "sha1": "3d57c40457ac55fbdf650f5bb7b2955d50e866a2", + "sha1": "9661099b4f9b40467e0e2736e04a34ec85b7a742", "gitDir": "test/corpus/repos/ruby", - "sha2": "8ec66f369586a4af74b230436d5737f54bcefc72" + "sha2": "7bc17f8aa6ab06f14d731175d5c8d5dedaa8ea9b" } ,{ "testCaseDescription": "ruby-unless-delete-rest-test", @@ -394,7 +394,7 @@ "filePaths": [ "unless.rb" ], - "sha1": "8ec66f369586a4af74b230436d5737f54bcefc72", + "sha1": "7bc17f8aa6ab06f14d731175d5c8d5dedaa8ea9b", "gitDir": "test/corpus/repos/ruby", - "sha2": "71b6ea047c38fa803b820d3d5b9bcffe1a7e45c3" + "sha2": "c6074d2900bc75792281ccca5e4cf1385ffd61f4" }] diff --git a/test/corpus/generated/ruby.json b/test/corpus/generated/ruby.json index 3bafa2bbc..aa2bd1dda 100644 --- a/test/corpus/generated/ruby.json +++ b/test/corpus/generated/ruby.json @@ -198,6 +198,11 @@ "syntax": "begin-else", "insert": "begin\n foo()\nend", "replacement": "begin\n foo()\nelse\n bar()\nend" + }, + { + "syntax": "else", + "insert": "begin\n foo()\nelse\nend", + "replacement": "begin\n foo()\nelse\n bar()\nend" } ] } diff --git a/test/corpus/repos/ruby b/test/corpus/repos/ruby index 6592554e5..f39262cb0 160000 --- a/test/corpus/repos/ruby +++ b/test/corpus/repos/ruby @@ -1 +1 @@ -Subproject commit 6592554e576fcb7805c20f575575bcc05f96d450 +Subproject commit f39262cb00c1a446c3fb7bcb435732e9ab0384a3