585 if (tree.permitting.nonEmpty()) {
586 print(" permits ");
587 printExprs(tree.permitting);
588 }
589 }
590 print(' ');
591 if ((tree.mods.flags & ENUM) != 0) {
592 printEnumBody(tree.defs);
593 } else {
594 printBlock(tree.defs);
595 }
596 enclClassName = enclClassNamePrev;
597 } catch (IOException e) {
598 throw new UncheckedIOException(e);
599 }
600 }
601
602 public void visitMethodDef(JCMethodDecl tree) {
603 try {
604 // when producing source output, omit anonymous constructors
605 if (tree.name == tree.name.table.names.init &&
606 enclClassName == null &&
607 sourceOutput) return;
608 println(); align();
609 printDocComment(tree);
610 printExpr(tree.mods);
611 printTypeParameters(tree.typarams);
612 if (tree.name == tree.name.table.names.init) {
613 print(enclClassName != null ? enclClassName : tree.name);
614 } else {
615 printExpr(tree.restype);
616 print(' ');
617 print(tree.name);
618 }
619 print('(');
620 if (tree.recvparam!=null) {
621 printExpr(tree.recvparam);
622 if (tree.params.size() > 0) {
623 print(", ");
624 }
625 }
626 printExprs(tree.params);
627 print(')');
628 if (tree.thrown.nonEmpty()) {
629 print(" throws ");
630 printExprs(tree.thrown);
631 }
632 if (tree.defaultValue != null) {
732 }
733 }
734
735 public void visitSkip(JCSkip tree) {
736 try {
737 print(';');
738 } catch (IOException e) {
739 throw new UncheckedIOException(e);
740 }
741 }
742
743 public void visitBlock(JCBlock tree) {
744 try {
745 printFlags(tree.flags);
746 printBlock(tree.stats);
747 } catch (IOException e) {
748 throw new UncheckedIOException(e);
749 }
750 }
751
752 public void visitDoLoop(JCDoWhileLoop tree) {
753 try {
754 print("do ");
755 printStat(tree.body);
756 align();
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 } catch (IOException e) {
767 throw new UncheckedIOException(e);
768 }
769 }
770
771 public void visitWhileLoop(JCWhileLoop tree) {
772 try {
773 print("while ");
774 if (tree.cond.hasTag(PARENS)) {
775 printExpr(tree.cond);
776 } else {
777 print('(');
778 printExpr(tree.cond);
779 print(')');
780 }
781 print(' ');
782 printStat(tree.body);
783 } catch (IOException e) {
784 throw new UncheckedIOException(e);
785 }
786 }
787
788 public void visitForLoop(JCForLoop tree) {
789 try {
790 print("for (");
791 if (tree.init.nonEmpty()) {
792 if (tree.init.head.hasTag(VARDEF)) {
793 printExpr(tree.init.head);
794 for (List<JCStatement> l = tree.init.tail; l.nonEmpty(); l = l.tail) {
795 JCVariableDecl vdef = (JCVariableDecl)l.head;
796 print(", ");
797 print(vdef.name);
798 if (vdef.init != null) {
799 print(" = ");
800 printExpr(vdef.init);
801 }
802 }
803 } else {
804 printExprs(tree.init);
805 }
806 }
807 print("; ");
|
585 if (tree.permitting.nonEmpty()) {
586 print(" permits ");
587 printExprs(tree.permitting);
588 }
589 }
590 print(' ');
591 if ((tree.mods.flags & ENUM) != 0) {
592 printEnumBody(tree.defs);
593 } else {
594 printBlock(tree.defs);
595 }
596 enclClassName = enclClassNamePrev;
597 } catch (IOException e) {
598 throw new UncheckedIOException(e);
599 }
600 }
601
602 public void visitMethodDef(JCMethodDecl tree) {
603 try {
604 // when producing source output, omit anonymous constructors
605 if (tree.isInitOrVNew() &&
606 enclClassName == null &&
607 sourceOutput) return;
608 println(); align();
609 printDocComment(tree);
610 printExpr(tree.mods);
611 printTypeParameters(tree.typarams);
612 if (tree.isInitOrVNew()) {
613 print(enclClassName != null ? enclClassName : tree.name);
614 } else {
615 printExpr(tree.restype);
616 print(' ');
617 print(tree.name);
618 }
619 print('(');
620 if (tree.recvparam!=null) {
621 printExpr(tree.recvparam);
622 if (tree.params.size() > 0) {
623 print(", ");
624 }
625 }
626 printExprs(tree.params);
627 print(')');
628 if (tree.thrown.nonEmpty()) {
629 print(" throws ");
630 printExprs(tree.thrown);
631 }
632 if (tree.defaultValue != null) {
732 }
733 }
734
735 public void visitSkip(JCSkip tree) {
736 try {
737 print(';');
738 } catch (IOException e) {
739 throw new UncheckedIOException(e);
740 }
741 }
742
743 public void visitBlock(JCBlock tree) {
744 try {
745 printFlags(tree.flags);
746 printBlock(tree.stats);
747 } catch (IOException e) {
748 throw new UncheckedIOException(e);
749 }
750 }
751
752 public void visitDefaultValue(JCDefaultValue tree) {
753 try {
754 printExpr(tree.clazz, TreeInfo.postfixPrec);
755 print(".default");
756 } catch (IOException e) {
757 throw new UncheckedIOException(e);
758 }
759 }
760
761 public void visitDoLoop(JCDoWhileLoop tree) {
762 try {
763 print("do ");
764 printStat(tree.body);
765 align();
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 } catch (IOException e) {
776 throw new UncheckedIOException(e);
777 }
778 }
779
780 public void visitWhileLoop(JCWhileLoop tree) {
781 try {
782 print("while ");
783 if (tree.cond.hasTag(PARENS)) {
784 printExpr(tree.cond);
785 } else {
786 print('(');
787 printExpr(tree.cond);
788 print(')');
789 }
790 print(' ');
791 printStat(tree.body);
792 } catch (IOException e) {
793 throw new UncheckedIOException(e);
794 }
795 }
796
797 public void visitWithField(JCWithField tree) {
798 try {
799 print("__WithField(");
800 printExpr(tree.field);
801 print(", ");
802 printExpr(tree.value);
803 print(")");
804 } catch (IOException e) {
805 throw new UncheckedIOException(e);
806 }
807 }
808
809 public void visitForLoop(JCForLoop tree) {
810 try {
811 print("for (");
812 if (tree.init.nonEmpty()) {
813 if (tree.init.head.hasTag(VARDEF)) {
814 printExpr(tree.init.head);
815 for (List<JCStatement> l = tree.init.tail; l.nonEmpty(); l = l.tail) {
816 JCVariableDecl vdef = (JCVariableDecl)l.head;
817 print(", ");
818 print(vdef.name);
819 if (vdef.init != null) {
820 print(" = ");
821 printExpr(vdef.init);
822 }
823 }
824 } else {
825 printExprs(tree.init);
826 }
827 }
828 print("; ");
|