Skip to content

Commit

Permalink
Add better switch rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
timowest committed Oct 3, 2013
1 parent c2413b5 commit 7709aed
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Expand Up @@ -1077,7 +1077,7 @@ class ScalaDumpVisitor(settings: ConversionSettings) extends VoidVisitor[ScalaDu
}

def visit(n: BlockStmt, arg: Context) {
if (!isEmpty(n.getStmts) && n.getStmts.get(0).isInstanceOf[SwitchStmt]) {
if (!isEmpty(n.getStmts) && n.getStmts.size == 1 && n.getStmts.get(0).isInstanceOf[SwitchStmt]) {
n.getStmts.get(0).accept(this, arg)
return
}
Expand Down
29 changes: 29 additions & 0 deletions scalagen/src/test/scala/com/mysema/examples/Switch.java
@@ -0,0 +1,29 @@
package com.mysema.examples;

public class Switch {

public static void method1() {
switch (42) {
default: System.out.println(42);
}
System.out.println("Hello World!");
}

public static void method2() {
System.out.println("Hello World!");
switch (42) {
default: System.out.println(42);
}
}

public static void method3() {
switch (42) {
default: System.out.println(42);
}
}

public static void method4() {
System.out.println("Hello World!");
}

}

0 comments on commit 7709aed

Please sign in to comment.