diff options
author | peichhorn <peichhor@web.de> | 2011-07-25 07:24:44 +0200 |
---|---|---|
committer | peichhorn <peichhor@web.de> | 2011-07-25 07:24:44 +0200 |
commit | b325214e82e7d65dde32e197ab932ba5cd0b43c6 (patch) | |
tree | 277fb78b03363cba24a27d41d6277662bece9680 /src/delombok/lombok | |
parent | 05d4168e3a64eb510e2793c219fe20d2555f7a47 (diff) | |
download | lombok-b325214e82e7d65dde32e197ab932ba5cd0b43c6.tar.gz lombok-b325214e82e7d65dde32e197ab932ba5cd0b43c6.tar.bz2 lombok-b325214e82e7d65dde32e197ab932ba5cd0b43c6.zip |
The previous commit to fix Issue 233 accidentally broke delombok for emtpy method bodies. This is now fixed.
Diffstat (limited to 'src/delombok/lombok')
-rw-r--r-- | src/delombok/lombok/delombok/PrettyCommentsPrinter.java | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java index c0f61650..d3710bab 100644 --- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java +++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java @@ -384,9 +384,23 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { /** Derived visitor method: print statement tree. */ public void printStat(JCTree tree) throws IOException { - printExpr(tree, TreeInfo.notExpression); + if (isEmptyStat(tree)) { + printEmptyStat(); + } else { + printExpr(tree, TreeInfo.notExpression); + } } + public void printEmptyStat() throws IOException { + print(";"); + } + + public boolean isEmptyStat(JCTree tree) { + if (!(tree instanceof JCBlock)) return false; + JCBlock block = (JCBlock) tree; + return (Position.NOPOS == block.pos) && block.stats.isEmpty(); + } + /** Derived visitor method: print list of expression trees, separated by given string. * @param sep the separator string */ @@ -481,18 +495,14 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { /** Print a block. */ public void printBlock(List<? extends JCTree> stats, JCTree container) throws IOException { - if ((Position.NOPOS == container.pos) && stats.isEmpty()) { - print(";"); - } else { - print("{"); - println(); - indent(); - printStats(stats); - consumeComments(endPos(container)); - undent(); - align(); - print("}"); - } + print("{"); + println(); + indent(); + printStats(stats); + consumeComments(endPos(container)); + undent(); + align(); + print("}"); } /** Print a block. @@ -722,7 +732,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { } if (tree.body != null) { print(" "); - printStat(tree.body); + printBlock(tree.body.stats, tree.body); } else { print(";"); } |