GumTreeDiff / gumtree

An awesome code differencing tool
https://github.com/GumTreeDiff/gumtree/wiki
GNU Lesser General Public License v3.0
893 stars 170 forks source link

Order ignored? #326

Closed codinuum closed 5 months ago

codinuum commented 6 months ago

The following should result in two updates (or less optimal move+delete+insert) because import_from_stmt is ordered.

01-18-2024 9 47 26

b0.py.txt b1.py.txt

jrfaller commented 6 months ago

I cannot reproduce this result, which parser are you using? With tree sitter I have one delete / insert which is due to the way the parser encode from statements.

Cheers!

codinuum commented 6 months ago

I tried the following. gumtree webdiff -m gumtree-simple -g python-treesitter b0.py b1.py

Parinsg b0.py results in the following.

module [0,32]
    import_from_statement [0,31]
        from: from [0,4]
        dotted_name [5,13]
            identifier: datasets [5,13]
        dotted_name [21,31]
            identifier: data_utils [21,31]
jrfaller commented 6 months ago

OK, the script is correct but the visualization is not. It's infered as a move and update however since they affect the very same token, only the update action is seen 😢

===
match
---
dotted_name [5,13]
dotted_name [23,31]
===
match
---
module [0,32]
module [0,32]
===
match
---
from: from [0,4]
from: from [0,4]
===
match
---
identifier: datasets [5,13]
identifier: get_file [23,31]
===
match
---
dotted_name [21,31]
dotted_name [5,15]
===
match
---
identifier: data_utils [21,31]
identifier: data_utils [5,15]
===
match
---
import_from_statement [0,31]
import_from_statement [0,31]
===
move-tree
---
dotted_name [5,13]
    identifier: datasets [5,13]
to
import_from_statement [0,31]
at 2
===
update-node
---
identifier: datasets [5,13]
replace datasets by get_file