allow to ignore external super parameter annotations in nullable stuff inspection (IDEA-114892)

This commit is contained in:
peter
2014-09-15 14:49:56 +02:00
parent 9a09378a2c
commit 2781f30195
6 changed files with 81 additions and 17 deletions
@@ -0,0 +1,13 @@
import java.util.Date;
import java.util.concurrent.locks.Condition;
abstract class Demo6Impl implements Condition {
@Override
public boolean awaitUntil(Date deadline) {
/* This is considered to be an error in Eclipse: The second parameter is not annotated in the JDK but
* only through the external annotations in IntelliJ. Thus, Eclipse is complaining:
* Illegal redefinition of parameter unit, inherited method from ExecutorService does not constrain this parameter
*/
return false;
}
}
@@ -0,0 +1,9 @@
import java.util.Date;
import java.util.concurrent.locks.Condition;
abstract class Demo6Impl implements Condition {
@Override
public boolean awaitUntil(Date <warning descr="Not annotated parameter overrides @NotNull parameter">deadline</warning>) {
return false;
}
}
@@ -8,14 +8,31 @@ package com.intellij.codeInspection;
import com.intellij.JavaTestUtil;
import com.intellij.codeInspection.nullable.NullableStuffInspection;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.testFramework.LightProjectDescriptor;
import com.intellij.testFramework.PsiTestUtil;
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
import org.jetbrains.annotations.NotNull;
public class NullableStuffInspectionTest extends LightCodeInsightFixtureTestCase {
private static final DefaultLightProjectDescriptor PROJECT_DESCRIPTOR = new DefaultLightProjectDescriptor() {
@Override
public Sdk getSdk() {
return PsiTestUtil.addJdkAnnotations(super.getSdk());
}
};
private final NullableStuffInspection myInspection = new NullableStuffInspection();
{
myInspection.REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS = false;
}
@NotNull
@Override
protected LightProjectDescriptor getProjectDescriptor() {
return PROJECT_DESCRIPTOR;
}
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath() + "/inspection/nullableProblems/";
@@ -39,6 +56,13 @@ public class NullableStuffInspectionTest extends LightCodeInsightFixtureTestCase
doTest();
}
public void testOverridingExternalNotNull() { doTest(); }
public void testIgnoreExternalNotNull() {
myInspection.IGNORE_EXTERNAL_SUPER_NOTNULL = true;
doTest();
}
public void testHonorSuperParameterDefault() {
DataFlowInspectionTest.addJavaxNullabilityAnnotations(myFixture);
DataFlowInspectionTest.addJavaxDefaultNullabilityAnnotations(myFixture);