From 5f73492b7f4f2b2199d494376c32cf62704e69cb Mon Sep 17 00:00:00 2001 From: "Anna.Kozlova" Date: Mon, 4 Apr 2016 16:21:50 +0200 Subject: [PATCH] fix parenthesis expr during precise rethrow detection --- .../src/com/intellij/codeInsight/ExceptionUtil.java | 3 ++- .../advHighlighting7/PreciseRethrow.java | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java index 85413d2a046d..cffd36569447 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/ExceptionUtil.java @@ -579,7 +579,8 @@ public class ExceptionUtil { } @NotNull - private static List getPreciseThrowTypes(@Nullable final PsiExpression expression) { + private static List getPreciseThrowTypes(@Nullable PsiExpression expression) { + expression = PsiUtil.skipParenthesizedExprDown(expression); if (expression instanceof PsiReferenceExpression) { final PsiElement target = ((PsiReferenceExpression)expression).resolve(); if (target != null && PsiUtil.isCatchParameter(target)) { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PreciseRethrow.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PreciseRethrow.java index 5f85e1860cbb..abe4b85fd5e9 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PreciseRethrow.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/PreciseRethrow.java @@ -193,6 +193,14 @@ class C { } } + void m11_5() { + try {} + catch (Exception e) { + //parentesis expr + throw (e); + } + } + static class MyResource implements AutoCloseable { public void close() throws E1 { } }