ParenthesizedExpression added
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package org.jetbrains.jet.j2k.ast;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author ignatov
|
||||
*/
|
||||
public class ParenthesizedExpression extends Expression {
|
||||
private final Expression myExpression;
|
||||
|
||||
public ParenthesizedExpression(Expression expression) {
|
||||
myExpression = expression;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String toKotlin() {
|
||||
return "(" + myExpression.toKotlin() + ")";
|
||||
}
|
||||
}
|
||||
@@ -165,6 +165,9 @@ public class ExpressionVisitor extends StatementVisitor implements Visitor {
|
||||
@Override
|
||||
public void visitParenthesizedExpression(PsiParenthesizedExpression expression) {
|
||||
super.visitParenthesizedExpression(expression);
|
||||
myResult = new ParenthesizedExpression(
|
||||
expressionToExpression(expression.getExpression())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.jetbrains.jet.j2k.ast;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.jet.j2k.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author ignatov
|
||||
*/
|
||||
public class ParenthesizedExpressionTest extends JetTestCaseBase {
|
||||
public void testParenthesized() throws Exception {
|
||||
Assert.assertEquals(expressionToSingleLineKotlin("(1 + 2)"), "((1 + 2))");
|
||||
}
|
||||
|
||||
public void testParenthesized2() throws Exception {
|
||||
Assert.assertEquals(expressionToSingleLineKotlin("(o.toString() + \"abc\")"), "((o.toString() + \"abc\"))");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user