mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
redundant throws: filter out unchecked exception (IDEA-177478, IDEA-177506)
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInspection.unneededThrows;
|
||||
|
||||
import com.intellij.codeInsight.ExceptionUtil;
|
||||
import com.intellij.codeInsight.daemon.JavaErrorMessages;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.MethodThrowsFix;
|
||||
@@ -135,7 +136,7 @@ public class RedundantThrowsDeclarationLocalInspection extends BaseJavaBatchLoca
|
||||
.of(method.getThrowsList().getReferenceElements())
|
||||
.map(ref -> {
|
||||
PsiElement resolved = ref.resolve();
|
||||
return resolved instanceof PsiClass ? new ReferenceAndType(ref) : null;
|
||||
return resolved instanceof PsiClass && !ExceptionUtil.isUncheckedException((PsiClass)resolved) ? new ReferenceAndType(ref) : null;
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.toArray(ReferenceAndType[]::new);
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Remove 'RuntimeException' from 'f' throws list" "false"
|
||||
import java.io.*;
|
||||
|
||||
class a {
|
||||
void f() throws <caret>RuntimeException {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user