Reputation: 111806
I have created an interface, with about 30 methods and implemented in 30 classes.
I want to add @Override to each of the implementations, but i would like not to do it by hand.
How can IntelliJ help me?
interface looks like this:
public interface PreviewObjectTests {
void testGetName();
void testGetType();
//... 30 similar methods
}
implementation code:
public class PreviewObjectAccountTest implements PreviewObjectTests {
//I want to add @Override here!
@Test public void testGetName() {
assertThat(...);
}
//I want to add @Override here!
@Test public void testGetType() {
assertThat(...);
}
//...30 similar methods
}
Upvotes: 52
Views: 16087
Reputation: 2256
For Eclipse (tested on Mars.2):
Window / Preferences (or Project Properties) Java / Compiler Error/Warnings Annotations Missing @Override annotation - Set to Error (or Warning)
After the rebuild workspace, in the Markers view, right click on one of the errors, Quick Fix (Ctrl+1) and all the errors should appear. Select all and apply the fix.
This worked for me to properly annotate a few hundreds of classes...
Upvotes: -3
Reputation: 580
For IntelliJ:
Upvotes: 55
Reputation: 902
Its not eclipse or idea specfic. Its compiler specfic and what compliance you adhere to. In eclipse its 1.6 or higher. And In idea I believe its for 1.5 or higher.
In the above cases it will bechecked automatically by respective IDEs.
Upvotes: -3
Reputation: 111806
I found a way to do it with the simple find/replace tool.
This works in my particular case, because there were not really any other methods in the class files. I will assume this will be a bit more crazy if i had a lot of methods in the files belonging to other interfaces
Upvotes: -3
Reputation: 402591
Easily done with Alt+Enter intention, then press Right arrow for the sub-menu:
Upvotes: 66