what is best java libraries to write custom refactoring scripts? [closed]

I plan to do complex refactoring of large project, default ide capabilities is not enough. Please also provide tutorial link if possible.

Language: java, xml

I talk about programmatic api for java refactoring

Example I have created new api in project and I want automatically refractor some code to use it, ie source to source transformation of ast tree

Answer

There’s always Eclipse; you should be able to access its Java refactoring machinery via its internal procedural APIs. Whether those are easily found or well documented, I don’t know. No source-to-source transformations.

There is a tool called Jackpot that was supposedly designed to support this task. I believe it also only offers procedural APIs but I think they are intentionally well documented. No source-to-source transformation capability.

Our DMS Software Reengineering Toolkit with its Java Front End could be used for this.

DMS was designed to be general purpose program transformation engine for many languages (Java is just one it happens to know about). It can carry out arbitrary code changes. DMS provides parsing to ASTs, symbol table construction, an AST manipulation interface, including OP’s request for pattern-directed source-to-source transformations, and regeneration of source text (including the original comments if unchanged) from any modified AST. DMS is happy to read all the files that make up your application, so you can effect changes that cross source file boundaries easily.

People may suggest using some parser generator. While parsing is necessary, it is hardly sufficient; a parser fails to do all the other things (above) that you need.

Leave a Reply

Your email address will not be published. Required fields are marked *