为什么 Eclipse JDT Null-Checking 尊重 Apache Commons Validate

Why does Eclipse JDT Null-Checking respect Apache Commons Validate

我将 @NonNull-Checking 与 Eclipse-JDT 一起使用,很高兴看到它理解并尊重 Apache Commons Validate 的使用。这意味着在代码中:

Validate.notNull(someInput);
@NonNull String a = someInput;

如果没有第一行,第二行会在 Eclipse 中产生警告。 如果 "assert" 应该被尊重,我只能配置。 但在没有任何进一步通知的情况下,它也尊重 Validate#notNull 和 Objects#requireNonNull。 这很好,但我想知道:

  1. 它是硬编码的还是可配置的(在某些插件、文件中...),frameworks/methods Eclipse 尊重适当的 Null 检查?
  2. 我可以编写自己的方法让 Eclipse 知道,某些变量保证是非空的吗?

该列表是硬编码的,无法扩展(除非通过修改源代码)。

org.eclipse.jdt.internal.compiler.lookuporg.eclipse.jdt.internal.compiler.ast 中涉及的一些主要 类,包括 TypeConstantsTypeIds 接口以及 ReferenceBindingMessageSend 类.