576 if (tree.permitting.nonEmpty()) {
577 print(" permits ");
578 printExprs(tree.permitting);
579 }
580 }
581 print(" ");
582 if ((tree.mods.flags & ENUM) != 0) {
583 printEnumBody(tree.defs);
584 } else {
585 printBlock(tree.defs);
586 }
587 enclClassName = enclClassNamePrev;
588 } catch (IOException e) {
589 throw new UncheckedIOException(e);
590 }
591 }
592
593 public void visitMethodDef(JCMethodDecl tree) {
594 try {
595 // when producing source output, omit anonymous constructors
596 if (tree.name == tree.name.table.names.init &&
597 enclClassName == null &&
598 sourceOutput) return;
599 println(); align();
600 printDocComment(tree);
601 printExpr(tree.mods);
602 printTypeParameters(tree.typarams);
603 if (tree.name == tree.name.table.names.init) {
604 print(enclClassName != null ? enclClassName : tree.name);
605 } else {
606 printExpr(tree.restype);
607 print(" " + tree.name);
608 }
609 print("(");
610 if (tree.recvparam!=null) {
611 printExpr(tree.recvparam);
612 if (tree.params.size() > 0) {
613 print(", ");
614 }
615 }
616 printExprs(tree.params);
617 print(")");
618 if (tree.thrown.nonEmpty()) {
619 print(" throws ");
620 printExprs(tree.thrown);
621 }
622 if (tree.defaultValue != null) {
623 print(" default ");
716 }
717 }
718
719 public void visitSkip(JCSkip tree) {
720 try {
721 print(";");
722 } catch (IOException e) {
723 throw new UncheckedIOException(e);
724 }
725 }
726
727 public void visitBlock(JCBlock tree) {
728 try {
729 printFlags(tree.flags);
730 printBlock(tree.stats);
731 } catch (IOException e) {
732 throw new UncheckedIOException(e);
733 }
734 }
735
736 public void visitDoLoop(JCDoWhileLoop tree) {
737 try {
738 print("do ");
739 printStat(tree.body);
740 align();
741 print(" while ");
742 if (tree.cond.hasTag(PARENS)) {
743 printExpr(tree.cond);
744 } else {
745 print("(");
746 printExpr(tree.cond);
747 print(")");
748 }
749 print(";");
750 } catch (IOException e) {
751 throw new UncheckedIOException(e);
752 }
753 }
754
755 public void visitWhileLoop(JCWhileLoop tree) {
756 try {
757 print("while ");
758 if (tree.cond.hasTag(PARENS)) {
759 printExpr(tree.cond);
760 } else {
761 print("(");
762 printExpr(tree.cond);
763 print(")");
764 }
765 print(" ");
766 printStat(tree.body);
767 } catch (IOException e) {
768 throw new UncheckedIOException(e);
769 }
770 }
771
772 public void visitForLoop(JCForLoop tree) {
773 try {
774 print("for (");
775 if (tree.init.nonEmpty()) {
776 if (tree.init.head.hasTag(VARDEF)) {
777 printExpr(tree.init.head);
778 for (List<JCStatement> l = tree.init.tail; l.nonEmpty(); l = l.tail) {
779 JCVariableDecl vdef = (JCVariableDecl)l.head;
780 print(", " + vdef.name);
781 if (vdef.init != null) {
782 print(" = ");
783 printExpr(vdef.init);
784 }
785 }
786 } else {
787 printExprs(tree.init);
788 }
789 }
790 print("; ");
791 if (tree.cond != null) printExpr(tree.cond);
|
576 if (tree.permitting.nonEmpty()) {
577 print(" permits ");
578 printExprs(tree.permitting);
579 }
580 }
581 print(" ");
582 if ((tree.mods.flags & ENUM) != 0) {
583 printEnumBody(tree.defs);
584 } else {
585 printBlock(tree.defs);
586 }
587 enclClassName = enclClassNamePrev;
588 } catch (IOException e) {
589 throw new UncheckedIOException(e);
590 }
591 }
592
593 public void visitMethodDef(JCMethodDecl tree) {
594 try {
595 // when producing source output, omit anonymous constructors
596 if (tree.isInitOrVNew() &&
597 enclClassName == null &&
598 sourceOutput) return;
599 println(); align();
600 printDocComment(tree);
601 printExpr(tree.mods);
602 printTypeParameters(tree.typarams);
603 if (tree.isInitOrVNew()) {
604 print(enclClassName != null ? enclClassName : tree.name);
605 } else {
606 printExpr(tree.restype);
607 print(" " + tree.name);
608 }
609 print("(");
610 if (tree.recvparam!=null) {
611 printExpr(tree.recvparam);
612 if (tree.params.size() > 0) {
613 print(", ");
614 }
615 }
616 printExprs(tree.params);
617 print(")");
618 if (tree.thrown.nonEmpty()) {
619 print(" throws ");
620 printExprs(tree.thrown);
621 }
622 if (tree.defaultValue != null) {
623 print(" default ");
716 }
717 }
718
719 public void visitSkip(JCSkip tree) {
720 try {
721 print(";");
722 } catch (IOException e) {
723 throw new UncheckedIOException(e);
724 }
725 }
726
727 public void visitBlock(JCBlock tree) {
728 try {
729 printFlags(tree.flags);
730 printBlock(tree.stats);
731 } catch (IOException e) {
732 throw new UncheckedIOException(e);
733 }
734 }
735
736 public void visitDefaultValue(JCDefaultValue tree) {
737 try {
738 printExpr(tree.clazz, TreeInfo.postfixPrec);
739 print(".default");
740 } catch (IOException e) {
741 throw new UncheckedIOException(e);
742 }
743 }
744
745 public void visitDoLoop(JCDoWhileLoop tree) {
746 try {
747 print("do ");
748 printStat(tree.body);
749 align();
750 print(" while ");
751 if (tree.cond.hasTag(PARENS)) {
752 printExpr(tree.cond);
753 } else {
754 print("(");
755 printExpr(tree.cond);
756 print(")");
757 }
758 print(";");
759 } catch (IOException e) {
760 throw new UncheckedIOException(e);
761 }
762 }
763
764 public void visitWhileLoop(JCWhileLoop tree) {
765 try {
766 print("while ");
767 if (tree.cond.hasTag(PARENS)) {
768 printExpr(tree.cond);
769 } else {
770 print("(");
771 printExpr(tree.cond);
772 print(")");
773 }
774 print(" ");
775 printStat(tree.body);
776 } catch (IOException e) {
777 throw new UncheckedIOException(e);
778 }
779 }
780
781 public void visitWithField(JCWithField tree) {
782 try {
783 print("__WithField(");
784 printExpr(tree.field);
785 print(", ");
786 printExpr(tree.value);
787 print(")");
788 } catch (IOException e) {
789 throw new UncheckedIOException(e);
790 }
791 }
792
793 public void visitForLoop(JCForLoop tree) {
794 try {
795 print("for (");
796 if (tree.init.nonEmpty()) {
797 if (tree.init.head.hasTag(VARDEF)) {
798 printExpr(tree.init.head);
799 for (List<JCStatement> l = tree.init.tail; l.nonEmpty(); l = l.tail) {
800 JCVariableDecl vdef = (JCVariableDecl)l.head;
801 print(", " + vdef.name);
802 if (vdef.init != null) {
803 print(" = ");
804 printExpr(vdef.init);
805 }
806 }
807 } else {
808 printExprs(tree.init);
809 }
810 }
811 print("; ");
812 if (tree.cond != null) printExpr(tree.cond);
|