コード例 #1
0
ファイル: Pretty.java プロジェクト: Doublemine/TerminalIDE
 /**
  * Print unit consisting of package clause and import statements in toplevel, followed by class
  * definition. if class definition == null, print all definitions in toplevel.
  *
  * @param tree The toplevel tree
  * @param cdef The class definition, which is assumed to be part of the toplevel tree.
  */
 public void printUnit(JCCompilationUnit tree, JCClassDecl cdef) throws IOException {
   docComments = tree.docComments;
   printDocComment(tree);
   if (tree.pid != null) {
     print("package ");
     printExpr(tree.pid);
     print(";");
     println();
   }
   boolean firstImport = true;
   for (List<JCTree> l = tree.defs;
       l.nonEmpty() && (cdef == null || l.head.getTag() == JCTree.IMPORT);
       l = l.tail) {
     if (l.head.getTag() == JCTree.IMPORT) {
       JCImport imp = (JCImport) l.head;
       Name name = TreeInfo.name(imp.qualid);
       if (name == name.table.asterisk
           || cdef == null
           || isUsed(TreeInfo.symbol(imp.qualid), cdef)) {
         if (firstImport) {
           firstImport = false;
           println();
         }
         printStat(imp);
       }
     } else {
       printStat(l.head);
     }
   }
   if (cdef != null) {
     printStat(cdef);
     println();
   }
 }
コード例 #2
0
ファイル: Pretty.java プロジェクト: Doublemine/TerminalIDE
 public void visitBinary(JCBinary tree) {
   try {
     int ownprec = TreeInfo.opPrec(tree.getTag());
     String opname = operatorName(tree.getTag());
     open(prec, ownprec);
     printExpr(tree.lhs, ownprec);
     print(" " + opname + " ");
     printExpr(tree.rhs, ownprec + 1);
     close(prec, ownprec);
   } catch (IOException e) {
     throw new UncheckedIOException(e);
   }
 }
コード例 #3
0
ファイル: Pretty.java プロジェクト: Doublemine/TerminalIDE
 public void visitUnary(JCUnary tree) {
   try {
     int ownprec = TreeInfo.opPrec(tree.getTag());
     String opname = operatorName(tree.getTag());
     open(prec, ownprec);
     if (tree.getTag() <= JCTree.PREDEC) {
       print(opname);
       printExpr(tree.arg, ownprec);
     } else {
       printExpr(tree.arg, ownprec);
       print(opname);
     }
     close(prec, ownprec);
   } catch (IOException e) {
     throw new UncheckedIOException(e);
   }
 }
コード例 #4
0
ファイル: Pretty.java プロジェクト: Doublemine/TerminalIDE
 /** Print a set of modifiers. */
 public void printFlags(long flags) throws IOException {
   if ((flags & SYNTHETIC) != 0) print("/*synthetic*/ ");
   print(TreeInfo.flagNames(flags));
   if ((flags & StandardFlags) != 0) print(" ");
   if ((flags & ANNOTATION) != 0) print("@");
 }
コード例 #5
0
ファイル: Pretty.java プロジェクト: minixalpha/hack-javac
 // Prints the inner element type of a nested array
 private void printBaseElementType(JCTree tree) throws IOException {
   printExpr(TreeInfo.innermostType(tree));
 }