Class ErrorReporter


  • class ErrorReporter
    extends java.lang.Object
    Handle error reporting for an annotation processor.
    See Also:
    AutoValue
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean anyErrors  
      private javax.annotation.processing.Messager messager  
    • Constructor Summary

      Constructors 
      Constructor Description
      ErrorReporter​(javax.annotation.processing.ProcessingEnvironment processingEnv)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void abortIfAnyError()
      Abandon the processing of this class if any errors have been output.
      (package private) void abortWithError​(java.lang.String msg, javax.lang.model.element.Element e)
      Issue a compilation error and abandon the processing of this class.
      (package private) void reportError​(java.lang.String msg, javax.lang.model.element.Element e)
      Issue a compilation error.
      (package private) void reportNote​(java.lang.String msg, javax.lang.model.element.Element e)
      Issue a compilation note.
      (package private) void reportWarning​(java.lang.String msg, javax.lang.model.element.Element e)
      Issue a compilation warning.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • messager

        private final javax.annotation.processing.Messager messager
      • anyErrors

        private boolean anyErrors
    • Constructor Detail

      • ErrorReporter

        ErrorReporter​(javax.annotation.processing.ProcessingEnvironment processingEnv)
    • Method Detail

      • reportNote

        void reportNote​(java.lang.String msg,
                        javax.lang.model.element.Element e)
        Issue a compilation note.
        Parameters:
        msg - the text of the note
        e - the element to which it pertains
      • reportWarning

        void reportWarning​(java.lang.String msg,
                           javax.lang.model.element.Element e)
        Issue a compilation warning.
        Parameters:
        msg - the text of the warning
        e - the element to which it pertains
      • reportError

        void reportError​(java.lang.String msg,
                         javax.lang.model.element.Element e)
        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:
        msg - the text of the warning
        e - the element to which it pertains
      • abortWithError

        void abortWithError​(java.lang.String msg,
                            javax.lang.model.element.Element e)
        Issue a compilation error and abandon the processing of this class. This does not prevent the processing of other classes.
        Parameters:
        msg - the text of the error
        e - the element to which it pertains
      • abortIfAnyError

        void abortIfAnyError()
        Abandon the processing of this class if any errors have been output.