NullabilityAnnotationInfo (@NotNull PsiAnnotation anno, @NotNull PsiElement context, PsiAnnotation.TargetType @NotNull [] types, boolean superPackage) { if (superPackage) return null; String name = anno.getQualifiedName(); if (name == null) return null; if (ArrayUtil.contains(PsiAnnotation.TargetType.LOCAL_VARIABLE, types)) return null; Nullability nullability; switch (name) { case DEFAULT_NOT_NULL -> nullability = Nullability.NOT_NULL; case DEFAULT_NULLNESS_UNKNOWN -> nullability = Nullability.UNKNOWN; default -> { return null; } } PsiType targetType = null; if (context instanceof PsiMethod) { targetType = ((PsiMethod)context).getReturnType(); } else if (context instanceof PsiVariable) { targetType = ((PsiVariable)context).getType(); } if (PsiUtil.resolveClassInClassTypeOnly(targetType) instanceof PsiTypeParameter) return null; return new NullabilityAnnotationInfo(anno, nullability, true); }