Beispiel #1
0
 public void visitVarDef(JCVariableDecl tree) {
   try {
     if (docComments != null && docComments.get(tree) != null) {
       println();
       align();
     }
     printDocComment(tree);
     if ((tree.mods.flags & ENUM) != 0) {
       print("/*public static final*/ ");
       print(tree.name);
       if (tree.init != null) {
         print(" /* = ");
         printExpr(tree.init);
         print(" */");
       }
     } else {
       printExpr(tree.mods);
       if ((tree.mods.flags & VARARGS) != 0) {
         printExpr(((JCArrayTypeTree) tree.vartype).elemtype);
         print("... " + tree.name);
       } else {
         printExpr(tree.vartype);
         print(" " + tree.name);
       }
       if (tree.init != null) {
         print(" = ");
         printExpr(tree.init);
       }
       if (prec == TreeInfo.notExpression) print(";");
     }
   } catch (IOException e) {
     throw new UncheckedIOException(e);
   }
 }
Beispiel #2
0
 /**
  * Print documentation comment, if it exists
  *
  * @param tree The tree for which a documentation comment should be printed.
  */
 public void printDocComment(JCTree tree) throws IOException {
   if (docComments != null) {
     String dc = docComments.get(tree);
     if (dc != null) {
       print("/**");
       println();
       int pos = 0;
       int endpos = lineEndPos(dc, pos);
       while (pos < dc.length()) {
         align();
         print(" *");
         if (pos < dc.length() && dc.charAt(pos) > ' ') print(" ");
         print(dc.substring(pos, endpos));
         println();
         pos = endpos + 1;
         endpos = lineEndPos(dc, pos);
       }
       align();
       print(" */");
       println();
       align();
     }
   }
 }