diff --git a/java/java-impl/src/com/intellij/codeInsight/NullableNotNullManagerImpl.java b/java/java-impl/src/com/intellij/codeInsight/NullableNotNullManagerImpl.java index 1bb5a8ee5423..866fc5bc8c0e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/NullableNotNullManagerImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/NullableNotNullManagerImpl.java @@ -50,7 +50,7 @@ public class NullableNotNullManagerImpl extends NullableNotNullManager implement public void setNotNulls(@NotNull String... annotations) { LinkedHashSet set = ContainerUtil.newLinkedHashSet(annotations); Collections.addAll(set, DEFAULT_NOT_NULLS); - set.remove(NULLABLE); + set.removeAll(Arrays.asList(DEFAULT_NULLABLES)); myNotNulls = new ArrayList<>(set); } @@ -58,7 +58,7 @@ public class NullableNotNullManagerImpl extends NullableNotNullManager implement public void setNullables(@NotNull String... annotations) { LinkedHashSet set = ContainerUtil.newLinkedHashSet(annotations); Collections.addAll(set, DEFAULT_NULLABLES); - set.remove(NOT_NULL); + set.removeAll(Arrays.asList(DEFAULT_NOT_NULLS)); myNullables = new ArrayList<>(set); } @@ -135,8 +135,8 @@ public class NullableNotNullManagerImpl extends NullableNotNullManager implement readJdomList(state.myNullables, myNullables, DEFAULT_NULLABLES); readJdomList(state.myNotNulls, myNotNulls, DEFAULT_NOT_NULLS); - myNullables.remove(NOT_NULL); - myNotNulls.remove(NULLABLE); + myNullables.removeAll(Arrays.asList(DEFAULT_NOT_NULLS)); + myNotNulls.removeAll(Arrays.asList(DEFAULT_NULLABLES)); } private static void readJdomList(@Nullable Element src, @NotNull List to, @NotNull String[] defaults) { diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/NullableNotNullManagerTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/NullableNotNullManagerTest.java index b068511fb592..d2f879b41184 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/NullableNotNullManagerTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/NullableNotNullManagerTest.java @@ -34,6 +34,9 @@ public class NullableNotNullManagerTest extends LightPlatformTestCase { public void testCannotAddNotNullToNullable() { assertNotNull(myManager); checkAnnotations(); + myManager.setNotNulls("foo.NotNull"); + checkAnnotations(); + assertTrue(myManager.getNotNulls().contains("foo.NotNull")); myManager.setNotNulls(AnnotationUtil.NULLABLE); myManager.setNullables(AnnotationUtil.NOT_NULL); checkAnnotations();