Closed elizabethdinella closed 5 years ago
Hi, it's just a numeric identifier for the node's type (here 150 corresponds to NAME nodes). However, it will be gone in the next version, in which we will only rely on a ruby's symbol like implementation for defining a node type.
Regards!
Oh, thanks! So is there any way to identify which node in the original AST was updated?
If you are using Java code to generate this, you can retrieve the position of the node in the source file. In next version, node position will be included in the default output.
Hi, I am still not understanding how these numbers correspond to the type of node. For example, there are multiple name nodes with many different numbers (73, 165, 150, etc). Do these numbers somehow distinguish between different name nodes?
OK just to know what language are you analyzing?
Javascript
OK, since you are not using C where there is a regression, I recommend you to pull the latest version of the develop branch you will have a way better text output for the textual diff. I do not recall that much the old output since it was not used, so you're right that it does not seem to be the node's type id, so perhaps it is the node id, which is unique in its tree.
In the latest version, default text output is like that :
match
---
NAME: event [844,849]
NAME: event [844,849]
===
match
---
GETPROP [968,991]
GETPROP [968,991]
===
match
---
NAME: startsWith [763,773]
NAME: startsWith [763,773]
Where [763,773] corresponds to the starting and ending character index of the node in the source file.
Thanks! This is excatly what i'm looking for. However the same files produce different diffs in the new version.
insert-node
---
String: "expression" [4484,4496]
to
FIELD [4484,63325]
at 0
===
insert-node
---
String: "callee" [4558,4566]
to
FIELD [4558,53880]
at 0
===
insert-node
---
String: "object" [4677,4685]
to
FIELD [4677,53721]
at 0
===
update-node
---
String: "user" [45784,45790]
replace "user" by "userId"
===
delete-node
---
String: "body" [57,63]
===
===
delete-node
---
String: "expression" [4484,4496]
===
===
delete-node
---
String: "callee" [4558,4566]
===
===
delete-node
---
String: "object" [4677,4685]
===
which was just a single update in the original version. Is there away to change matching parameters to get the matching output I was getting previously?
Can you attach your test files so that I can analyze them?
Yes, they're JSON representations fo JS es6 files that were generated using esprima.
{
"type": "Program",
"body": [
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "express"
},
"init": {
"type": "CallExpression",
"callee": {
"type": "Identifier",
"name": "require"
},
"arguments": [
{
"type": "Literal",
"value": "express",
"raw": "'express'"
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "router"
},
"init": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "express"
},
"property": {
"type": "Identifier",
"name": "Router"
}
},
"arguments": []
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "bodyParser"
},
"init": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "Identifier",
"name": "require"
},
"arguments": [
{
"type": "Literal",
"value": "body-parser",
"raw": "'body-parser'"
}
]
},
"property": {
"type": "Identifier",
"name": "json"
}
},
"arguments": []
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "Project"
},
"init": {
"type": "CallExpression",
"callee": {
"type": "Identifier",
"name": "require"
},
"arguments": [
{
"type": "Literal",
"value": "../models/project",
"raw": "'../models/project'"
}
]
}
}
],
"kind": "const"
},
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "router"
},
"property": {
"type": "Identifier",
"name": "get"
}
},
"arguments": [
{
"type": "Literal",
"value": "/",
"raw": "'/'"
},
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "req"
},
{
"type": "Identifier",
"name": "res"
},
{
"type": "Identifier",
"name": "next"
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "Project"
},
"property": {
"type": "Identifier",
"name": "find"
}
},
"arguments": []
},
"property": {
"type": "Identifier",
"name": "lean"
}
},
"arguments": []
},
"property": {
"type": "Identifier",
"name": "then"
}
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "projects"
}
],
"body": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "res"
},
"property": {
"type": "Identifier",
"name": "send"
}
},
"arguments": [
{
"type": "Identifier",
"name": "projects"
}
]
},
"generator": false,
"expression": true,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "catch"
}
},
"arguments": [
{
"type": "Identifier",
"name": "next"
}
]
}
}
]
},
"generator": false,
"expression": false,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "get"
}
},
"arguments": [
{
"type": "Literal",
"value": "/:id",
"raw": "'/:id'"
},
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "req"
},
{
"type": "Identifier",
"name": "res"
},
{
"type": "Identifier",
"name": "next"
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "Project"
},
"property": {
"type": "Identifier",
"name": "findById"
}
},
"arguments": [
{
"type": "MemberExpression",
"computed": false,
"object": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "req"
},
"property": {
"type": "Identifier",
"name": "params"
}
},
"property": {
"type": "Identifier",
"name": "id"
}
}
]
},
"property": {
"type": "Identifier",
"name": "then"
}
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "project"
}
],
"body": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "res"
},
"property": {
"type": "Identifier",
"name": "send"
}
},
"arguments": [
{
"type": "Identifier",
"name": "project"
}
]
},
"generator": false,
"expression": true,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "catch"
}
},
"arguments": [
{
"type": "Identifier",
"name": "next"
}
]
}
}
]
},
"generator": false,
"expression": false,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "delete"
}
},
"arguments": [
{
"type": "Literal",
"value": "/:id",
"raw": "'/:id'"
},
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "req"
},
{
"type": "Identifier",
"name": "res"
},
{
"type": "Identifier",
"name": "next"
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "Project"
},
"property": {
"type": "Identifier",
"name": "findByIdAndRemove"
}
},
"arguments": [
{
"type": "MemberExpression",
"computed": false,
"object": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "req"
},
"property": {
"type": "Identifier",
"name": "params"
}
},
"property": {
"type": "Identifier",
"name": "id"
}
}
]
},
"property": {
"type": "Identifier",
"name": "then"
}
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "deleted"
}
],
"body": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "res"
},
"property": {
"type": "Identifier",
"name": "send"
}
},
"arguments": [
{
"type": "Identifier",
"name": "deleted"
}
]
},
"generator": false,
"expression": true,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "catch"
}
},
"arguments": [
{
"type": "Identifier",
"name": "next"
}
]
}
}
]
},
"generator": false,
"expression": false,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "post"
}
},
"arguments": [
{
"type": "Literal",
"value": "/",
"raw": "'/'"
},
{
"type": "Identifier",
"name": "bodyParser"
},
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "req"
},
{
"type": "Identifier",
"name": "res"
},
{
"type": "Identifier",
"name": "next"
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "proj"
},
"init": {
"type": "NewExpression",
"callee": {
"type": "Identifier",
"name": "Project"
},
"arguments": [
{
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "req"
},
"property": {
"type": "Identifier",
"name": "body"
}
}
]
}
}
],
"kind": "let"
},
{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "proj"
},
"property": {
"type": "Identifier",
"name": "user"
}
},
"right": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "req"
},
"property": {
"type": "Identifier",
"name": "user"
}
},
"property": {
"type": "Identifier",
"name": "id"
}
}
}
},
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "proj"
},
"property": {
"type": "Identifier",
"name": "save"
}
},
"arguments": []
},
"property": {
"type": "Identifier",
"name": "then"
}
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "saved"
}
],
"body": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "res"
},
"property": {
"type": "Identifier",
"name": "send"
}
},
"arguments": [
{
"type": "Identifier",
"name": "saved"
}
]
},
"generator": false,
"expression": true,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "catch"
}
},
"arguments": [
{
"type": "Identifier",
"name": "next"
}
]
}
}
]
},
"generator": false,
"expression": false,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "put"
}
},
"arguments": [
{
"type": "Literal",
"value": "/:id",
"raw": "'/:id'"
},
{
"type": "Identifier",
"name": "bodyParser"
},
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "req"
},
{
"type": "Identifier",
"name": "res"
},
{
"type": "Identifier",
"name": "next"
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "Project"
},
"property": {
"type": "Identifier",
"name": "findByIdAndUpdate"
}
},
"arguments": [
{
"type": "MemberExpression",
"computed": false,
"object": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "req"
},
"property": {
"type": "Identifier",
"name": "params"
}
},
"property": {
"type": "Identifier",
"name": "id"
}
},
{
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "req"
},
"property": {
"type": "Identifier",
"name": "body"
}
}
]
},
"property": {
"type": "Identifier",
"name": "then"
}
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "saved"
}
],
"body": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "res"
},
"property": {
"type": "Identifier",
"name": "send"
}
},
"arguments": [
{
"type": "Identifier",
"name": "saved"
}
]
},
"generator": false,
"expression": true,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "catch"
}
},
"arguments": [
{
"type": "Identifier",
"name": "next"
}
]
}
}
]
},
"generator": false,
"expression": false,
"async": false
}
]
}
},
{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "module"
},
"property": {
"type": "Identifier",
"name": "exports"
}
},
"right": {
"type": "Identifier",
"name": "router"
}
}
}
],
"sourceType": "script"
}
and
{
"type": "Program",
"body": [
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "express"
},
"init": {
"type": "CallExpression",
"callee": {
"type": "Identifier",
"name": "require"
},
"arguments": [
{
"type": "Literal",
"value": "express",
"raw": "'express'"
}
]
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "router"
},
"init": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "express"
},
"property": {
"type": "Identifier",
"name": "Router"
}
},
"arguments": []
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "bodyParser"
},
"init": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "Identifier",
"name": "require"
},
"arguments": [
{
"type": "Literal",
"value": "body-parser",
"raw": "'body-parser'"
}
]
},
"property": {
"type": "Identifier",
"name": "json"
}
},
"arguments": []
}
}
],
"kind": "const"
},
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "Project"
},
"init": {
"type": "CallExpression",
"callee": {
"type": "Identifier",
"name": "require"
},
"arguments": [
{
"type": "Literal",
"value": "../models/project",
"raw": "'../models/project'"
}
]
}
}
],
"kind": "const"
},
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "router"
},
"property": {
"type": "Identifier",
"name": "get"
}
},
"arguments": [
{
"type": "Literal",
"value": "/",
"raw": "'/'"
},
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "req"
},
{
"type": "Identifier",
"name": "res"
},
{
"type": "Identifier",
"name": "next"
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "Project"
},
"property": {
"type": "Identifier",
"name": "find"
}
},
"arguments": []
},
"property": {
"type": "Identifier",
"name": "lean"
}
},
"arguments": []
},
"property": {
"type": "Identifier",
"name": "then"
}
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "projects"
}
],
"body": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "res"
},
"property": {
"type": "Identifier",
"name": "send"
}
},
"arguments": [
{
"type": "Identifier",
"name": "projects"
}
]
},
"generator": false,
"expression": true,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "catch"
}
},
"arguments": [
{
"type": "Identifier",
"name": "next"
}
]
}
}
]
},
"generator": false,
"expression": false,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "get"
}
},
"arguments": [
{
"type": "Literal",
"value": "/:id",
"raw": "'/:id'"
},
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "req"
},
{
"type": "Identifier",
"name": "res"
},
{
"type": "Identifier",
"name": "next"
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "Project"
},
"property": {
"type": "Identifier",
"name": "findById"
}
},
"arguments": [
{
"type": "MemberExpression",
"computed": false,
"object": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "req"
},
"property": {
"type": "Identifier",
"name": "params"
}
},
"property": {
"type": "Identifier",
"name": "id"
}
}
]
},
"property": {
"type": "Identifier",
"name": "then"
}
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "project"
}
],
"body": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "res"
},
"property": {
"type": "Identifier",
"name": "send"
}
},
"arguments": [
{
"type": "Identifier",
"name": "project"
}
]
},
"generator": false,
"expression": true,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "catch"
}
},
"arguments": [
{
"type": "Identifier",
"name": "next"
}
]
}
}
]
},
"generator": false,
"expression": false,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "delete"
}
},
"arguments": [
{
"type": "Literal",
"value": "/:id",
"raw": "'/:id'"
},
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "req"
},
{
"type": "Identifier",
"name": "res"
},
{
"type": "Identifier",
"name": "next"
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "Project"
},
"property": {
"type": "Identifier",
"name": "findByIdAndRemove"
}
},
"arguments": [
{
"type": "MemberExpression",
"computed": false,
"object": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "req"
},
"property": {
"type": "Identifier",
"name": "params"
}
},
"property": {
"type": "Identifier",
"name": "id"
}
}
]
},
"property": {
"type": "Identifier",
"name": "then"
}
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "deleted"
}
],
"body": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "res"
},
"property": {
"type": "Identifier",
"name": "send"
}
},
"arguments": [
{
"type": "Identifier",
"name": "deleted"
}
]
},
"generator": false,
"expression": true,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "catch"
}
},
"arguments": [
{
"type": "Identifier",
"name": "next"
}
]
}
}
]
},
"generator": false,
"expression": false,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "post"
}
},
"arguments": [
{
"type": "Literal",
"value": "/",
"raw": "'/'"
},
{
"type": "Identifier",
"name": "bodyParser"
},
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "req"
},
{
"type": "Identifier",
"name": "res"
},
{
"type": "Identifier",
"name": "next"
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "proj"
},
"init": {
"type": "NewExpression",
"callee": {
"type": "Identifier",
"name": "Project"
},
"arguments": [
{
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "req"
},
"property": {
"type": "Identifier",
"name": "body"
}
}
]
}
}
],
"kind": "let"
},
{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "proj"
},
"property": {
"type": "Identifier",
"name": "userId"
}
},
"right": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "req"
},
"property": {
"type": "Identifier",
"name": "user"
}
},
"property": {
"type": "Identifier",
"name": "id"
}
}
}
},
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "proj"
},
"property": {
"type": "Identifier",
"name": "save"
}
},
"arguments": []
},
"property": {
"type": "Identifier",
"name": "then"
}
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "saved"
}
],
"body": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "res"
},
"property": {
"type": "Identifier",
"name": "send"
}
},
"arguments": [
{
"type": "Identifier",
"name": "saved"
}
]
},
"generator": false,
"expression": true,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "catch"
}
},
"arguments": [
{
"type": "Identifier",
"name": "next"
}
]
}
}
]
},
"generator": false,
"expression": false,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "put"
}
},
"arguments": [
{
"type": "Literal",
"value": "/:id",
"raw": "'/:id'"
},
{
"type": "Identifier",
"name": "bodyParser"
},
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "req"
},
{
"type": "Identifier",
"name": "res"
},
{
"type": "Identifier",
"name": "next"
}
],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "Project"
},
"property": {
"type": "Identifier",
"name": "findByIdAndUpdate"
}
},
"arguments": [
{
"type": "MemberExpression",
"computed": false,
"object": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "req"
},
"property": {
"type": "Identifier",
"name": "params"
}
},
"property": {
"type": "Identifier",
"name": "id"
}
},
{
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "req"
},
"property": {
"type": "Identifier",
"name": "body"
}
}
]
},
"property": {
"type": "Identifier",
"name": "then"
}
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"id": null,
"params": [
{
"type": "Identifier",
"name": "saved"
}
],
"body": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "res"
},
"property": {
"type": "Identifier",
"name": "send"
}
},
"arguments": [
{
"type": "Identifier",
"name": "saved"
}
]
},
"generator": false,
"expression": true,
"async": false
}
]
},
"property": {
"type": "Identifier",
"name": "catch"
}
},
"arguments": [
{
"type": "Identifier",
"name": "next"
}
]
}
}
]
},
"generator": false,
"expression": false,
"async": false
}
]
}
},
{
"type": "ExpressionStatement",
"expression": {
"type": "AssignmentExpression",
"operator": "=",
"left": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Identifier",
"name": "module"
},
"property": {
"type": "Identifier",
"name": "exports"
}
},
"right": {
"type": "Identifier",
"name": "router"
}
}
}
],
"sourceType": "script"
}
The same issue occurs with the following files (fed to gumtree as js): https://github.com/nohyoungjin/ensi/blob/2aaa1079575559f6aa8b554a83fed3f8bc565bd0/js/common.js https://github.com/nohyoungjin/ensi/blob/1600e248bfea723f11d5c5332d4ed8292cbce347/js/common.js
In gumtree 2.1.2 the only update is the number on line 47. In gumtree 2.1.3 the diff includes many inserts and delete
I see, I could reproduce. Strange thing when I cut down the json files to contain only the first body element, I have no longer the detected useless insertion / deletion. I think there might be a bug inside one of the two phases of matching. I will investigate but files are huge to debug ;)
OK I found the problem. TLDR the problem is caused by trees exceeding the size for which the optimal matching algorithm of Zhang and Shasha is launched. Previously the trees were pruned of already matched nodes, and now it's no longer the case (because it was deleting potential anchors, but we are looking for a solution that preserves anchors and reduce search space). Therefore the behavior has changed. I am working on a good tradeof algorithm that seems to work in your case but I have to try it on a big benchmark before releasing it. I will commit it so that you can try.
Okay, you can try with the gumtree-simple matcher (-m gumtree-simple argument).
What are the meaning of the numbers in the diff output? For example in the following output:
user(150) was updated. What does 150 mean? Does this correpond to something in the original AST? Thank you!