pouryafard75 / RM-ASTDiff

MIT License
2 stars 1 forks source link

Missing subtrees in case having Generic functions with type parameter as the return type #92

Open pouryafard75 opened 8 months ago

pouryafard75 commented 8 months ago

Case: https://github.com/pouryafard75/TestCases/commit/58b8350a98ed4f93e2410a080fa011aa3158aeee

Due to the dependency to gumtree 3.0 jdt tree generator, the differences are not highlighted:

image

Surprisingly, 2.1 tree generator contains this information:

image
tsantalis commented 8 months ago

@pouryafard75 Is it possible to fix this issue on our side?

pouryafard75 commented 8 months ago

@tsantalis It is possible, However this will make tools incompatible.

tsantalis commented 8 months ago

Can we make a PR to gumtree? but then they need to make a new maven release. The incompatibility is not a problem, because we have 3.0.3 as compatible release.

pouryafard75 commented 8 months ago

@tsantalis All the perfect diffs at the moment, work based on 3.0 tree structure. I assume around 200 cases might need change if we change the structure!

tsantalis commented 7 months ago

@pouryafard75 Could we submit a PR resolving the issue opened at Gumtree repository, now that the issue has been checked by Jean-Rémy?

pouryafard75 commented 7 months ago

@tsantalis I did these two commits to resolve the issue: fix: add typeArguments subtrees to the receiver of the method invocation for jdt add test for typeArguments of the method invocation in jdt

I have also tested the diff to ensure the correctness:

image
pouryafard75 commented 7 months ago

@tsantalis PR submitted https://github.com/GumTreeDiff/gumtree/pull/327

tsantalis commented 7 months ago

@pouryafard75 SuperMethodInvocation has type arguments too. Can we update the PR to handle this case?

SuperMethodInvocation: [ ClassName . ] super . [ < Type { , Type } > ] Identifier ( [ Expression { , Expression } ] )

tsantalis commented 7 months ago

@pouryafard75 ClassInstanceCreation has type arguments too.

ClassInstanceCreation: [ Expression . ] new [ < Type { , Type } > ] Type ( [ Expression { , Expression } ] ) [ AnonymousClassDeclaration ]

pouryafard75 commented 7 months ago

@pouryafard75 SuperMethodInvocation has type arguments too. Can we update the PR to handle this case?

SuperMethodInvocation: [ ClassName . ] super . [ < Type { , Type } > ] Identifier ( [ Expression { , Expression } ] )

@tsantalis super.<String>emptyList(); --->

    SuperMethodInvocation [35,60]
              SimpleType [42,48]
                      SimpleName: String [42,48]
              SimpleName: emptyList [49,58]

this.<String>emptyList(); --->

              MethodInvocation [35,59]
                        METHOD_INVOCATION_RECEIVER [35,39]
                            ThisExpression [35,39]
                            SimpleType [41,47]
                                SimpleName: String [41,47]
                        SimpleName: emptyList [48,57]

This is default GumTree 3.0 output, They dont override the visitor for these ASTNodes, Method invocation is the only one which has been overwritten.

pouryafard75 commented 7 months ago

ClassInstanceCreation

@tsantalis Can you give me an example for this here?

new A().<String>emptyList();-->

           MethodInvocation [35,62]
                        METHOD_INVOCATION_RECEIVER [35,42]
                            ClassInstanceCreation [35,42]
                                SimpleType [39,40]
                                    SimpleName: A [39,40]
                            SimpleType [44,50]
                                SimpleName: String [44,50]
                        SimpleName: emptyList [51,60]

If you meant this, its already supported.

tsantalis commented 7 months ago

new A().<String>emptyList() This is a method invocation with class instance creation as receiver.

The case I am talking about looks like new <Category> Payload(arg1, arg2)

pouryafard75 commented 7 months ago

@tsantalis Thanks for the clarification.

new <Category> Payload(arg1, arg2); -->

           ClassInstanceCreation [35,69]
                        SimpleType [40,48]
                            SimpleName: Category [40,48]
                        SimpleType [50,57]
                            SimpleName: Payload [50,57]
                        SimpleName: arg1 [58,62]
                        SimpleName: arg2 [64,68]