From 1bde86531e04ac562994282fb235c4f442500d82 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Wed, 8 Feb 2017 08:43:04 -0800 Subject: [PATCH] Fix ordering of go Method shape in termAssignment --- src/Language/Go.hs | 10 +- .../go/method-declarations.json | 128 +++++++++--------- test/corpus/repos/go | 2 +- 3 files changed, 70 insertions(+), 70 deletions(-) diff --git a/src/Language/Go.hs b/src/Language/Go.hs index 462917a98..6929b5a47 100644 --- a/src/Language/Go.hs +++ b/src/Language/Go.hs @@ -68,11 +68,11 @@ termAssignment source category children = case (category, children) of (IncrementStatement, _) -> Just $ S.Leaf (toText source) (DecrementStatement, _) -> Just $ S.Leaf (toText source) (QualifiedIdentifier, _) -> Just $ S.Leaf (toText source) - (Method, [params, name, fun]) -> Just (S.Method name Nothing Nothing (toList (unwrap params)) (toList (unwrap fun))) - (Method, [params, name, outParams, fun]) - -> Just (S.Method name (Just outParams) Nothing (toList (unwrap params)) (toList (unwrap fun))) - (Method, [params, name, outParams, ty, fun]) - -> Just (S.Method name (Just outParams) (Just ty) (toList (unwrap params)) (toList (unwrap fun))) + (Method, [receiverParams, name, body]) -> Just (S.Method name (Just receiverParams) Nothing [] (toList (unwrap body))) + (Method, [receiverParams, name, params, body]) + -> Just (S.Method name (Just receiverParams) Nothing (toList (unwrap params)) (toList (unwrap body))) + (Method, [receiverParams, name, params, ty, body]) + -> Just (S.Method name (Just receiverParams) (Just ty) (toList (unwrap params)) (toList (unwrap body))) _ -> Nothing categoryForGoName :: Text -> Category diff --git a/test/corpus/diff-summaries/go/method-declarations.json b/test/corpus/diff-summaries/go/method-declarations.json index 7018a2bf6..1e40a1ace 100644 --- a/test/corpus/diff-summaries/go/method-declarations.json +++ b/test/corpus/diff-summaries/go/method-declarations.json @@ -53,7 +53,7 @@ "+" ], "gitDir": "test/corpus/repos/go", - "shas": "177fb35939c02b4bc6067142eab57a6cc2237513..2f023a586a3c306c01e1fbf646c7bffc5a6428b3" + "shas": "852d29d2b9a695875dd0e15454330bbf7c5e49ff..8dbfd03f829f633e03994c029050d4c04facf13a" } ,{ "testCaseDescription": "go-method-declarations-insert-test", @@ -73,7 +73,7 @@ ] } }, - "summary": "Added the '(other Person).Equals(…)' method" + "summary": "Added the '(self Person).Equals(…)' method" } ] }, @@ -95,40 +95,13 @@ "+func (self Person) Equals(other Person) bool {}" ], "gitDir": "test/corpus/repos/go", - "shas": "2f023a586a3c306c01e1fbf646c7bffc5a6428b3..d79d8d6400fbf0ee98ec1c1de105b35653bc6abf" + "shas": "8dbfd03f829f633e03994c029050d4c04facf13a..0c19c3d818bc2c0bac5168d3e77f4e54e382a2d3" } ,{ "testCaseDescription": "go-method-declarations-replacement-test", "expectedResult": { "changes": { "method-declarations.go": [ - { - "span": { - "replace": [ - { - "start": [ - 5, - 33 - ], - "end": [ - 5, - 39 - ] - }, - { - "start": [ - 5, - 30 - ], - "end": [ - 5, - 33 - ] - } - ] - }, - "summary": "Replaced the 'Person' identifier with the 'Num' identifier in the '(other Num).Equals(…)' method" - }, { "span": { "replace": [ @@ -154,7 +127,34 @@ } ] }, - "summary": "Replaced the 'Person' identifier with the 'Num' identifier in the '(other Num).Equals(…)' method" + "summary": "Replaced the 'Person' identifier with the 'Num' identifier in the '(self Num).Equals(…)' method" + }, + { + "span": { + "replace": [ + { + "start": [ + 5, + 33 + ], + "end": [ + 5, + 39 + ] + }, + { + "start": [ + 5, + 30 + ], + "end": [ + 5, + 33 + ] + } + ] + }, + "summary": "Replaced the 'Person' identifier with the 'Num' identifier in the '(self Num).Equals(…)' method" } ] }, @@ -176,40 +176,13 @@ "+func (self Num) Equals(other Num) bool {}" ], "gitDir": "test/corpus/repos/go", - "shas": "d79d8d6400fbf0ee98ec1c1de105b35653bc6abf..4984840b9c1f873e4f0283f9aa56578524bc318a" + "shas": "0c19c3d818bc2c0bac5168d3e77f4e54e382a2d3..973f19351649422c552bebc3caa6b543f7edde31" } ,{ "testCaseDescription": "go-method-declarations-delete-replacement-test", "expectedResult": { "changes": { "method-declarations.go": [ - { - "span": { - "replace": [ - { - "start": [ - 5, - 30 - ], - "end": [ - 5, - 33 - ] - }, - { - "start": [ - 5, - 33 - ], - "end": [ - 5, - 39 - ] - } - ] - }, - "summary": "Replaced the 'Num' identifier with the 'Person' identifier in the '(other Person).Equals(…)' method" - }, { "span": { "replace": [ @@ -235,7 +208,34 @@ } ] }, - "summary": "Replaced the 'Num' identifier with the 'Person' identifier in the '(other Person).Equals(…)' method" + "summary": "Replaced the 'Num' identifier with the 'Person' identifier in the '(self Person).Equals(…)' method" + }, + { + "span": { + "replace": [ + { + "start": [ + 5, + 30 + ], + "end": [ + 5, + 33 + ] + }, + { + "start": [ + 5, + 33 + ], + "end": [ + 5, + 39 + ] + } + ] + }, + "summary": "Replaced the 'Num' identifier with the 'Person' identifier in the '(self Person).Equals(…)' method" } ] }, @@ -257,7 +257,7 @@ "+func (self Person) Equals(other Person) bool {}" ], "gitDir": "test/corpus/repos/go", - "shas": "4984840b9c1f873e4f0283f9aa56578524bc318a..5d97f8471206dc97ee31629ea3a5513e44182603" + "shas": "973f19351649422c552bebc3caa6b543f7edde31..322c0af27ab61337490585a423787b8dd90cdb4d" } ,{ "testCaseDescription": "go-method-declarations-delete-insert-test", @@ -277,7 +277,7 @@ ] } }, - "summary": "Deleted the '(other Person).Equals(…)' method" + "summary": "Deleted the '(self Person).Equals(…)' method" } ] }, @@ -299,7 +299,7 @@ "+" ], "gitDir": "test/corpus/repos/go", - "shas": "5d97f8471206dc97ee31629ea3a5513e44182603..e3c6f620532caea3d241a47bbaa17701dba91928" + "shas": "322c0af27ab61337490585a423787b8dd90cdb4d..02fce651f253788ced60704a9f32342bbae010a8" } ,{ "testCaseDescription": "go-method-declarations-teardown-test", @@ -356,5 +356,5 @@ "-" ], "gitDir": "test/corpus/repos/go", - "shas": "e3c6f620532caea3d241a47bbaa17701dba91928..852d29d2b9a695875dd0e15454330bbf7c5e49ff" + "shas": "02fce651f253788ced60704a9f32342bbae010a8..7edc6135ad00c9c21d6159bf897deac80d7f7b99" }] diff --git a/test/corpus/repos/go b/test/corpus/repos/go index 852d29d2b..7edc6135a 160000 --- a/test/corpus/repos/go +++ b/test/corpus/repos/go @@ -1 +1 @@ -Subproject commit 852d29d2b9a695875dd0e15454330bbf7c5e49ff +Subproject commit 7edc6135ad00c9c21d6159bf897deac80d7f7b99