Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlight exception throwers in IntelliJ IDEA

I recently moved from Eclipse to IntelliJ IDEA, and there is a feature that I'm missing. In Eclipse, when you placed the caret on a checked exception, in throws declaration or catch block, it would highlight which method/constructor calls throw that exception.

Is there any way to do this in IntelliJ IDEA (Community edition)?

like image 916
TDJoe Avatar asked Oct 14 '11 21:10

TDJoe


People also ask

How do I throw an exception in debugging in Intellij?

Throw an exception Make sure the current method is selected on the Frames tab, then right-click anywhere in the tab and select Throw Exception. Create the exception (this can be any Throwable including Error and checked exceptions that are not handled by the method). Do not use the throw keyword.

Is throw an exception?

The throws keyword is used to declare which exceptions can be thrown from a method, while the throw keyword is used to explicitly throw an exception within a method or block of code. The throws keyword is used in a method signature and declares which exceptions can be thrown from a method.


1 Answers

Place the caret on the catch keyword and press Ctrl+Shift+F7.

(Find | Highlight Usages in File). If you are using different keymap and the above shortcut doesn't work, use Help | Find Action to search for this action and see its keyboard shortcut:

Find Action

If you want it to work automatically, enable Settings | Editor | Highlight usages of element at caret.

The same works on try and throws keywords with a choice of exceptions to highlight.

Here is a screenshot from IntelliJ IDEA Tip of the Day:

exceptions highlighted

Note that there is no way to highlight it by particular exception class until you select this class from the list of suggestions:

exceptions to highlight

like image 88
CrazyCoder Avatar answered Sep 24 '22 09:09

CrazyCoder