public interface Messager
Messager 为注解处理器提供了报告错误消息、警告和其他通知的方式。可以传递元素、注释和注解值以为消息提供位置提示。然而,这样的位置提示可能不可用或只是近似的。
- API 注意:
-
通过此接口中的方法“打印”的消息可能会或可能不会显示为文本输出到
System.out或System.err等位置。实现可以选择以不同的方式呈现此信息,例如在窗口中显示消息。 - 自从:
- 1.6
- 参见:
-
方法总结
修饰符和类型方法描述default voidprintError(CharSequence msg) 打印错误。default voidprintError(CharSequence msg, Element e) 在元素的位置打印错误。voidprintMessage(Diagnostic.Kind kind, CharSequence msg) 打印指定种类的消息。voidprintMessage(Diagnostic.Kind kind, CharSequence msg, Element e) 在元素的位置打印指定种类的消息。voidprintMessage(Diagnostic.Kind kind, CharSequence msg, Element e, AnnotationMirror a) 在注解元素的注释镜像位置打印指定类型的消息。voidprintMessage(Diagnostic.Kind kind, CharSequence msg, Element e, AnnotationMirror a, AnnotationValue v) 在注解元素的注解镜像中的注解值位置处打印指定类型的消息.default voidprintNote(CharSequence msg) 打印注释。default voidprintNote(CharSequence msg, Element e) 在元素的位置打印注释。default voidprintWarning(CharSequence msg) 打印警告。default voidprintWarning(CharSequence msg, Element e) 在元素的位置打印警告。
-
方法详情
-
printMessage
打印指定种类的消息。- 参数:
kind- 消息的种类msg- 消息,如果没有则为空字符串
-
printMessage
在元素的位置打印指定种类的消息。- 参数:
kind- 消息的种类msg- 消息,如果没有则为空字符串e- 用作位置提示的元素
-
printMessage
在注解元素的注释镜像位置打印指定类型的消息。- 参数:
kind- 消息的种类msg- 消息,如果没有则为空字符串e- 带注解的元素a- 用作位置提示的注释
-
printMessage
void printMessage(Diagnostic.Kind kind, CharSequence msg, Element e, AnnotationMirror a, AnnotationValue v) 在注解元素的注解镜像中的注解值位置处打印指定类型的消息.- 参数:
kind- 消息的种类msg- 消息,如果没有则为空字符串e- 带注解的元素a- 包含注解值的注释v- 用作位置提示的注解值
-
printError
打印错误。- 实现要求:
-
默认实现等同于
printMessage(Diagnostic.Kind.ERROR, msg)。 - 参数:
msg- 消息,如果没有则为空字符串- 自从:
- 18
-
printError
在元素的位置打印错误。- 实现要求:
-
默认实现相当于
printMessage(Diagnostic.Kind.ERROR, msg, e)。 - 参数:
msg- 消息,如果没有则为空字符串e- 用作位置提示的元素- 自从:
- 18
-
printWarning
打印警告。- 实现要求:
-
默认实现相当于
printMessage(Diagnostic.Kind.WARNING, msg)。 - 参数:
msg- 消息,如果没有则为空字符串- 自从:
- 18
-
printWarning
在元素的位置打印警告。- 实现要求:
-
默认实现相当于
printMessage(Diagnostic.Kind.WARNING, msg, e)。 - 参数:
msg- 消息,如果没有则为空字符串e- 用作位置提示的元素- 自从:
- 18
-
printNote
打印注释。- 实现要求:
-
默认实现等同于
printMessage(Diagnostic.Kind.NOTE, msg)。 - 参数:
msg- 消息,如果没有则为空字符串- 自从:
- 18
-
printNote
在元素的位置打印注释。- 实现要求:
-
默认实现相当于
printMessage(Diagnostic.Kind.NOTE, msg, e)。 - 参数:
msg- 消息,如果没有则为空字符串e- 用作位置提示的元素- 自从:
- 18
-