aboutsummaryrefslogtreecommitdiff
path: root/src/delombok
diff options
context:
space:
mode:
authorpeichhorn <peichhor@web.de>2011-07-14 10:38:16 +0200
committerpeichhorn <peichhor@web.de>2011-07-14 10:42:42 +0200
commit68b079d3129c8201fcffb898bf6155efdc393d0a (patch)
tree03f656204f303ab4aa0d13733de2bfc7a8a174ba /src/delombok
parent4b9a8142d0638d0098ec0e76cc791b65592f66c0 (diff)
downloadlombok-68b079d3129c8201fcffb898bf6155efdc393d0a.tar.gz
lombok-68b079d3129c8201fcffb898bf6155efdc393d0a.tar.bz2
lombok-68b079d3129c8201fcffb898bf6155efdc393d0a.zip
fixed Issue 233:
Javac parser handles ";" (empty statements) as empty blocks with an invalid position. Thats why delomok replaces ";" with "{}". This gets an issue when you use this in an interface, since interfaces are not allowed to have initializer blocks.
Diffstat (limited to 'src/delombok')
-rw-r--r--src/delombok/lombok/delombok/PrettyCommentsPrinter.java21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java
index edff8637..c0f61650 100644
--- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java
+++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java
@@ -103,6 +103,7 @@ import com.sun.tools.javac.tree.JCTree.TypeBoundKind;
import com.sun.tools.javac.util.Convert;
import com.sun.tools.javac.util.List;
import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Position;
/** Prints out a tree as an indented Java source program.
*
@@ -480,14 +481,18 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
/** Print a block.
*/
public void printBlock(List<? extends JCTree> stats, JCTree container) throws IOException {
- print("{");
- println();
- indent();
- printStats(stats);
- consumeComments(endPos(container));
- undent();
- align();
- print("}");
+ if ((Position.NOPOS == container.pos) && stats.isEmpty()) {
+ print(";");
+ } else {
+ print("{");
+ println();
+ indent();
+ printStats(stats);
+ consumeComments(endPos(container));
+ undent();
+ align();
+ print("}");
+ }
}
/** Print a block.