Class AnnotationFileParser

    • Method Detail

      • annosInPackage

        public static java.util.Map<java.lang.String,​javax.lang.model.element.TypeElement> annosInPackage​(javax.lang.model.element.PackageElement packageElement)
        All annotations defined in the package (but not those nested within classes in the package). Keys are both fully-qualified and simple names.
        Parameters:
        packageElement - a package
        Returns:
        a map from annotation name to TypeElement
      • annosInType

        public static java.util.Map<java.lang.String,​javax.lang.model.element.TypeElement> annosInType​(javax.lang.model.element.TypeElement typeElement)
        All annotations declared (directly) within a class. Keys are both fully-qualified and simple names.
        Parameters:
        typeElement - a type
        Returns:
        a map from annotation name to TypeElement
      • createNameToAnnotationMap

        public static java.util.Map<java.lang.String,​javax.lang.model.element.TypeElement> createNameToAnnotationMap​(java.util.List<javax.lang.model.element.TypeElement> typeElements)
        All annotations declared within any of the given elements.
        Parameters:
        typeElements - the elements whose annotations to retrieve
        Returns:
        a map from annotation names (both fully-qualified and simple names) to TypeElement
      • parseStubFile

        public static void parseStubFile​(java.lang.String filename,
                                         java.io.InputStream inputStream,
                                         AnnotatedTypeFactory atypeFactory,
                                         javax.annotation.processing.ProcessingEnvironment processingEnv,
                                         AnnotationFileParser.AnnotationFileAnnotations annotationFileAnnos,
                                         AnnotationFileUtil.AnnotationFileType fileType,
                                         AnnotationFileElementTypes fileElementTypes)
        The main entry point. Parse a stub file and side-effects the annotationFileAnnos argument.
        Parameters:
        filename - name of stub file, used only for diagnostic messages
        inputStream - of stub file to parse
        atypeFactory - the type factory
        processingEnv - the processing environment
        annotationFileAnnos - annotations from the annotation file; side-effected by this method
        fileType - the annotation file type and source
        fileElementTypes - the manager that controls the stub file parsing process
      • parseAjavaFile

        public static void parseAjavaFile​(java.lang.String filename,
                                          java.io.InputStream inputStream,
                                          com.sun.source.tree.CompilationUnitTree root,
                                          AnnotatedTypeFactory atypeFactory,
                                          javax.annotation.processing.ProcessingEnvironment processingEnv,
                                          AnnotationFileParser.AnnotationFileAnnotations ajavaAnnos,
                                          AnnotationFileElementTypes fileElementTypes)
        The main entry point when parsing an ajava file. Parses an ajava file and side-effects the last two arguments.
        Parameters:
        filename - name of ajava file, used only for diagnostic messages
        inputStream - of ajava file to parse
        root - javac tree for the file to be parsed
        atypeFactory - the type factory
        processingEnv - the processing environment
        ajavaAnnos - annotations from the ajava file; side-effected by this method
        fileElementTypes - the manager that controls the stub file parsing process
      • parseJdkFileAsStub

        public static void parseJdkFileAsStub​(java.lang.String filename,
                                              java.io.InputStream inputStream,
                                              AnnotatedTypeFactory atypeFactory,
                                              javax.annotation.processing.ProcessingEnvironment processingEnv,
                                              AnnotationFileParser.AnnotationFileAnnotations stubAnnos,
                                              AnnotationFileElementTypes fileElementTypes)
        Parse a stub file that is a part of the annotated JDK and side-effects the stubAnnos argument.
        Parameters:
        filename - name of stub file, used only for diagnostic messages
        inputStream - of stub file to parse
        atypeFactory - the type factory
        processingEnv - the processing environment
        stubAnnos - annotations from the stub file; side-effected by this method
        fileElementTypes - the manager that controls the stub file parsing process
      • putIfAbsent

        public static <K,​V> void putIfAbsent​(java.util.Map<K,​V> m,
                                                   K key,
                                                   V value)
        Just like Map.put, but does not override any existing value in the map.
        Type Parameters:
        K - the key type
        V - the value type
        Parameters:
        m - a map
        key - a key
        value - the value to associate with the key, if the key isn't already in the map
      • putAllNew

        public static <K,​V> void putAllNew​(java.util.Map<K,​V> m,
                                                 java.util.Map<K,​V> m2)
        Just like Map.putAll, but modifies existing values using putIfAbsent(Map, Object, Object).
        Type Parameters:
        K - the key type for the maps
        V - the value type for the maps
        Parameters:
        m - the destination map
        m2 - the source map