Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a refactoring tool for Eclipse better than the built in one?

I know there is re-sharper for Visual Studio, but is there a really good refactoring tool for Eclipse that is better than the small amount of built in refactors?

Preferably something free.

(Update)

Looking to do things like take all string literals in a file and make them constants.
Solve lots of PMD errors in some automated fashion.

like image 242
John Sonmez Avatar asked Dec 18 '08 22:12

John Sonmez


3 Answers

I know you would prefer a free plug in for Eclipse, but if you love ReSharper and have to work with Java, check out InteliJ IDEA http://www.jetbrains.com/idea/index.html. It was the original inspiration for ReSharper and is also developed by JetBrains. I believe it has most of the same refactoring capabilities of RS and also supports the same keyboard scheme (if you chose to use the inteliJ scheme in VS.) If you do try it, let us C# guys know how it compares to your RS experience.

like image 84
Tion Avatar answered Sep 21 '22 21:09

Tion


This does not really answer your question but I can't properly format this into a comment.

Here is a nice way to extract Strings into constant in eclipse. (I didn't know about the pick out string until a couple of weeks ago)

We have this line:

System.out.println("This Line Contains a constant The 42 Constant that is stuck inside");

First let mark the desireed constant with our mouse cursor and ctrl-1 + "pick out selected String", the result is:

System.out.println("This Line Contains a constant " + "The 42 Constant" +" that is stuck inside");

Now you can put your mouse cursor on the picked out constant and Alt+Shift+T and than a (extract constant) that will generate the constants THE_42_CONSTANT as a private static final String

private static final String THE_42_CONSTANT = "The 42 Constant";
...
...
System.out.println("This Line Contains a constant " + THE_42_CONSTANT+ " that is stuck inside");

Hope this is what you are actually looking for, of course you can adjust hot-keys for the aboe actions in eclipse

like image 23
ekeren Avatar answered Sep 22 '22 21:09

ekeren


Jackpot is a refactoring language built into javac. It was James Goslings project, and became the heart of the Netbeans refactoring module. It's essentially a pattern matching language, matching over the AST.

With it, you can write your own patterns.

Edit: changed the link to a more live (post-Oracle) link. I have no idea if this is still a viable standalone project, though Netbeans is now 100% open source.

like image 28
jamesh Avatar answered Sep 20 '22 21:09

jamesh