views:

592

answers:

5

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.

A: 

What kind of refactoring are you looking for?

Eclipse can do the externalize strings bit.

Milhous
Not externalize. I want them constants, not in a property file.
John Sonmez
you are right, it con only do strings on a case by case basis.
Milhous
+1  A: 

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.

jamesh
That link is dead. All I can find are some old articles and a page in the NetBeans wiki. Does anyone know what happened to the project?
Jens Bannmann
A: 

Some plugins like Checkstyle plug into the quick fix framework and do allow mass fixes at once. But what you're looking for should plug into the existing refactoring framework, not replace it.

John Stoneham
+1  A: 

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

ekeren
A: 

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.

Tion