A bit off-topic: interface annotations enforce better design?
PsiElement.getProject() normally returns non-null project unless it isn't
valid (psiElement.isValid() == false) so it cannot be documented as @NotNull
On the other hand annotating it as @Nullable will produce enormous amount
of false positives since in most cases we've ensured somehow already psiElement
is indeed valid.
throw InvalidPsiElementAccess exception instead of returning null.
First of all we can now document getProject() (and many others) as @NotNull,
plus we have better design with early real problem diagnostics instead of
getting NPE somewhere miles behind from the faulty code.
getParent() always returns @NotNull except forementioned validity problem
AND it is top-level PsiPackage or PsiDirectory, where @Nullable is perfectly
legal. Any ideas?
"Develop with pleasure!"