boolean (PsiElement element) { if (!PsiUtil.isLanguageLevel7OrHigher(element)) { return false; } if (!(element instanceof PsiReferenceExpression referenceExpression)) { return false; } if (PsiUtil.isAccessedForWriting(referenceExpression)) { return false; } final PsiElement target = referenceExpression.resolve(); if (!(target instanceof PsiVariable variable)) { return false; } if (ClassUtils.findClass("java.util.Objects", element) == null) { return false; } final NullabilityAnnotationInfo info = NullableNotNullManager.getInstance(variable.getProject()).findEffectiveNullabilityInfo(variable); if (info != null && info.getNullability() == Nullability.NOT_NULL && !info.isExternal() && !info.isInferred()) { return true; } final PsiStatement referenceStatement = PsiTreeUtil.getParentOfType(referenceExpression, PsiStatement.class); final PsiElement parent = referenceStatement != null ? referenceStatement.getParent() : null; if (!(parent instanceof PsiCodeBlock codeBlock)) { return false; } final PsiStatement[] statements = codeBlock.getStatements(); for (PsiStatement statement : statements) { if (statement == referenceStatement) { return false; } if (isNotNullAssertion(statement, variable) || isIfStatementNullCheck(statement, variable)) { return true; } } return false; }