--- a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java Thu Oct 04 13:04:53 2012 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java Fri Oct 05 14:35:24 2012 +0100
@@ -87,6 +87,11 @@
*/
private final static String trimSequence = "[...]";
+ /**
+ * Max number of chars to be generated when output should fit into a single line
+ */
+ private final static int PREFERRED_LENGTH = 20;
+
/** Align code to be indented to left margin.
*/
void align() throws IOException {
@@ -135,6 +140,10 @@
out.write(lineSep);
}
+ public static String toSimpleString(JCTree tree) {
+ return toSimpleString(tree, PREFERRED_LENGTH);
+ }
+
public static String toSimpleString(JCTree tree, int maxLength) {
StringWriter s = new StringWriter();
try {
@@ -938,7 +947,16 @@
public void visitLambda(JCLambda tree) {
try {
print("(");
- printExprs(tree.params);
+ if (TreeInfo.isExplicitLambda(tree)) {
+ printExprs(tree.params);
+ } else {
+ String sep = "";
+ for (JCVariableDecl param : tree.params) {
+ print(sep);
+ print(param.name);
+ sep = ",";
+ }
+ }
print(")->");
printExpr(tree.body);
} catch (IOException e) {