Class MethodApplier


  • public class MethodApplier
    extends java.lang.Object
    Adds annotations from element to the return type, formal parameter types, type parameters, and throws clauses of the AnnotatedExecutableType type.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected javax.lang.model.element.Element element
      An Element that type represents.
      protected AnnotatedTypeMirror type
      The type to which we wish to apply annotations.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean accepts​(AnnotatedTypeMirror typeMirror, javax.lang.model.element.Element element)  
      protected com.sun.tools.javac.code.TargetType[] annotatedTargets()
      Returns receiver, returns, and throws.
      static void apply​(AnnotatedTypeMirror type, javax.lang.model.element.Element element, AnnotatedTypeFactory atypeFactory)
      Apply annotations from element to type.
      void extractAndApply()
      Sets the method's element, annotates its return type, parameters, type parameters, and throws annotations.
      protected java.lang.Iterable<com.sun.tools.javac.code.Attribute.TypeCompound> getRawTypeAttributes()
      Returns the annotations on the method symbol (element).
      protected void handleInvalid​(java.util.List<com.sun.tools.javac.code.Attribute.TypeCompound> invalid)
      This implementation reports all invalid annotations as errors.
      protected void handleTargeted​(java.util.List<com.sun.tools.javac.code.Attribute.TypeCompound> targeted)
      This method should apply all annotations that are handled by this object.
      protected void handleValid​(java.util.List<com.sun.tools.javac.code.Attribute.TypeCompound> valid)
      The default implementation of this method does nothing.
      protected boolean isAccepted()
      Tests element/type fields to ensure that this TargetedElementAnnotationApplier is valid for this element/type pair.
      protected java.util.Map<org.checkerframework.framework.util.element.TargetedElementAnnotationApplier.TargetClass,​java.util.List<com.sun.tools.javac.code.Attribute.TypeCompound>> sift​(java.lang.Iterable<com.sun.tools.javac.code.Attribute.TypeCompound> typeCompounds)
      Separate the input annotations into a Map of TargetClass (TARGETED, VALID, INVALID) to the annotations that fall into each of those categories.
      protected com.sun.tools.javac.code.TargetType[] validTargets()
      Returns all possible annotation positions for a method except those in annotatedTargets.
      • Methods inherited from class java.lang.Object

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

      • type

        protected final AnnotatedTypeMirror type
        The type to which we wish to apply annotations.
      • element

        protected final javax.lang.model.element.Element element
        An Element that type represents.
    • Method Detail

      • accepts

        public static boolean accepts​(AnnotatedTypeMirror typeMirror,
                                      javax.lang.model.element.Element element)
      • annotatedTargets

        protected com.sun.tools.javac.code.TargetType[] annotatedTargets()
        Returns receiver, returns, and throws. See extract and apply as we also annotate type params.
        Returns:
        receiver, returns, and throws
      • validTargets

        protected com.sun.tools.javac.code.TargetType[] validTargets()
        Returns all possible annotation positions for a method except those in annotatedTargets.
        Returns:
        all possible annotation positions for a method except those in annotatedTargets
      • getRawTypeAttributes

        protected java.lang.Iterable<com.sun.tools.javac.code.Attribute.TypeCompound> getRawTypeAttributes()
        Returns the annotations on the method symbol (element).
        Returns:
        the annotations on the method symbol (element)
      • isAccepted

        protected boolean isAccepted()
        Tests element/type fields to ensure that this TargetedElementAnnotationApplier is valid for this element/type pair.
        Returns:
        true if the type/element members are handled by this class false otherwise
      • handleValid

        protected void handleValid​(java.util.List<com.sun.tools.javac.code.Attribute.TypeCompound> valid)
        The default implementation of this method does nothing.
        Parameters:
        valid - the list of annotations that were returned by getRawTypeAttributes and had a TargetType contained by valid and NOT annotatedTargets
      • handleInvalid

        protected void handleInvalid​(java.util.List<com.sun.tools.javac.code.Attribute.TypeCompound> invalid)
        This implementation reports all invalid annotations as errors.
        Parameters:
        invalid - the list of annotations that were returned by getRawTypeAttributes and were not handled by handleTargeted or handleValid
      • sift

        protected java.util.Map<org.checkerframework.framework.util.element.TargetedElementAnnotationApplier.TargetClass,​java.util.List<com.sun.tools.javac.code.Attribute.TypeCompound>> sift​(java.lang.Iterable<com.sun.tools.javac.code.Attribute.TypeCompound> typeCompounds)
        Separate the input annotations into a Map of TargetClass (TARGETED, VALID, INVALID) to the annotations that fall into each of those categories.
        Parameters:
        typeCompounds - annotations to sift through, should be those returned by getRawTypeAttributes
        Returns:
        a Map<TargetClass => Annotations>.