-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
textdiff
has inconsistent range output between formats
#334
Comments
I did some digging within the code and found this line in this file: gumtree/core/src/main/java/com/github/gumtreediff/actions/ChawatheScriptGenerator.java Line 106 in 170ba6f
gumtree/core/src/main/java/com/github/gumtreediff/actions/model/Insert.java Lines 25 to 34 in 170ba6f
From this, we can see that the |
Thanks a lot for the detailed report! You're correct, it seems like a bug. I will try to investigate this. |
OK I see the problem. The text serializer uses this code to output the text for insert actions. It defers the computation to this method, which resort to the parent node stored in the action, which belongs to the source tree as you noticed here. For the other serializer, XML for instance, it uses this code which uses the parent node supplied as a parameter here that is the parent coming from the destination tree which is a different behavior. I think we should indeed have consistent behavior but I am not sure what is the right solution. An inserted node only exists in the destination tree therefore if one wants to look up the code corresponding to this node together with the parent, she should look inside the destination file, that's why I am more convinced by the behavior of the XML and JSON formatters. WDYT? |
Hi all,
I compiled the latest version of Gumtree from the source and have been using it. Really great project! I'm having some issues with the
textdiff
command, unfortunately. It appears that the output between the three formats is inconsistent with each other, mainly with their ranges.(Not that I think it matters, but I'm currently running Fedora 38.)
Steps to Reproduce
I have the following Java files,
A.java
,B1.java
, andB2.java
, which I have attached to this issue:A.java
is the original file and contains a simple class with one field calledqwerty
.B1.java
changes the field's name toasdfg
and addsSystem.out.println("hello")
to the constructor.B2.java
is the same asB1.java
, but with 10 extra lines added immediately before the curly brace opening the class.I then ran the following (I've attached these files to my issue as well):
Behavior
All three formats handled
update-node
the same way, but there is an inconsistency between their handling ofinsert-tree
. Eachinsert-tree
hastree
as anExpressionStatement
andparent
as aBlock
. This is correct. However, the ranges differ between formats. Here's the inconsistency shown in a table:tree: [116, 144]
parent: [111, 116]
tree: [126, 154]
parent: [111, 116]
tree: [116, 144]
parent: [110, 148]
tree: [126, 154]
parent: [120, 158]
tree: [116, 144]
parent: [110, 148]
tree: [126, 154]
parent: [120, 158]
It appears that TEXT is taking
parent
fromA.java
, while JSON and XML are takingparent
fromB1/2.java
. You can verify this because TEXT'sparent
fields do not change between the two diffs, while JSON's and XML's increase by 10.Which file format has the correct version? Personally, I think TEXT makes the most sense, as you are inserting the tree at a point in the old tree.
Files
The text was updated successfully, but these errors were encountered: