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?
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⏎.
You can use Alt+Enter and select Cleanup code.
This will remove all unnecessary throws Exception declarations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With