Class CommentHasStringValueProcessor

  • All Implemented Interfaces:
    javax.annotation.processing.Processor

    @SupportedAnnotationTypes("org.antlr.v4.test.runtime.CommentHasStringValue")
    @SupportedSourceVersion(RELEASE_7)
    public class CommentHasStringValueProcessor
    extends javax.annotation.processing.AbstractProcessor
    I think I figured out how to use annotation processors in maven. It's more or less automatic and you don't even need to tell maven, with one minor exception. The idea is to create a project for the annotation and another for the annotation processor. Then, a project that uses the annotation can simply set up the dependency on the other projects. You have to turn off processing, -proc:none on the processor project itself but other than that, java 6+ more or less tries to apply any processors it finds during compilation. maven just works. Also you need a META-INF/services/javax.annotation.processing.Processor file with "org.antlr.v4.test.runtime.CommentHasStringValueProcessor" in it.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected com.sun.tools.javac.tree.TreeMaker treeMaker  
      protected com.sun.tools.javac.model.JavacElements utilities  
      • Fields inherited from class javax.annotation.processing.AbstractProcessor

        processingEnv
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static com.sun.tools.javac.util.Context extractContext​(com.sun.tools.javac.model.JavacElements utilities)  
      javax.lang.model.SourceVersion getSupportedSourceVersion()  
      void init​(javax.annotation.processing.ProcessingEnvironment processingEnv)  
      boolean process​(java.util.Set<? extends javax.lang.model.element.TypeElement> annotations, javax.annotation.processing.RoundEnvironment roundEnv)  
      • Methods inherited from class javax.annotation.processing.AbstractProcessor

        getCompletions, getSupportedAnnotationTypes, getSupportedOptions, isInitialized
      • Methods inherited from class java.lang.Object

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

      • utilities

        protected com.sun.tools.javac.model.JavacElements utilities
      • treeMaker

        protected com.sun.tools.javac.tree.TreeMaker treeMaker
    • Constructor Detail

      • CommentHasStringValueProcessor

        public CommentHasStringValueProcessor()
    • Method Detail

      • init

        public void init​(javax.annotation.processing.ProcessingEnvironment processingEnv)
        Specified by:
        init in interface javax.annotation.processing.Processor
        Overrides:
        init in class javax.annotation.processing.AbstractProcessor
      • extractContext

        private static com.sun.tools.javac.util.Context extractContext​(com.sun.tools.javac.model.JavacElements utilities)
      • process

        public boolean process​(java.util.Set<? extends javax.lang.model.element.TypeElement> annotations,
                               javax.annotation.processing.RoundEnvironment roundEnv)
        Specified by:
        process in interface javax.annotation.processing.Processor
        Specified by:
        process in class javax.annotation.processing.AbstractProcessor
      • getSupportedSourceVersion

        public javax.lang.model.SourceVersion getSupportedSourceVersion()
        Specified by:
        getSupportedSourceVersion in interface javax.annotation.processing.Processor
        Overrides:
        getSupportedSourceVersion in class javax.annotation.processing.AbstractProcessor