groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MG <mg...@arscreat.com>
Subject Re: AST to replace `==` with `equals` method invocation
Date Sun, 10 Jun 2018 19:27:03 GMT
Hi Paolo,

I have not used it myself, but have you had a look at the new Groovy 2.5 
"abstract syntax tree search and replace"-feature 
(http://groovy-lang.org/releasenotes/groovy-2.5.html & search for "AST 
matching") ?

Cheers,
mg


On 10.06.2018 16:55, Paolo Di Tommaso wrote:
> Dear all,
>
> I'm trying to implement an AST transformation to replace any `==` 
> binary expression with a equals method call invocation as suggested 
> here 
> <https://stackoverflow.com/questions/28355773/in-groovy-why-does-the-behaviour-of-change-for-interfaces-extending-compar#comment45123447_28387391>.
>
>
> My understanding is that it's required to override each the visitor 
> for each node where a binary expression can appear ie. if statement, 
> while statement, assignment, for loop, method call, etc.
>
> That looks a bit overkill. I was wondering if there's a better way to 
> replace globally all `==` binary expressions with `equals` method 
> invocations.
>
>
> Cheers,
> Paolo
>


Mime
View raw message