Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refactoring java code using scripts

Is there an eclipse based solution to refactor Java code using scripts?

I've read about the Eclipse Language toolkit, but it seems that it implies the creation of a plugin, which sounds like overkill for a one-off operation.

Are there some kind of bindings to a scripting language, or at least a way to call refactoring code from java but without a plugin?

Sample use case : I have a project which uses castor generated classes, and I want to migrate to JAXB 2. It implies a lot of refactoring in the existing code, which cannot be done by search and replace, nor regular expressions, because of the context-sensitveness.

like image 967
Mikarnage Avatar asked Nov 25 '22 04:11

Mikarnage


1 Answers

When the refactoring is complex, I usually write a transformation pipeline with Recoder. The only drawback of this tool is that it sometimes breaks the code format (e.g. moving comments around, or adding/deleting whitespace), but so far it has been enough for my requirements.

like image 188
Javier Avatar answered Dec 16 '22 10:12

Javier