Files
openide/java/java-tests/testData/inspection/redundantThrowsGlobalFix/beforeRemoveTry.java
Nikita Eshkeev abdc241d87 [java-analysis-impl] IDEA-248487 Red code after "Remove unnecessary 'throws' declarations"
The local inspection for redundant throws didn't use to check if the
method was called somewhere where it was in a try-catch block, so
removing what seemed to be a redundant throw used to lead to red code
because of the corresponding try-catch sections. This patch amends both
the local and the global inspections for redundant throws, so the local
inspeciton checks if it's cheap enough to find such try-catch sections
and if not it assumes that there is a try-catch section somewhere. The
global inspeciton looks for all the references to the method and finds
all the try-catch sections that are related to it. The inspeciton
removes the corresponding catch sections if possible or amends the type
of catch sections if their type is an instance of a disjunction type.

Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>

GitOrigin-RevId: 076f2a974326700172c8796a4d28df8fe0dd4546
2020-09-10 18:59:40 +00:00

20 lines
309 B
Java

// "FileNotFoundException" "true"
import java.io.FileNotFoundException;
class Main {
public void f() throws <caret>FileNotFoundException {}
{
try {
f();
} catch (FileNotFoundException e) {}
}
}
class B {
{
try {
new Main().f();
} catch (FileNotFoundException e) {}
}
}