Question

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.

Était-ce utile?

La solution

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.

Autres conseils

Eclipse provides some refactoring help. For eg if you select the portion of code you want to refactor and right click, you get an option for Refactor. From which you can extract to a method(the one i commonly use while refactoring), extract interface, superclass etc.

You can also check these:

http://www.eclipse.org/articles/article.php?file=Article-Unleashing-the-Power-of-Refactoring/index.html

Eclipse: Most useful refactorings

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top