中突出显示异常抛出器

中突出显示异常抛出器

本文介绍了在 IntelliJ IDEA 中突出显示异常抛出器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从 Eclipse 转移到 IntelliJ IDEA,但我缺少一个功能.在 Eclipse 中,当您将插入符号放在已检查的异常上时,在 throws 声明或 catch 块中,它会突出显示哪个方法/构造函数调用会引发该异常.

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.

有没有办法在 IntelliJ IDEA(社区版)中做到这一点?

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

推荐答案

将插入符号放在 catch 关键字上并按 ++.

Place the caret on the catch keyword and press ++.

(Find | 突出显示文件中的用法).如果您使用不同的键盘映射并且上述快捷方式不起作用,请使用 Help |Find Action 搜索此操作并查看其键盘快捷键:

(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:

如果您希望它自动工作,请启用设置 |编辑器 |突出显示插入符号中元素的用法.

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

同样适用于 trythrows 关键字,并可选择突出显示的异常.

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

这是来自 IntelliJ IDEA 每日提示的屏幕截图:

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

请注意,除非您从建议列表中选择此类,否则无法按特定异常类突出显示它:

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

这篇关于在 IntelliJ IDEA 中突出显示异常抛出器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 08:28