Reputation: 10310
Often after refactoring throws
sections become unnecessary. IntelliJ highlights them with grey showing that they can be removed, but I'd like to remove them automatically (just like unused imports get removed via ctrl+alt+O).
Q: Is there a way to automatically remove unused throws
sections within a class? Is there a shortcut for that?
Upvotes: 7
Views: 4873
Reputation: 116
You can use Alt+Enter and select Cleanup code.
This will remove all unnecessary throws Exception declarations.
Upvotes: 2
Reputation: 49646
There are two ways I am aware of:
I use the ^⇧⌘C combination. There was no default hotkey.
You can specify code cleanup scope. It might be the whole project or a custom scope.
It gets accessible on the focused clause (you put the mouse on the element) with alt⏎.
Upvotes: 5