Eclipse:在块中找到可以抛出异常的行 [英] Eclipse: find lines in a block that can throw exceptions
问题描述
我正在看代码,看起来像
I'm looking at code that looks like
try {
// Lots of things here.
// More than I'd like to individually hover over every time I see this
}
catch (Exception e) {
// doesn't matter
}
对于try块中的任何特定方法,我可以找到它抛出的检查异常。有没有办法突出显示可能会引发一些检查异常的所有行?
For any particular method in the try block, I can find what checked exceptions it throws. Is there any way to highlight all lines that could throw some checked exception?
一般来说,我想我可以删除catch块,改变方法签名来抛出异常,在这一点上,我可以看到抛出的方法中的所有行一个例外(Nevermind:see the update)。
In general, I guess I could perhaps remove the catch block, changing the method signature to throw Exception, at which point, I can see all lines in the method that throw an exception (Nevermind: see the update).
在这种情况下,这甚至不会很好地工作,因为代码在JSP中。
In this case, that won't even work nicely, because the code is in a JSP.
注意:如果重要,我使用MyEclipse标准。
Note: if it matters, I'm using MyEclipse standard.
更新:标记出现在,但在这种情况下根本不做任何事情。我问了这个问题,因为我认为关于这个上下文的一些事情使得这个预期的行为,但它看起来像是一个奇怪的边缘案例或错误。
Update: Mark occurrences is on, but simply does nothing in this case. I asked the question because I thought that something about the context made this expected behavior, but it looks like it's a weird edge case or bug.
推荐答案
在eclipse中,如果启用突出显示事件并选择异常
,它会突出显示正在被catch块捕获的(已检查)异常的所有行。
In eclipse, if you enable "highlight occurrences" and select Exception
, it would highlight all lines that are throwing a (checked) exception that is being caught by the catch block.
这篇关于Eclipse:在块中找到可以抛出异常的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!