mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
redundant throws: do not warn on native methods IDEA-205525
This commit is contained in:
+4
@@ -8,6 +8,7 @@ import com.intellij.codeInsight.daemon.impl.quickfix.MethodThrowsFix;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.codeInspection.reference.*;
|
||||
import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
|
||||
import com.intellij.lang.jvm.JvmModifier;
|
||||
import com.intellij.openapi.application.WriteAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -71,6 +72,9 @@ public class RedundantThrowsDeclarationInspection extends GlobalJavaBatchInspect
|
||||
|
||||
PsiElement psiMethod = refMethod.getPsiElement();
|
||||
if (!(psiMethod instanceof PsiMethod)) return null;
|
||||
|
||||
if (((PsiMethod)psiMethod).hasModifier(JvmModifier.NATIVE)) return null;
|
||||
|
||||
PsiReferenceList list = ((PsiMethod)psiMethod).getThrowsList();
|
||||
PsiClassType[] throwsList = list.getReferencedTypes();
|
||||
PsiJavaCodeReferenceElement[] throwsRefs = list.getReferenceElements();
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems/>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import java.io.*;
|
||||
|
||||
class Bar {
|
||||
|
||||
public native int goDrink(String arg) throws IOException;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
Bar bar = new Bar();
|
||||
bar.goDrink("aaa");
|
||||
}
|
||||
}
|
||||
@@ -58,4 +58,8 @@ public class RedundantThrowTest extends InspectionTestCase {
|
||||
public void testThrownClausesInMethodReference() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNativeMethod() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user