this statement added

This commit is contained in:
Sergey Ignatov
2011-11-07 19:23:45 +04:00
parent 35a6c1973a
commit fd7fde1058
6 changed files with 61 additions and 2 deletions
@@ -0,0 +1,22 @@
package org.jetbrains.jet.j2k.ast;
import org.jetbrains.annotations.NotNull;
/**
* @author ignatov
*/
public class ThisExpression extends Expression {
private Identifier myIdentifier;
public ThisExpression(Identifier identifier) {
myIdentifier = identifier;
}
@NotNull
@Override
public String toKotlin() {
if (myIdentifier.isEmpty())
return "this";
return "this" + AT + myIdentifier.toKotlin();
}
}
@@ -193,7 +193,7 @@ public class ExpressionVisitor extends StatementVisitor implements Visitor {
myResult = new NewClassExpression(
elementToElement(expression.getClassOrAnonymousClassReference()),
elementToElement(expression.getArgumentList()),
expression.getAnonymousClass() != null?
expression.getAnonymousClass() != null ?
anonymousClassToAnonymousClass(expression.getAnonymousClass()) :
null
);
@@ -239,13 +239,24 @@ public class ExpressionVisitor extends StatementVisitor implements Visitor {
@Override
public void visitSuperExpression(PsiSuperExpression expression) {
super.visitSuperExpression(expression);
final PsiJavaCodeReferenceElement qualifier = expression.getQualifier();
myResult = new SuperExpression(
expression.getQualifier() != null ? new IdentifierImpl(expression.getQualifier().getQualifiedName()): Identifier.EMPTY_IDENTIFIER);
qualifier != null ?
new IdentifierImpl(qualifier.getQualifiedName()) :
Identifier.EMPTY_IDENTIFIER
);
}
@Override
public void visitThisExpression(PsiThisExpression expression) {
super.visitThisExpression(expression);
final PsiJavaCodeReferenceElement qualifier = expression.getQualifier();
myResult = new ThisExpression(
qualifier != null ?
new IdentifierImpl(qualifier.getQualifiedName()) :
Identifier.EMPTY_IDENTIFIER
);
}
@Override
@@ -0,0 +1,11 @@
class Base {
void foo() {}
}
class A extends Base {
class C {
void test() {
A.this.foo();
}
}
}
@@ -0,0 +1,13 @@
namespace {
open class Base {
fun foo() : Unit {
}
}
open class A : Base {
open class C {
fun test() : Unit {
this@A.foo()
}
}
}
}
@@ -0,0 +1 @@
super.call();
@@ -0,0 +1 @@
super.call()