diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2010-01-07 22:53:06 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2010-01-07 23:47:46 +0100 |
commit | e94bf546f3bdb37dbc442804d3819c83bd4f69c5 (patch) | |
tree | 66ccfeb251471d724238b7d4e5b61f775d549622 /src/delombok/lombok | |
parent | 24be0f86adba532b0a002e6594c4d150e6cb84ab (diff) | |
download | lombok-e94bf546f3bdb37dbc442804d3819c83bd4f69c5.tar.gz lombok-e94bf546f3bdb37dbc442804d3819c83bd4f69c5.tar.bz2 lombok-e94bf546f3bdb37dbc442804d3819c83bd4f69c5.zip |
Fixing javac's PrettyPrinter's screwup on enum members with bodies or parameters.
Note that JDK7 fixed this themselves though they kept the silly comments.
Diffstat (limited to 'src/delombok/lombok')
-rw-r--r-- | src/delombok/lombok/delombok/PrettyCommentsPrinter.java | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java index 1d04bb5f..a7c79f46 100644 --- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java +++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java @@ -521,6 +521,22 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { print("}"); } + public void printEnumMember(JCVariableDecl tree) throws IOException { + print(tree.name); + if (tree.init instanceof JCNewClass) { + JCNewClass constructor = (JCNewClass) tree.init; + if (constructor.args != null && constructor.args.nonEmpty()) { + print("("); + printExprs(constructor.args); + print(")"); + } + if (constructor.def != null && constructor.def.defs != null) { + print(" "); + printBlock(constructor.def.defs, constructor.def); + } + } + } + /** Is the given tree an enumerator definition? */ boolean isEnumerator(JCTree t) { return getTag(t) == JCTree.VARDEF && (((JCVariableDecl) t).mods.flags & ENUM) != 0; @@ -693,13 +709,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { } printDocComment(tree); if ((tree.mods.flags & ENUM) != 0) { - print("/*public static final*/ "); - print(tree.name); - if (tree.init != null) { - print(" /* = "); - printExpr(tree.init); - print(" */"); - } + printEnumMember(tree); } else { printExpr(tree.mods); if ((tree.mods.flags & VARARGS) != 0) { |