private void annotateMethod(ExecutableElement methodElt, AnnotatedExecutableType methodType) {
    if (checker.isChecking() || methodType.isAnnotated()) {
      return;
    }
    // First annotate the receiver
    annotateThis(methodType.getReceiverType());

    // If it is from library
    if (checker.isFromLibrary(methodElt)) {
      Set<AnnotationMirror> set = AnnotationUtils.createAnnotationSet();
      set.add(checker.PEER);
      annotateConstants(methodType, set);
    }
    // methodType.isAnnotated() only checks the annotations on methodType,
    // but not the type of its receiver, parameters or return;
    if (!methodType.isAnnotated()) methodType.addAnnotation(checker.BOTTOM);
  }
    @Override
    public Void visitExecutable(AnnotatedExecutableType t, ElementKind p) {
      // The following lines are from super class, except adding the
      // traverse of the receiver
      scan(t.getReceiverType(), p);
      scan(t.getReturnType(), p);
      scanAndReduce(t.getParameterTypes(), p, null);
      scanAndReduce(t.getThrownTypes(), p, null);
      scanAndReduce(t.getTypeVariables(), p, null);

      ExecutableElement elt = t.getElement();
      annotateMethod(elt, t);
      return null;
    }
예제 #3
0
 @Override
 public final R visitExecutable(AnnotatedExecutableType type, AnnotatedTypeMirror p) {
   assert p instanceof AnnotatedExecutableType : p;
   AnnotatedExecutableType ex = (AnnotatedExecutableType) p;
   R r = scan(type.getReturnType(), ex.getReturnType());
   r = scanAndReduce(type.getReceiverType(), ex.getReceiverType(), r);
   r = scanAndReduce(type.getParameterTypes(), ex.getParameterTypes(), r);
   r = scanAndReduce(type.getThrownTypes(), ex.getThrownTypes(), r);
   r = scanAndReduce(type.getTypeVariables(), ex.getTypeVariables(), r);
   return r;
 }