mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-144019 - NPE: NullableStuffInspectionBase.checkNonStandardAnnotations
GitOrigin-RevId: 8b17b61144c6c9966ad4b3af556521a5f5957701
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cab9f60b31
commit
7cd2f834e6
+2
-1
@@ -21,13 +21,14 @@ import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiAnnotation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class ChangeNullableDefaultsFix implements LocalQuickFix {
|
||||
private final NullableNotNullManager myManager;
|
||||
private final String myNotNullName;
|
||||
private final String myNullableName;
|
||||
|
||||
ChangeNullableDefaultsFix(PsiAnnotation notNull, PsiAnnotation nullable, NullableNotNullManager manager) {
|
||||
ChangeNullableDefaultsFix(@Nullable PsiAnnotation notNull, @Nullable PsiAnnotation nullable, @NotNull NullableNotNullManager manager) {
|
||||
myNotNullName = notNull != null ? notNull.getQualifiedName() : null;
|
||||
myNullableName = nullable != null ? nullable.getQualifiedName() : null;
|
||||
myManager = manager;
|
||||
|
||||
+3
-11
@@ -419,23 +419,15 @@ public class NullableStuffInspectionBase extends AbstractBaseJavaLocalInspection
|
||||
Annotated annotated,
|
||||
NullableNotNullManager manager, String anno, @NotNull ProblemsHolder holder) {
|
||||
if (!AnnotationUtil.isAnnotatingApplicable(field, anno)) {
|
||||
final PsiAnnotation notNull = AnnotationUtil.findAnnotation(field, manager.getNotNulls());
|
||||
final PsiAnnotation nullable = AnnotationUtil.findAnnotation(field, manager.getNullables());
|
||||
final PsiAnnotation annotation;
|
||||
String message = "Not \'";
|
||||
if (annotated.isDeclaredNullable) {
|
||||
message += nullable.getQualifiedName();
|
||||
annotation = nullable;
|
||||
} else {
|
||||
message += notNull.getQualifiedName();
|
||||
annotation = notNull;
|
||||
}
|
||||
PsiAnnotation annotation = Objects.requireNonNull(annotated.isDeclaredNullable ? annotated.nullable : annotated.notNull);
|
||||
message += annotation.getQualifiedName();
|
||||
message += "\' but \'" + anno + "\' would be used for code generation.";
|
||||
final PsiJavaCodeReferenceElement annotationNameReferenceElement = annotation.getNameReferenceElement();
|
||||
holder.registerProblem(annotationNameReferenceElement != null && annotationNameReferenceElement.isPhysical() ? annotationNameReferenceElement : field.getNameIdentifier(),
|
||||
message,
|
||||
ProblemHighlightType.WEAK_WARNING,
|
||||
new ChangeNullableDefaultsFix(notNull, nullable, manager));
|
||||
new ChangeNullableDefaultsFix(annotated.notNull, annotated.nullable, manager));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user