src/share/classes/com/sun/tools/javac/tree/Pretty.java

changeset 1348
573ceb23beeb
parent 1347
1408af4cd8b0
child 1357
c75be5bc5283
     1.1 --- a/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Thu Oct 04 13:04:53 2012 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Fri Oct 05 14:35:24 2012 +0100
     1.3 @@ -87,6 +87,11 @@
     1.4       */
     1.5      private final static String trimSequence = "[...]";
     1.6  
     1.7 +    /**
     1.8 +     * Max number of chars to be generated when output should fit into a single line
     1.9 +     */
    1.10 +    private final static int PREFERRED_LENGTH = 20;
    1.11 +
    1.12      /** Align code to be indented to left margin.
    1.13       */
    1.14      void align() throws IOException {
    1.15 @@ -135,6 +140,10 @@
    1.16          out.write(lineSep);
    1.17      }
    1.18  
    1.19 +    public static String toSimpleString(JCTree tree) {
    1.20 +        return toSimpleString(tree, PREFERRED_LENGTH);
    1.21 +    }
    1.22 +
    1.23      public static String toSimpleString(JCTree tree, int maxLength) {
    1.24          StringWriter s = new StringWriter();
    1.25          try {
    1.26 @@ -938,7 +947,16 @@
    1.27      public void visitLambda(JCLambda tree) {
    1.28          try {
    1.29              print("(");
    1.30 -            printExprs(tree.params);
    1.31 +            if (TreeInfo.isExplicitLambda(tree)) {
    1.32 +                printExprs(tree.params);
    1.33 +            } else {
    1.34 +                String sep = "";
    1.35 +                for (JCVariableDecl param : tree.params) {
    1.36 +                    print(sep);
    1.37 +                    print(param.name);
    1.38 +                    sep = ",";
    1.39 +                }
    1.40 +            }
    1.41              print(")->");
    1.42              printExpr(tree.body);
    1.43          } catch (IOException e) {

mercurial