TODO fix: Remove dead code.
Use util method in CallType
This commit is contained in:
@@ -27,9 +27,9 @@ import org.jetbrains.jet.lang.psi.JetQualifiedExpression;
|
|||||||
import org.jetbrains.jet.lang.psi.JetSafeQualifiedExpression;
|
import org.jetbrains.jet.lang.psi.JetSafeQualifiedExpression;
|
||||||
import org.jetbrains.k2js.translate.context.TemporaryVariable;
|
import org.jetbrains.k2js.translate.context.TemporaryVariable;
|
||||||
import org.jetbrains.k2js.translate.context.TranslationContext;
|
import org.jetbrains.k2js.translate.context.TranslationContext;
|
||||||
|
import org.jetbrains.k2js.translate.utils.TranslationUtils;
|
||||||
|
|
||||||
import static com.google.dart.compiler.util.AstUtil.newSequence;
|
import static com.google.dart.compiler.util.AstUtil.newSequence;
|
||||||
import static org.jetbrains.k2js.translate.utils.JsAstUtils.inequality;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Pavel Talanov
|
* @author Pavel Talanov
|
||||||
@@ -42,11 +42,10 @@ public enum CallType {
|
|||||||
@NotNull TranslationContext context) {
|
@NotNull TranslationContext context) {
|
||||||
assert receiver != null;
|
assert receiver != null;
|
||||||
TemporaryVariable temporaryVariable = context.declareTemporary(receiver);
|
TemporaryVariable temporaryVariable = context.declareTemporary(receiver);
|
||||||
|
JsBinaryOperation notNullCheck = TranslationUtils.notNullCheck(context, temporaryVariable.reference());
|
||||||
JsNullLiteral nullLiteral = context.program().getNullLiteral();
|
JsNullLiteral nullLiteral = context.program().getNullLiteral();
|
||||||
//TODO: find similar not null checks
|
JsExpression methodCall = constructor.construct(temporaryVariable.reference());
|
||||||
JsBinaryOperation notNullCheck = inequality(temporaryVariable.reference(), nullLiteral);
|
JsConditional callMethodIfNotNullElseNull = new JsConditional(notNullCheck, methodCall, nullLiteral);
|
||||||
JsConditional callMethodIfNotNullElseNull =
|
|
||||||
new JsConditional(notNullCheck, constructor.construct(temporaryVariable.reference()), nullLiteral);
|
|
||||||
return newSequence(temporaryVariable.assignmentExpression(), callMethodIfNotNullElseNull);
|
return newSequence(temporaryVariable.assignmentExpression(), callMethodIfNotNullElseNull);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -73,14 +73,6 @@ public final class TranslationUtils {
|
|||||||
return Translation.translateAsExpression(jetExpression, context);
|
return Translation.translateAsExpression(jetExpression, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: refactor backing field reference generation to use the generic way
|
|
||||||
@NotNull
|
|
||||||
public static JsNameRef backingFieldReference(@NotNull TranslationContext context,
|
|
||||||
@NotNull JetProperty expression) {
|
|
||||||
PropertyDescriptor propertyDescriptor = getPropertyDescriptor(context.bindingContext(), expression);
|
|
||||||
return backingFieldReference(context, propertyDescriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static JsNameRef backingFieldReference(@NotNull TranslationContext context,
|
public static JsNameRef backingFieldReference(@NotNull TranslationContext context,
|
||||||
@NotNull PropertyDescriptor descriptor) {
|
@NotNull PropertyDescriptor descriptor) {
|
||||||
@@ -166,14 +158,6 @@ public final class TranslationUtils {
|
|||||||
return Translation.translateAsExpression(baseExpression, context);
|
return Translation.translateAsExpression(baseExpression, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO:
|
|
||||||
@NotNull
|
|
||||||
public static JsExpression translateReceiver(@NotNull TranslationContext context,
|
|
||||||
@NotNull JetDotQualifiedExpression expression) {
|
|
||||||
return Translation.translateAsExpression(expression.getReceiverExpression(), context);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static JsExpression translateLeftExpression(@NotNull TranslationContext context,
|
public static JsExpression translateLeftExpression(@NotNull TranslationContext context,
|
||||||
@NotNull JetBinaryExpression expression) {
|
@NotNull JetBinaryExpression expression) {
|
||||||
|
|||||||
Reference in New Issue
Block a user