prash
prash

Reputation: 41

groovy parsing(to get the argument names in the method calls)

i want to get the names of arguments passed in the groovy method calls of groovy script.(literally to parse the script). example:-

(date)(getAttribute(ShippedDate)).compareTo((Date)getAttribute(OrderDate)) > 0 

i need to get shippedDate and orderDate

Thanks.

Upvotes: 2

Views: 523

Answers (1)

rdmueller
rdmueller

Reputation: 11052

The solution could be hidden in the groovy console. There you can access the AST (Abstract Syntax Tree) from the menu via Script->Inspect Ast . In this view, you will find the parameters you are searching for.

So it seems to be possible. While searching for "groovy ast" on google, I found the following code which seems to take a script and output the AST:

http://svn.codehaus.org/groovy/branches/gep-3/src/main/groovy/inspect/swingui/AstBrowser.groovy

Hope that helps!

Upvotes: 1

Related Questions