From 5615da1bc08f79c431ae17c3d70038b55e785208 Mon Sep 17 00:00:00 2001 From: joshvera Date: Wed, 17 Aug 2016 10:42:05 -0400 Subject: [PATCH 1/4] Change methodParams to be a list of args --- src/Parser.hs | 6 ++++-- src/Syntax.hs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Parser.hs b/src/Parser.hs index f59b65e09..e247e883d 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -69,8 +69,10 @@ termConstructor source sourceSpan info = fmap cofree . construct _ -> errorWith children construct children | FunctionCall == category info = case runCofree <$> children of - [ (_ :< S.MemberAccess{..}), params@(_ :< S.Args{}) ] -> - pure $! setCategory info MethodCall :< S.MethodCall memberId property (cofree params) + [ (_ :< S.MemberAccess{..}), params@(_ :< S.Args args) ] -> + pure $! setCategory info MethodCall :< S.MethodCall memberId property args + [ (_ :< S.MemberAccess{..}) ] -> + pure $! setCategory info MethodCall :< S.MethodCall memberId property [] (x:xs) -> withDefaultInfo $ S.FunctionCall (cofree x) (cofree <$> xs) _ -> errorWith children diff --git a/src/Syntax.hs b/src/Syntax.hs index 9ef6465ab..85763201b 100644 --- a/src/Syntax.hs +++ b/src/Syntax.hs @@ -33,7 +33,7 @@ data Syntax a f | MemberAccess { memberId :: f, property :: f } -- | A method call consisting of its target, the method name, and the parameters passed to the method. -- | e.g. in Javascript console.log('hello') represents a method call. - | MethodCall { targetId :: f, methodId :: f, methodParams :: f } + | MethodCall { targetId :: f, methodId :: f, methodParams :: [f] } -- | The list of arguments to a method call. -- | TODO: It might be worth removing this and using Fixed instead. | Args [f] From c16effb699fd910c64c090dd4a90ef573e1624a4 Mon Sep 17 00:00:00 2001 From: joshvera Date: Wed, 17 Aug 2016 11:00:17 -0400 Subject: [PATCH 2/4] Add comma operator 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 c8559d17b..087a6c0f9 100644 --- a/src/Renderer/Split.hs +++ b/src/Renderer/Split.hs @@ -74,6 +74,7 @@ styleName category = "category-" <> case category of C.Class -> "class_statement" C.Method -> "method" C.If -> "if_statement" + C.CommaOperator -> "comma_operator" Other string -> string -- | Pick the class name for a split patch. From d90653aaffa7551aa364a2630ec815242e0313af Mon Sep 17 00:00:00 2001 From: joshvera Date: Wed, 17 Aug 2016 11:23:53 -0400 Subject: [PATCH 3/4] remove unused params --- src/Parser.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parser.hs b/src/Parser.hs index e247e883d..594eb3ddd 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -69,7 +69,7 @@ termConstructor source sourceSpan info = fmap cofree . construct _ -> errorWith children construct children | FunctionCall == category info = case runCofree <$> children of - [ (_ :< S.MemberAccess{..}), params@(_ :< S.Args args) ] -> + [ (_ :< S.MemberAccess{..}), (_ :< S.Args args) ] -> pure $! setCategory info MethodCall :< S.MethodCall memberId property args [ (_ :< S.MemberAccess{..}) ] -> pure $! setCategory info MethodCall :< S.MethodCall memberId property [] From c09887b8df6bfa1a5fa2b06f8c0170264424f61b Mon Sep 17 00:00:00 2001 From: joshvera Date: Wed, 17 Aug 2016 11:24:12 -0400 Subject: [PATCH 4/4] update semantic-diff tests --- test/diffs/asymmetrical-context.split.js | 8 ++++---- test/diffs/insert.split.js | 6 +++--- test/diffs/multiline-insert.split.js | 14 +++++++------- test/diffs/nested-insert.split.js | 6 +++--- test/diffs/newline-at-eof.json.js | 2 +- test/diffs/newline-at-eof.split.js | 6 +++--- test/diffs/no-newline-at-eof.json.js | 2 +- test/diffs/no-newline-at-eof.split.js | 6 +++--- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/test/diffs/asymmetrical-context.split.js b/test/diffs/asymmetrical-context.split.js index 31bc72255..10de89c0c 100644 --- a/test/diffs/asymmetrical-context.split.js +++ b/test/diffs/asymmetrical-context.split.js @@ -1,7 +1,7 @@ -
1
      • console
      • .
      • log
      • (
          • '
          • hello
          • '
      • )
    • ;
  • + - @@ -20,9 +20,9 @@ - - diff --git a/test/diffs/insert.split.js b/test/diffs/insert.split.js index 04fe95e10..1bdaa6bef 100644 --- a/test/diffs/insert.split.js +++ b/test/diffs/insert.split.js @@ -1,11 +1,11 @@ -
    1
        • console
        • .
        • log
        • (
          • '
          • hello
          • '
        • )
      • ;
    1
        • console
        • .
        • log
        • (
            • '
            • hello
            • '
        • )
      • ;
    • +
    1
        • console
        • .
        • log
        • (
          • '
          • hello
          • '
        • )
      • ;
    5
    2
        • console
        • .
        • log
        • (
            • '
            • world
            • '
        • )
      • ;
    • +
    2
        • console
        • .
        • log
        • (
          • '
          • world
          • '
        • )
      • ;
    6
        • console
        • .
        • log
        • (
            • '
            • world
            • '
        • )
      • ;
    • +
    6
        • console
        • .
        • log
        • (
          • '
          • world
          • '
        • )
      • ;
    3
      1
          • console
          • .
          • log
          • (
              • '
              • hello
              • '
          • )
        • ;
      • + - - diff --git a/test/diffs/multiline-insert.split.js b/test/diffs/multiline-insert.split.js index 6d4caafc2..5fcbdab80 100644 --- a/test/diffs/multiline-insert.split.js +++ b/test/diffs/multiline-insert.split.js @@ -1,24 +1,24 @@ -
        1
            • console
            • .
            • log
            • (
              • '
              • hello
              • '
            • )
          • ;
        1
            • console
            • .
            • log
            • (
                • '
                • hello
                • '
            • )
          • ;
        • +
        1
            • console
            • .
            • log
            • (
              • '
              • hello
              • '
            • )
          • ;
        2
            • console
            • .
            • log
            • (
                • '
                • world
                • '
            • )
          • ;
        • +
        2
            • console
            • .
            • log
            • (
              • '
              • world
              • '
            • )
          • ;
        2
          1
              • console
              • .
              • log
              • (
                  • '
                  • hello
                  • '
              • )
            • ;
          • + - - - - - - diff --git a/test/diffs/nested-insert.split.js b/test/diffs/nested-insert.split.js index f43d38f8c..a41bcebe5 100644 --- a/test/diffs/nested-insert.split.js +++ b/test/diffs/nested-insert.split.js @@ -4,13 +4,13 @@ - - -
            1
                • console
                • .
                • log
                • (
                  • '
                  • hello
                  • '
                • )
              • ;
            1
                • console
                • .
                • log
                • (
                    • '
                    • hello
                    • '
                • )
              • ;
            • +
            1
                • console
                • .
                • log
                • (
                  • '
                  • hello
                  • '
                • )
              • ;
            2
              • if (
              • true
              • )
                • { +
            2
              • if (
              • true
              • )
                • {
            3
                    • console
                    • .
                    • log
                    • (
                        • '
                        • cruel
                        • '
                    • )
                  • ;
                • +
            3
                    • console
                    • .
                    • log
                    • (
                      • '
                      • cruel
                      • '
                    • )
                  • ;
            4
                • }
            • +
            4
                • }
            2
                • console
                • .
                • log
                • (
                    • '
                    • world
                    • '
                • )
              • ;
            • +
            2
                • console
                • .
                • log
                • (
                  • '
                  • world
                  • '
                • )
              • ;
            5
                • console
                • .
                • log
                • (
                    • '
                    • world
                    • '
                • )
              • ;
            • +
            5
                • console
                • .
                • log
                • (
                  • '
                  • world
                  • '
                • )
              • ;
            3
              1
                • if (
                • true
                • )
                  • {
              2
                      • console
                      • .
                      • log
                      • (
                          • '
                          • hello
                          • '
                      • )
                    • ;
                  • +
              2
                      • console
                      • .
                      • log
                      • (
                        • '
                        • hello
                        • '
                      • )
                    • ;
              2
                      • console
                      • .
                      • log
                      • (
                          • '
                          • hello
                          • '
                      • )
                    • ;
                  • +
              2
                      • console
                      • .
                      • log
                      • (
                        • '
                        • hello
                        • '
                      • )
                    • ;
              3
                      • console
                      • .
                      • log
                      • (
                          • '
                          • world
                          • '
                      • )
                    • ;
                  • +
              3
                      • console
                      • .
                      • log
                      • (
                        • '
                        • world
                        • '
                      • )
                    • ;
              3
                  • }
              • diff --git a/test/diffs/newline-at-eof.json.js b/test/diffs/newline-at-eof.json.js index 3d58ee6bc..9f0602ca9 100644 --- a/test/diffs/newline-at-eof.json.js +++ b/test/diffs/newline-at-eof.json.js @@ -1 +1 @@ -{"rows":[[{"number":1,"terms":[{"range":[0,29],"category":"Program","children":[{"range":[0,28],"category":"ExpressionStatements","children":[{"range":[0,27],"category":"MethodCall","children":[{"range":[0,7],"category":"Identifier"},{"range":[8,11],"category":"Identifier"},{"range":[12,26],"category":"Args","children":[{"range":[12,26],"category":"StringLiteral","children":[{"range":[12,13],"category":"StringLiteral"},{"range":[13,18],"category":"StringLiteral"},{"range":[18,19],"category":"StringLiteral"},{"range":[20,25],"category":"StringLiteral"},{"range":[25,26],"category":"StringLiteral"}]}]}]}]}]}],"range":[0,29],"hasChanges":false},{"number":1,"terms":[{"range":[0,29],"category":"Program","children":[{"range":[0,28],"category":"ExpressionStatements","children":[{"range":[0,27],"category":"MethodCall","children":[{"range":[0,7],"category":"Identifier"},{"range":[8,11],"category":"Identifier"},{"range":[12,26],"category":"Args","children":[{"range":[12,26],"category":"StringLiteral","children":[{"range":[12,13],"category":"StringLiteral"},{"range":[13,18],"category":"StringLiteral"},{"range":[18,19],"category":"StringLiteral"},{"range":[20,25],"category":"StringLiteral"},{"range":[25,26],"category":"StringLiteral"}]}]}]}]}]}],"range":[0,29],"hasChanges":false}],[{"number":2,"terms":[{"range":[29,29],"category":"Program","children":[]}],"range":[29,29],"hasChanges":false},{"number":2,"terms":[{"range":[29,30],"category":"Program","children":[]}],"range":[29,30],"hasChanges":false}],[{"number":3,"terms":[{"range":[30,56],"category":"Program","children":[{"patch":"insert","range":[30,55],"category":"ExpressionStatements","children":[{"range":[30,54],"category":"MethodCall","children":[{"range":[30,37],"category":"Identifier"},{"range":[38,41],"category":"Identifier"},{"range":[42,53],"category":"Args","children":[{"range":[42,53],"category":"StringLiteral","children":[{"range":[42,43],"category":"StringLiteral"},{"range":[43,52],"category":"StringLiteral"},{"range":[52,53],"category":"StringLiteral"}]}]}]}]}]}],"range":[30,56],"hasChanges":true}],[{"number":4,"terms":[{"range":[56,56],"category":"Program","children":[]}],"range":[56,56],"hasChanges":false}]],"oids":["0000000000000000000000000000000000000000","0000000000000000000000000000000000000000"],"paths":["test/diffs/newline-at-eof.A.js","test/diffs/newline-at-eof.B.js"]} \ No newline at end of file +{"rows":[[{"number":1,"terms":[{"range":[0,29],"category":"Program","children":[{"range":[0,28],"category":"ExpressionStatements","children":[{"range":[0,27],"category":"MethodCall","children":[{"range":[0,7],"category":"Identifier"},{"range":[8,11],"category":"Identifier"},{"range":[12,26],"category":"StringLiteral","children":[{"range":[12,13],"category":"StringLiteral"},{"range":[13,18],"category":"StringLiteral"},{"range":[18,19],"category":"StringLiteral"},{"range":[20,25],"category":"StringLiteral"},{"range":[25,26],"category":"StringLiteral"}]}]}]}]}],"range":[0,29],"hasChanges":false},{"number":1,"terms":[{"range":[0,29],"category":"Program","children":[{"range":[0,28],"category":"ExpressionStatements","children":[{"range":[0,27],"category":"MethodCall","children":[{"range":[0,7],"category":"Identifier"},{"range":[8,11],"category":"Identifier"},{"range":[12,26],"category":"StringLiteral","children":[{"range":[12,13],"category":"StringLiteral"},{"range":[13,18],"category":"StringLiteral"},{"range":[18,19],"category":"StringLiteral"},{"range":[20,25],"category":"StringLiteral"},{"range":[25,26],"category":"StringLiteral"}]}]}]}]}],"range":[0,29],"hasChanges":false}],[{"number":2,"terms":[{"range":[29,29],"category":"Program","children":[]}],"range":[29,29],"hasChanges":false},{"number":2,"terms":[{"range":[29,30],"category":"Program","children":[]}],"range":[29,30],"hasChanges":false}],[{"number":3,"terms":[{"range":[30,56],"category":"Program","children":[{"patch":"insert","range":[30,55],"category":"ExpressionStatements","children":[{"range":[30,54],"category":"MethodCall","children":[{"range":[30,37],"category":"Identifier"},{"range":[38,41],"category":"Identifier"},{"range":[42,53],"category":"StringLiteral","children":[{"range":[42,43],"category":"StringLiteral"},{"range":[43,52],"category":"StringLiteral"},{"range":[52,53],"category":"StringLiteral"}]}]}]}]}],"range":[30,56],"hasChanges":true}],[{"number":4,"terms":[{"range":[56,56],"category":"Program","children":[]}],"range":[56,56],"hasChanges":false}]],"oids":["0000000000000000000000000000000000000000","0000000000000000000000000000000000000000"],"paths":["test/diffs/newline-at-eof.A.js","test/diffs/newline-at-eof.B.js"]} \ No newline at end of file diff --git a/test/diffs/newline-at-eof.split.js b/test/diffs/newline-at-eof.split.js index 220e3f673..e3f5295b4 100644 --- a/test/diffs/newline-at-eof.split.js +++ b/test/diffs/newline-at-eof.split.js @@ -1,7 +1,7 @@ -
                1
                    • console
                    • .
                    • log
                    • (
                        • "
                        • hello
                        • ,
                        • world
                        • "
                    • )
                  • ;
                • + - @@ -9,7 +9,7 @@ - diff --git a/test/diffs/no-newline-at-eof.json.js b/test/diffs/no-newline-at-eof.json.js index ea5e696d5..3d1b24107 100644 --- a/test/diffs/no-newline-at-eof.json.js +++ b/test/diffs/no-newline-at-eof.json.js @@ -1 +1 @@ -{"rows":[[{"number":1,"terms":[{"range":[0,28],"category":"Program","children":[{"range":[0,28],"category":"ExpressionStatements","children":[{"range":[0,27],"category":"MethodCall","children":[{"range":[0,7],"category":"Identifier"},{"range":[8,11],"category":"Identifier"},{"range":[12,26],"category":"Args","children":[{"range":[12,26],"category":"StringLiteral","children":[{"range":[12,13],"category":"StringLiteral"},{"range":[13,18],"category":"StringLiteral"},{"range":[18,19],"category":"StringLiteral"},{"range":[20,25],"category":"StringLiteral"},{"range":[25,26],"category":"StringLiteral"}]}]}]}]}]}],"range":[0,28],"hasChanges":false},{"number":1,"terms":[{"range":[0,29],"category":"Program","children":[{"range":[0,28],"category":"ExpressionStatements","children":[{"range":[0,27],"category":"MethodCall","children":[{"range":[0,7],"category":"Identifier"},{"range":[8,11],"category":"Identifier"},{"range":[12,26],"category":"Args","children":[{"range":[12,26],"category":"StringLiteral","children":[{"range":[12,13],"category":"StringLiteral"},{"range":[13,18],"category":"StringLiteral"},{"range":[18,19],"category":"StringLiteral"},{"range":[20,25],"category":"StringLiteral"},{"range":[25,26],"category":"StringLiteral"}]}]}]}]}]}],"range":[0,29],"hasChanges":false}],[{"number":2,"terms":[{"range":[29,30],"category":"Program","children":[]}],"range":[29,30],"hasChanges":false}],[{"number":3,"terms":[{"range":[30,55],"category":"Program","children":[{"patch":"insert","range":[30,55],"category":"ExpressionStatements","children":[{"range":[30,54],"category":"MethodCall","children":[{"range":[30,37],"category":"Identifier"},{"range":[38,41],"category":"Identifier"},{"range":[42,53],"category":"Args","children":[{"range":[42,53],"category":"StringLiteral","children":[{"range":[42,43],"category":"StringLiteral"},{"range":[43,52],"category":"StringLiteral"},{"range":[52,53],"category":"StringLiteral"}]}]}]}]}]}],"range":[30,55],"hasChanges":true}]],"oids":["0000000000000000000000000000000000000000","0000000000000000000000000000000000000000"],"paths":["test/diffs/no-newline-at-eof.A.js","test/diffs/no-newline-at-eof.B.js"]} \ No newline at end of file +{"rows":[[{"number":1,"terms":[{"range":[0,28],"category":"Program","children":[{"range":[0,28],"category":"ExpressionStatements","children":[{"range":[0,27],"category":"MethodCall","children":[{"range":[0,7],"category":"Identifier"},{"range":[8,11],"category":"Identifier"},{"range":[12,26],"category":"StringLiteral","children":[{"range":[12,13],"category":"StringLiteral"},{"range":[13,18],"category":"StringLiteral"},{"range":[18,19],"category":"StringLiteral"},{"range":[20,25],"category":"StringLiteral"},{"range":[25,26],"category":"StringLiteral"}]}]}]}]}],"range":[0,28],"hasChanges":false},{"number":1,"terms":[{"range":[0,29],"category":"Program","children":[{"range":[0,28],"category":"ExpressionStatements","children":[{"range":[0,27],"category":"MethodCall","children":[{"range":[0,7],"category":"Identifier"},{"range":[8,11],"category":"Identifier"},{"range":[12,26],"category":"StringLiteral","children":[{"range":[12,13],"category":"StringLiteral"},{"range":[13,18],"category":"StringLiteral"},{"range":[18,19],"category":"StringLiteral"},{"range":[20,25],"category":"StringLiteral"},{"range":[25,26],"category":"StringLiteral"}]}]}]}]}],"range":[0,29],"hasChanges":false}],[{"number":2,"terms":[{"range":[29,30],"category":"Program","children":[]}],"range":[29,30],"hasChanges":false}],[{"number":3,"terms":[{"range":[30,55],"category":"Program","children":[{"patch":"insert","range":[30,55],"category":"ExpressionStatements","children":[{"range":[30,54],"category":"MethodCall","children":[{"range":[30,37],"category":"Identifier"},{"range":[38,41],"category":"Identifier"},{"range":[42,53],"category":"StringLiteral","children":[{"range":[42,43],"category":"StringLiteral"},{"range":[43,52],"category":"StringLiteral"},{"range":[52,53],"category":"StringLiteral"}]}]}]}]}],"range":[30,55],"hasChanges":true}]],"oids":["0000000000000000000000000000000000000000","0000000000000000000000000000000000000000"],"paths":["test/diffs/no-newline-at-eof.A.js","test/diffs/no-newline-at-eof.B.js"]} \ No newline at end of file diff --git a/test/diffs/no-newline-at-eof.split.js b/test/diffs/no-newline-at-eof.split.js index 9643db481..c6d2dd59b 100644 --- a/test/diffs/no-newline-at-eof.split.js +++ b/test/diffs/no-newline-at-eof.split.js @@ -1,6 +1,6 @@ -
                  1
                      • console
                      • .
                      • log
                      • (
                        • "
                        • hello
                        • ,
                        • world
                        • "
                      • )
                    • ;
                  1
                      • console
                      • .
                      • log
                      • (
                          • "
                          • hello
                          • ,
                          • world
                          • "
                      • )
                    • ;
                  • +
                  1
                      • console
                      • .
                      • log
                      • (
                        • "
                        • hello
                        • ,
                        • world
                        • "
                      • )
                    • ;
                  2
                    3
                        • console
                        • .
                        • log
                        • (
                            • "
                            • insertion
                            • "
                        • )
                      • ;
                    • +
                    3
                        • console
                        • .
                        • log
                        • (
                          • "
                          • insertion
                          • "
                        • )
                      • ;
                    -
                    1
                        • console
                        • .
                        • log
                        • (
                            • "
                            • hello
                            • ,
                            • world
                            • "
                        • )
                      • ;
                    1
                        • console
                        • .
                        • log
                        • (
                            • "
                            • hello
                            • ,
                            • world
                            • "
                        • )
                      • ;
                    • + + @@ -8,6 +8,6 @@ - +
                      1
                          • console
                          • .
                          • log
                          • (
                            • "
                            • hello
                            • ,
                            • world
                            • "
                          • )
                        • ;
                      1
                          • console
                          • .
                          • log
                          • (
                            • "
                            • hello
                            • ,
                            • world
                            • "
                          • )
                        • ;
                      3
                          • console
                          • .
                          • log
                          • (
                              • "
                              • insertion
                              • "
                          • )
                        • ;
                      3
                          • console
                          • .
                          • log
                          • (
                            • "
                            • insertion
                            • "
                          • )
                        • ;
                      \ No newline at end of file