Example #1
0
 /**
  * Print a list of annotations on separate lines, ending with a newline.
  *
  * @param annotations list of {@link AnnotationExpr annotation expressions}
  * @param arg argument provided to the calling visitor method
  */
 private void printMemberAnnotations(List<AnnotationExpr> annotations, Object arg) {
   if (annotations != null) {
     for (AnnotationExpr a : annotations) {
       a.accept(this, arg);
       printer.printLn();
     }
   }
 }
Example #2
0
 /**
  * Print a list of annotations. The final parameter determines whether to issue a leading (if
  * true) or trailing (if false) space.
  *
  * @param annotations list of {@link AnnotationExpr annotation expressions}
  * @param arg argument provided to the calling visitor method
  * @param isOnReceiver whether annotation is on a method receiver
  */
 private void printAnnotations(
     List<AnnotationExpr> annotations, Object arg, boolean isOnReceiver) {
   if (annotations != null) {
     Iterator<AnnotationExpr> i = annotations.iterator();
     if (i.hasNext()) {
       AnnotationExpr a = i.next();
       if (isOnReceiver) {
         printer.print(" ");
       }
       a.accept(this, arg);
       while (i.hasNext()) {
         printer.print(" ");
         a = i.next();
         a.accept(this, arg);
       }
       if (!isOnReceiver) {
         printer.print(" ");
       }
     }
   }
 }
  /**
   * Builds simplified annotation from its declaration. Only the name is included, because stubfiles
   * do not generally have access to the full definitions of annotations.
   *
   * @param expr
   * @return
   */
  private static Annotation extractAnnotation(AnnotationExpr expr) {
    // String exprName = expr.getName().getName();
    String exprName = expr.toString().substring(1); // 1 for '@'
    // String exprName = resolve(expr.getName().getName());

    // Eliminate jdk.Profile+Annotation, a synthetic annotation that
    // the JDK adds, apparently for profiling.
    if (exprName.contains("+")) {
      return null;
    }
    AnnotationDef def = new AnnotationDef(exprName);
    def.setFieldTypes(Collections.<String, AnnotationFieldType>emptyMap());
    return new Annotation(def, Collections.<String, Object>emptyMap());
  }