new int[] {1, 2, 3} now converted to array(1, 2, 3)
This commit is contained in:
@@ -129,16 +129,10 @@ public class ExpressionVisitor extends StatementVisitor implements Visitor {
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitExpressionStatement(PsiExpressionStatement statement) {
|
||||
super.visitExpressionStatement(statement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitExpressionList(PsiExpressionList list) {
|
||||
super.visitExpressionList(list);
|
||||
myResult =
|
||||
new ExpressionList(expressionsToExpressionList(list.getExpressions()));
|
||||
myResult = new ExpressionList(expressionsToExpressionList(list.getExpressions()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -159,8 +153,7 @@ public class ExpressionVisitor extends StatementVisitor implements Visitor {
|
||||
@Override
|
||||
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
|
||||
super.visitMethodCallExpression(expression);
|
||||
// TODO: not resolved
|
||||
myResult =
|
||||
myResult = // TODO: not resolved
|
||||
new MethodCallExpression(
|
||||
expressionToExpression(expression.getMethodExpression()),
|
||||
elementToElement(expression.getArgumentList())
|
||||
@@ -175,6 +168,9 @@ public class ExpressionVisitor extends StatementVisitor implements Visitor {
|
||||
@Override
|
||||
public void visitNewExpression(PsiNewExpression expression) {
|
||||
super.visitNewExpression(expression);
|
||||
|
||||
if (expression.getArrayInitializer() != null) // new Foo[] {}
|
||||
myResult = expressionToExpression(expression.getArrayInitializer());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,10 +21,25 @@ public class ArrayInitializerExpressionTest extends JetTestCaseBase {
|
||||
);
|
||||
}
|
||||
|
||||
public void testNewInt() throws Exception {
|
||||
Assert.assertEquals(
|
||||
expressionToSingleLineKotlin("new int[] {1, 2, 3};"),
|
||||
"array(1, 2, 3)"
|
||||
);
|
||||
}
|
||||
|
||||
public void testTwoDim() throws Exception {
|
||||
Assert.assertEquals(
|
||||
expressionToSingleLineKotlin("{ {1, 2, 3}, {4, 5, 6}, {7, 8, 9} };"),
|
||||
"array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9))"
|
||||
);
|
||||
}
|
||||
|
||||
// TODO
|
||||
// public void testTwoDimNewInt() throws Exception {
|
||||
// Assert.assertEquals(
|
||||
// statementToSingleLineKotlin("int[][] myArray = new int[5][];"),
|
||||
// "array(1, 2, 3)"
|
||||
// );
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user