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.
This commit is contained in:
peichhorn
2011-07-14 10:42:42 +02:00
parent 4b9a8142d0
commit 68b079d312
5 changed files with 31 additions and 9 deletions
@@ -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.
+1
View File
@@ -3,6 +3,7 @@ enum Ranks {
HEARTS,
DIAMONDS,
SPADES;
;
}
enum Complex {
RED("ff0000"),
@@ -1,5 +1,13 @@
@SuppressWarnings("all")
interface Interfaces {
enum Ranks {
CLUBS,
HEARTS,
DIAMONDS,
SPADES;
}
;
;
int x = 10;
void y();
int a = 20;
+1 -1
View File
@@ -1,5 +1,5 @@
enum Ranks {
CLUBS, HEARTS, DIAMONDS, SPADES
CLUBS, HEARTS, DIAMONDS, SPADES;;
}
enum Complex {
@@ -1,5 +1,13 @@
@SuppressWarnings("all")
interface Interfaces {
enum Ranks {
CLUBS,
HEARTS,
DIAMONDS,
SPADES;
}
;
;
int x = 10;
void y();
public static final int a = 20;