我发现了一个突出问题,其中包含了catch子句中的异常 . 这有点与Highlight exception throwers in IntelliJ IDEA有关
给出示例代码如下:
try {
System.out.print(Double.parseDouble("throws exception"));
} catch (NumberFormatException e){
System.out.print(e.toString());
}
并将光标定位在日食中的 NumberFormatException
上将突出显示它被抛出的位置
但在IntelliJ中,我无法重现这一点:
当把插入符号放在catch和 NumberFormatException
上时我已经尝试了 highlight usage in file
但它不起作用,我做错了什么?
在方法签名中执行它时,它是相同的,eclipse:
但不是在smartJ
有可能以与日食相同的方式获得这个吗?
EDIT
正如其中一个答案中的yole解释的那样,这特定于IntelliJ中未经检查的异常,即使它们在方法签名中声明,如 Double.parseDouble(String) throws NumberFormatException()
的情况
2 回答
在IntelliJ IDEA中,要查看抛出异常的位置,您需要将插入符号放在
catch
关键字上,而不是放在异常类名称上 .显然你需要一个组合键:
Ctrl + Shift + F7
见https://intellij-support.jetbrains.com/hc/en-us/community/posts/206269539-how-can-I-see-in-intellij-where-exception-is-thrown-