From 68b079d3129c8201fcffb898bf6155efdc393d0a Mon Sep 17 00:00:00 2001 From: peichhorn Date: Thu, 14 Jul 2011 10:38:16 +0200 Subject: 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. --- .../lombok/delombok/PrettyCommentsPrinter.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/delombok') 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 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. -- cgit