ThrowStatement 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 ThrowStatement extends Expression {
|
||||
private final Expression myExpression;
|
||||
|
||||
public ThrowStatement(Expression expression) {
|
||||
myExpression = expression;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String toKotlin() {
|
||||
return "throw" + SPACE + myExpression.toKotlin();
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ public class StatementVisitor extends ElementVisitor implements Visitor {
|
||||
@Override
|
||||
public void visitAssertStatement(PsiAssertStatement statement) {
|
||||
super.visitAssertStatement(statement);
|
||||
|
||||
myResult = new AssertStatement(
|
||||
expressionToExpression(statement.getAssertCondition()),
|
||||
expressionToExpression(statement.getAssertDescription())
|
||||
@@ -96,7 +95,6 @@ public class StatementVisitor extends ElementVisitor implements Visitor {
|
||||
super.visitExpressionListStatement(statement);
|
||||
myResult =
|
||||
new ExpressionListStatement(expressionsToExpressionList(statement.getExpressionList().getExpressions()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -179,6 +177,9 @@ public class StatementVisitor extends ElementVisitor implements Visitor {
|
||||
@Override
|
||||
public void visitThrowStatement(PsiThrowStatement statement) {
|
||||
super.visitThrowStatement(statement);
|
||||
myResult = new ThrowStatement(
|
||||
expressionToExpression(statement.getException())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.jetbrains.jet.j2k.ast;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import org.jetbrains.jet.j2k.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author ignatov
|
||||
*/
|
||||
public class ThrowStatementTest extends JetTestCaseBase {
|
||||
public void testSimpleThrowStatement() throws Exception {
|
||||
Assert.assertEquals(
|
||||
statementToSingleLineKotlin("throw exception;"), "throw exception");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user