private static @CheckForNull
    TypeQualifierAnnotation getDefaultTypeQualifierAnnotationForParameters(XMethod xmethod,
            TypeQualifierValue<?> typeQualifierValue, boolean stopAtMethodScope) {

        if (xmethod.isSynthetic())
        {
            return null; // synthetic methods don't get default annotations
        }
        // System.out.println("Looking for default " + typeQualifierValue +
        // " annotation of parameters of " + xmethod);
        if ("<init>".equals(xmethod.getName()) && xmethod.getClassDescriptor().isAnonymousClass())
        {
            return null; // constructors for anonymous inner classes don't get
            // default annotations
        }

        /** private methods don't inherit from class or package scope */
        if (xmethod.isPrivate()) {
            stopAtMethodScope = true;
        }

        boolean stopAtClassScope = false;

        if (!xmethod.isPublic() && !xmethod.isProtected() && (xmethod.isStatic() || "<init>".equals(xmethod.getName()))) {
            try {
                XClass xclass = Global.getAnalysisCache().getClassAnalysis(XClass.class, xmethod.getClassDescriptor());
                stopAtClassScope = xclass.isPrivate();
            } catch (CheckedAnalysisException e) {
                AnalysisContext.logError("Problem resolving class for " + xmethod, e);
            }
        }

        AnnotatedObject o = xmethod;
        while (true) {
            if (o == null) {
                return null;
            }

            if (stopAtMethodScope && o instanceof XClass) {
                return null;
            }
            // Check for direct type qualifier annotation
            Set<TypeQualifierAnnotation> applications = new HashSet<>();
            getDirectApplications(applications, o, ElementType.PARAMETER);
            TypeQualifierAnnotation tqa = findMatchingTypeQualifierAnnotation(applications, typeQualifierValue);
            if (tqa != null) {
                // Found matching annotation in outer scope
                assert false : "I think this code is dead; it shouldn't find anything";
            return tqa;
            }
            // Check for default annotation
            tqa = getDefaultAnnotation(o, typeQualifierValue, ElementType.PARAMETER);
            if (tqa != null) {
                if (DEBUG) {
                    System.out.println("Found default of " + tqa + " @ " + o);
                }
                return tqa;
            }
            if (stopAtClassScope && o instanceof XClass) {
                return null;
            }

            o = o.getContainingScope();

        }

    }
private static @ CheckForNull TypeQualifierAnnotation getDefaultTypeQualifierAnnotationForParameters ( XMethod xmethod , TypeQualifierValue < ? > typeQualifierValue , boolean stopAtMethodScope ) { if ( xmethod . isSynthetic ( ) ) { return null ; } if ( "<init>" . equals ( xmethod . getName ( ) ) && xmethod . getClassDescriptor ( ) . isAnonymousClass ( ) ) { return null ; } if ( xmethod . isPrivate ( ) ) { stopAtMethodScope = true ; } boolean stopAtClassScope = false ; if ( ! xmethod . isPublic ( ) && ! xmethod . isProtected ( ) && ( xmethod . isStatic ( ) || "<init>" . equals ( xmethod . getName ( ) ) ) ) { try { XClass xclass = Global . getAnalysisCache ( ) . getClassAnalysis ( XClass . class , xmethod . getClassDescriptor ( ) ) ; stopAtClassScope = xclass . isPrivate ( ) ; } catch ( CheckedAnalysisException e ) { AnalysisContext . logError ( "Problem resolving class for " + xmethod , e ) ; } } AnnotatedObject o = xmethod ; while ( true ) { if ( o == null ) { return null ; } if ( stopAtMethodScope && o instanceof XClass ) { return null ; } Set < TypeQualifierAnnotation > applications = new HashSet < > ( ) ; getDirectApplications ( applications , o , ElementType . PARAMETER ) ; TypeQualifierAnnotation tqa = findMatchingTypeQualifierAnnotation ( applications , typeQualifierValue ) ; if ( tqa != null ) { assert false : "I think this code is dead; it shouldn't find anything" ; return tqa ; } tqa = getDefaultAnnotation ( o , typeQualifierValue , ElementType . PARAMETER ) ; if ( tqa != null ) { if ( DEBUG ) { System . out . println ( "Found default of " + tqa + " @ " + o ) ; } return tqa ; } if ( stopAtClassScope && o instanceof XClass ) { return null ; } o = o . getContainingScope ( ) ; } }
Get the default (outer-scope) TypeQualifierAnnotation on given method
parameter.

@param xmethod
a method
@param typeQualifierValue
the kind of TypeQualifierValue we are looking for
@param stopAtMethodScope
@return the default (outer scope) TypeQualifierAnnotation on the
parameter, or null if there is no default TypeQualifierAnnotation