mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 12:16:49 +00:00
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.
This commit is contained in:
1 parent
24be0f86ad
commit
e94bf546f3
1 file changed
+17
-7
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user