Top Description Fields Constructors Methods
com.google.auto.value.processor

pack-priv Class ErrorReporter

extends Object
Class Inheritance
Imports
com.google.errorprone.annotations.FormatMethod, javax.annotation.processing.Messager, javax.annotation.processing.ProcessingEnvironment, javax.lang.model.element.Element, javax.tools.Diagnostic

Handle error reporting for an annotation processor.
Author
Éamonn McManus

Field Summary

Modifier and TypeField and Description
private int
private final javax.annotation.processing.Messager

Constructor Summary

AccessConstructor and Description
pack-priv
ErrorReporter(javax.annotation.processing.ProcessingEnvironment processingEnv)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
abortIfAnyError()

Abandon the processing of this class if any errors have been output.

pack-priv AbortProcessingException

Returns:

This method does not return, but is declared with an exception return type so you can write throw abortWithError(...) to tell the compiler that.
abortWithError
(javax.lang.model.element.Element
the element to which it pertains
e
,
String
the format string for the text of the error
format
,
Object...
arguments for the format string
args
)

Issue a compilation error and abandon the processing of this class.

pack-priv int
errorCount()

The number of errors that have been output by calls to reportError.

pack-priv void
reportError(javax.lang.model.element.Element
the element to which it pertains
e
,
String
the format string for the text of the warning
format
,
Object...
arguments for the format string
args
)

Issue a compilation error.

pack-priv void
reportNote(javax.lang.model.element.Element
the element to which it pertains
e
,
String
the format string for the text of the note
format
,
Object...
arguments for the format string
args
)

Issue a compilation note.

pack-priv void
reportWarning(javax.lang.model.element.Element
the element to which it pertains
e
,
String
the format string for the text of the warning
format
,
Object...
arguments for the format string
args
)

Issue a compilation warning.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

errorCountback to summary
private int errorCount
messagerback to summary
private final javax.annotation.processing.Messager messager

Constructor Detail

ErrorReporterback to summary
pack-priv ErrorReporter(javax.annotation.processing.ProcessingEnvironment processingEnv)

Method Detail

abortIfAnyErrorback to summary
pack-priv void abortIfAnyError()

Abandon the processing of this class if any errors have been output.

abortWithErrorback to summary
pack-priv AbortProcessingException abortWithError(javax.lang.model.element.Element e, String format, Object... args)

Issue a compilation error and abandon the processing of this class. This does not prevent the processing of other classes.

Parameters
e:javax.lang.model.element.Element

the element to which it pertains

format:String

the format string for the text of the error

args:Object[]

arguments for the format string

Returns:AbortProcessingException

This method does not return, but is declared with an exception return type so you can write throw abortWithError(...) to tell the compiler that.

Annotations
@FormatMethod
Exceptions
AbortProcessingException:
always
errorCountback to summary
pack-priv int errorCount()

The number of errors that have been output by calls to reportError.

reportErrorback to summary
pack-priv void reportError(javax.lang.model.element.Element e, String format, Object... args)

Issue a compilation error. This method does not throw an exception, since we want to continue processing and perhaps report other errors. It is a good idea to introduce a test case in CompilationTest for any new call to reportError(...) to ensure that we continue correctly after an error.

Parameters
e:javax.lang.model.element.Element

the element to which it pertains

format:String

the format string for the text of the warning

args:Object[]

arguments for the format string

Annotations
@FormatMethod
reportNoteback to summary
pack-priv void reportNote(javax.lang.model.element.Element e, String format, Object... args)

Issue a compilation note.

Parameters
e:javax.lang.model.element.Element

the element to which it pertains

format:String

the format string for the text of the note

args:Object[]

arguments for the format string

Annotations
@FormatMethod
reportWarningback to summary
pack-priv void reportWarning(javax.lang.model.element.Element e, String format, Object... args)

Issue a compilation warning.

Parameters
e:javax.lang.model.element.Element

the element to which it pertains

format:String

the format string for the text of the warning

args:Object[]

arguments for the format string

Annotations
@FormatMethod