[jsp] fixes unhandled exceptions highlighting in inner classes and lambda expressions

This commit is contained in:
Roman Shevchenko
2015-07-23 17:08:15 +02:00
parent 8b80f72a06
commit d66a9bda00
2 changed files with 23 additions and 11 deletions
@@ -798,16 +798,17 @@ public class HighlightUtil extends HighlightUtilBase {
}
@Nullable
private static HighlightInfoType getUnhandledExceptionHighlightType(final PsiElement element) {
if (!FileTypeUtils.isInServerPageFile(element)) {
return HighlightInfoType.UNHANDLED_EXCEPTION;
private static HighlightInfoType getUnhandledExceptionHighlightType(PsiElement element) {
// JSP top level errors are handled by UnhandledExceptionInJSP inspection
if (FileTypeUtils.isInServerPageFile(element)) {
PsiMethod targetMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class, true, PsiLambdaExpression.class);
if (targetMethod instanceof SyntheticElement) {
return null;
}
}
PsiMethod targetMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
if (!(targetMethod instanceof SyntheticElement)) return HighlightInfoType.UNHANDLED_EXCEPTION;
// ignore JSP top level errors - it handled by UnhandledExceptionInJSP inspection
return null;
}
return HighlightInfoType.UNHANDLED_EXCEPTION;
}
@Nullable
static HighlightInfo checkBreakOutsideLoop(@NotNull PsiBreakStatement statement) {
@@ -369,11 +369,19 @@ public class ExceptionUtil {
visitElement(statement);
}
@Override
public void visitLambdaExpression(PsiLambdaExpression expression) {
if (ArrayUtil.find(elements, expression) >= 0) {
visitElement(expression);
}
}
@Override
public void visitMethodReferenceExpression(@NotNull PsiMethodReferenceExpression expression) {
if (ArrayUtil.find(elements, expression) < 0) return;
addExceptions(array, getUnhandledExceptions(expression, null));
visitElement(expression);
if (ArrayUtil.find(elements, expression) >= 0) {
addExceptions(array, getUnhandledExceptions(expression, null));
visitElement(expression);
}
}
@Override
@@ -387,6 +395,9 @@ public class ExceptionUtil {
addExceptions(array, getUnhandledCloserExceptions(resource, null));
visitElement(resource);
}
@Override
public void visitClass(PsiClass aClass) { }
};
for (PsiElement element : elements) {