NullableNotNullManager: remove all default nullables from not-nulls and vice versa

+ Simple sanity test. Review ID: IDEA-CR-33648
This commit is contained in:
Tagir Valeev
2018-06-18 15:25:25 +07:00
parent 2de36f53d7
commit 8f02a0178f
2 changed files with 7 additions and 4 deletions
@@ -50,7 +50,7 @@ public class NullableNotNullManagerImpl extends NullableNotNullManager implement
public void setNotNulls(@NotNull String... annotations) {
LinkedHashSet<String> 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<String> 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<String> to, @NotNull String[] defaults) {
@@ -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();