mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-38867 (AIOOBE: TryWithIdenticalCatchesInspection$TryWithIdenticalCatchesVisitor.canCollapse)
This commit is contained in:
+4
-1
@@ -82,6 +82,10 @@ public class TryWithIdenticalCatchesInspection extends BaseInspection {
|
||||
if (catchSections.length < 2) {
|
||||
return;
|
||||
}
|
||||
final PsiParameter[] parameters = statement.getCatchBlockParameters();
|
||||
if (catchSections.length != parameters.length) {
|
||||
return;
|
||||
}
|
||||
final boolean[] duplicates = new boolean[catchSections.length];
|
||||
for (int i = 0; i < catchSections.length - 1; i++) {
|
||||
final PsiCatchSection catchSection = catchSections[i];
|
||||
@@ -99,7 +103,6 @@ public class TryWithIdenticalCatchesInspection extends BaseInspection {
|
||||
false);
|
||||
final DuplicatesFinder finder = new DuplicatesFinder(new PsiElement[]{catchBlock},
|
||||
inputVariables, null, Collections.<PsiVariable>emptyList());
|
||||
final PsiParameter[] parameters = statement.getCatchBlockParameters();
|
||||
for (int j = i + 1; j < catchSections.length; j++) {
|
||||
if (duplicates[j]) {
|
||||
continue;
|
||||
|
||||
+12
@@ -105,4 +105,16 @@ class TryIdenticalCatches {
|
||||
} catch (E1 e) {
|
||||
}
|
||||
}
|
||||
|
||||
void q() {
|
||||
try {
|
||||
Class.forName("bla").newInstance();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
} catch (InstantiationException ) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -108,4 +108,16 @@ class TryIdenticalCatches {
|
||||
} <warning descr="catch branch identical to 'E2' branch">catch (E1 e)</warning> {
|
||||
}
|
||||
}
|
||||
|
||||
void q() {
|
||||
try {
|
||||
Class.forName("bla").newInstance();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
} catch (<error descr="Cannot resolve symbol 'InstantiationException'">InstantiationException</error><error descr="Identifier expected"> </error>) {
|
||||
<error descr="Cannot resolve symbol 'e'">e</error>.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user