mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-09 20:42:52 +07:00
IDEA-142391 Don't report overriding externally-annotated @NotNull methods/parameters when there's no @NotNull annotation in the project
This commit is contained in:
+4
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems>
|
||||
</problems>
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class B extends Comparable<B> {
|
||||
@Override
|
||||
public int compareTo(B o) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public class DataFlowInspectionTestSuite {
|
||||
suite.addTestSuite(NormalCompletionDfaTest.class);
|
||||
|
||||
suite.addTestSuite(NullableStuffInspectionTest.class);
|
||||
suite.addTestSuite(NullableStuffInspection14Test.class);
|
||||
suite.addTestSuite(NullableStuffInspectionAncientTest.class);
|
||||
|
||||
suite.addTestSuite(AddAssertStatementFixTest.class);
|
||||
suite.addTestSuite(SurroundWithIfFixTest.class);
|
||||
|
||||
+24
-29
@@ -16,8 +16,9 @@ import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
|
||||
public class NullableStuffInspection14Test extends InspectionTestCase {
|
||||
public class NullableStuffInspectionAncientTest extends InspectionTestCase {
|
||||
private final NullableStuffInspection myInspection = new NullableStuffInspection();
|
||||
{
|
||||
myInspection.REPORT_ANNOTATION_NOT_PROPAGATED_TO_OVERRIDERS = false;
|
||||
@@ -28,40 +29,34 @@ public class NullableStuffInspection14Test extends InspectionTestCase {
|
||||
return JavaTestUtil.getJavaTestDataPath() + "/inspection";
|
||||
}
|
||||
|
||||
private void doTest14() throws Exception {
|
||||
myExcludeAnnotations = true;
|
||||
try {
|
||||
doTest("nullableProblems/" + getTestName(true), new LocalInspectionToolWrapper(myInspection),"java 1.4");
|
||||
}
|
||||
finally {
|
||||
myExcludeAnnotations = false;
|
||||
}
|
||||
public void testJdk14() throws Exception{
|
||||
doTest("nullableProblems/" + getTestName(true), new LocalInspectionToolWrapper(myInspection), "java 1.4");
|
||||
}
|
||||
|
||||
public void testJdk14() throws Exception{ doTest14(); }
|
||||
|
||||
private boolean myExcludeAnnotations = false;
|
||||
public void testJdkAnnotationsWithoutJetBrainsAnnotations() throws Exception{
|
||||
doTest("nullableProblems/" + getTestName(true), new LocalInspectionToolWrapper(myInspection), "java 1.5");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupRootModel(String testDir, VirtualFile[] sourceDir, String sdkName) {
|
||||
super.setupRootModel(testDir, sourceDir, sdkName);
|
||||
|
||||
if (myExcludeAnnotations) {
|
||||
final Sdk sdk = ModuleRootManager.getInstance(myModule).getSdk();
|
||||
assert sdk != null;
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final SdkModificator sdkMod = sdk.getSdkModificator();
|
||||
for (VirtualFile file : sdkMod.getRoots(OrderRootType.CLASSES)) {
|
||||
if ("annotations.jar".equals(file.getName())) {
|
||||
sdkMod.removeRoot(file, OrderRootType.CLASSES);
|
||||
break;
|
||||
}
|
||||
}
|
||||
sdkMod.commitChanges();
|
||||
}
|
||||
});
|
||||
Sdk sdk = ModuleRootManager.getInstance(myModule).getSdk();
|
||||
removeAnnotationsJar(sdk);
|
||||
if ("testJdkAnnotationsWithoutJetBrainsAnnotations".equals(getName())) {
|
||||
PsiTestUtil.addJdkAnnotations(sdk);
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeAnnotationsJar(final Sdk sdk) {
|
||||
ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
final SdkModificator sdkMod = sdk.getSdkModificator();
|
||||
for (VirtualFile file : sdkMod.getRoots(OrderRootType.CLASSES)) {
|
||||
if ("annotations.jar".equals(file.getName())) {
|
||||
sdkMod.removeRoot(file, OrderRootType.CLASSES);
|
||||
break;
|
||||
}
|
||||
}
|
||||
sdkMod.commitChanges();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user