In a situation like the following:
class Foo
{
final String bar;
Foo(@NotNull baz, String foon)
{
bar = baz;
final String qux = quux();
String spork = quux();
spork = new String();
foon.contains("abc");
}
final @NotNull String quux() {return "Q"};
}
I would like Idea to suggest to me that the variable 'bar' could be declared @NotNull (because it is final and initialized from a @NotNull value).
Similarly, I think that Idea could determine that qux and spork could be declared @NotNull (because they are only assigned to from values that are known to be not null, or declared as @NotNull).
Similarly, I think that Idea could determine that foon could be declared @NotNull (because a method is called on it with no check for null beforehand... if it were null, a NullPointerException would result).
I would like to have inspections to check for these cases and intentions to add the @NotNull keyword.
I would also like to have Idea able to do similar things with @Nullable. For instance, if null, or an a @Nullable value is ever assigned to a variable or field, then Idea should be able to suggest that the variable or field be declared @Nullable.