KT-879 Translate witches, wizards, gnomes correctly, also don't forget about switch statement

This commit is contained in:
ignatov
2011-12-29 14:01:13 +04:00
parent 14eea7bd17
commit fe839d5025
4 changed files with 41 additions and 2 deletions
@@ -17,7 +17,7 @@ public class CaseContainer extends Statement {
myCaseStatement = caseStatement;
List<Statement> newStatements = new LinkedList<Statement>();
for (Statement s : statements)
if (s.getKind() != Kind.BREAK && s.getKind() != Kind.CONTINUE )
if (s.getKind() != Kind.BREAK && s.getKind() != Kind.CONTINUE)
newStatements.add(s);
myBlock = new Block(newStatements);
}
@@ -261,7 +261,7 @@ public class StatementVisitor extends ElementVisitor {
List<PsiStatement> result = new LinkedList<PsiStatement>();
for (int i = start; i < allStatements.size(); i++) {
PsiStatement s = allStatements.get(i);
if (s instanceof PsiBreakStatement)
if (s instanceof PsiBreakStatement || s instanceof PsiReturnStatement)
return result;
if (!(s instanceof PsiSwitchLabelStatement))
result.add(s);
+16
View File
@@ -0,0 +1,16 @@
class Test {
public static int getInt(int i) {
switch (i) {
case 0:
return 0;
case 1:
return 1;
case 2:
return 2;
case 3:
return 3;
default:
return -1;
}
}
}
+23
View File
@@ -0,0 +1,23 @@
open class Test() {
class object {
open public fun getInt(i : Int) : Int {
when (i) {
0 -> {
return 0
}
1 -> {
return 1
}
2 -> {
return 2
}
3 -> {
return 3
}
else -> {
return (-1)
}
}
}
}
}