gumtree-spoon-ast-diff icon indicating copy to clipboard operation
gumtree-spoon-ast-diff copied to clipboard

not able to handle one case of ExplicitConversion

Open jianguda opened this issue 5 years ago • 3 comments

For example, run this

@Test
public void testExplicitConversion() throws Exception {
    AstComparator comparator = new AstComparator();
    String a = "class Foo{public void bar(){\ndouble b = 0;\n}}";
    String b = "class Foo{public void bar(){\ndouble b = (double) 0;\n}}";
    Diff diff = comparator.compare(a, b);
    List<Operation> operations = diff.getRootOperations();
    for (Operation operation : operations) {
        System.out.println(operation);
        System.out.println("================");
    }
    a = "class Foo{public void bar(){\nint a = 1;\ndouble b = a;\n}}";
    b = "class Foo{public void bar(){\nint a = 1;\ndouble b = (double) a;\n}}";
    diff = comparator.compare(a, b);
    operations = diff.getRootOperations();
    for (Operation operation : operations) {
        System.out.println(operation);
        System.out.println("================");
    }
}

and we only get

Update Literal at Foo:2
	0 to ((double) (0))

================

I also tried the webdiff tool from gumtree and did not meet this issue.

jianguda avatar May 17 '19 11:05 jianguda

Thanks Jian for the bug report. Could you try to make a fix in a pull request?

monperrus avatar May 17 '19 11:05 monperrus

I am going to handle this in Summer

jianguda avatar May 27 '19 12:05 jianguda

great!

monperrus avatar May 28 '19 07:05 monperrus