KT-893 Need to support another form of for loop

This commit is contained in:
ignatov
2011-12-30 15:48:40 +04:00
parent 153a26b653
commit 0e37d92bc0
3 changed files with 22 additions and 2 deletions
@@ -128,8 +128,7 @@ public class StatementVisitor extends ElementVisitor {
&& condition != null
&& update != null
&& update.getChildren().length == 1
&& update.getChildren()[0] instanceof PsiPostfixExpression
&& ((PsiPostfixExpression) update.getChildren()[0]).getOperationTokenType() == JavaTokenType.PLUSPLUS
&& isPlusPlusExpression(update.getChildren()[0])
&& operationTokenType != null
&& (operationTokenType == JavaTokenType.LT || operationTokenType == JavaTokenType.LE)
&& initialization.getFirstChild() != null
@@ -160,6 +159,10 @@ public class StatementVisitor extends ElementVisitor {
}
}
private static boolean isPlusPlusExpression(@NotNull PsiElement psiElement) {
return (psiElement instanceof PsiPostfixExpression && ((PsiPostfixExpression) psiElement).getOperationTokenType() == JavaTokenType.PLUSPLUS)
|| (psiElement instanceof PsiPrefixExpression && ((PsiPrefixExpression) psiElement).getOperationTokenType() == JavaTokenType.PLUSPLUS);
}
@Override
public void visitForeachStatement(@NotNull PsiForeachStatement statement) {
+9
View File
@@ -0,0 +1,9 @@
package demo;
class Test {
void test() {
for(int i = 0; i < 10; ++i) {
System.out.println(i)
}
}
}
+8
View File
@@ -0,0 +1,8 @@
package demo
open class Test() {
open fun test() : Unit {
for (i in 0..(10 - 1)) {
System.out?.println(i)
}
}
}