I am trying to fix a few bugs in an old, now open-sourced intellij IDEA plugin (the CFML Plugin)
The following Syntax appears several times in multiple files and generates an error:
String @NotNull []
This is what the error looks like:
The example is from the following file: https://github.com/JetBrains/intellij-plugins/blob/master/CFML/src/com/intellij/coldFusion/model/CfmlUtil.java#L249
What does this syntax do?
I haven't found any information on it. It seems like @NotNull String[]
would do exactly the same thing without the error.
How do I get this to work? I have followed the setup instructions for setting up a development environment and creating a plugin project exactly. What is my environment missing to run this code?
I suspect that you don't have the JetBrains Annotations library installed. Please follow the installation guide here.
The String @NotNull []
syntax consists of the @NotNull
annotation applied to the String[]
type. Note that this is different from @NotNull String[]
, in which @NotNull
only applies to the String
type. The annotation is used in this way to say that the string array returned will not be null, but the strings inside it might be.
Compare:
@NotNull String @Nullable []
: strings in the returned array must be non null, but a null array could be returned.@NotNull String @NotNull []
: strings in the returned array must be non null, and the array must also be non null@Nullable String @NotNull []
: The string array must be non null, but the strings inside it might be null@Nullable String @Nullable []
: The string array could be null, and there might be null strings in it too