All RESOLVED_CALL getters replaced with util methods
JetElement.getResolvedCall(BindingContext) JetElement.getResolvedCallForSure(BindingContext)
This commit is contained in:
+2
-3
@@ -27,7 +27,7 @@ import org.jetbrains.jet.lang.psi.JetClassOrObject;
|
||||
import org.jetbrains.jet.lang.psi.JetDelegationSpecifier;
|
||||
import org.jetbrains.jet.lang.psi.JetDelegatorToSuperCall;
|
||||
import org.jetbrains.jet.lang.psi.JetParameter;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
@@ -124,8 +124,7 @@ public final class ClassInitializerTranslator extends AbstractTranslator {
|
||||
|
||||
@NotNull
|
||||
private List<JsExpression> translateArguments(@NotNull JetDelegatorToSuperCall superCall) {
|
||||
ResolvedCall<?> call = context().bindingContext().get(BindingContext.RESOLVED_CALL, superCall.getCalleeExpression());
|
||||
assert call != null : "ResolvedCall for superCall must be not null";
|
||||
ResolvedCall<?> call = BindingContextUtilPackage.getResolvedCallWithAssert(superCall, context().bindingContext());
|
||||
return CallArgumentTranslator.translate(call, null, context()).getTranslateArguments();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -37,10 +37,10 @@ import org.jetbrains.k2js.translate.utils.TranslationUtils;
|
||||
import org.jetbrains.k2js.translate.utils.mutator.AssignToExpressionMutator;
|
||||
import org.jetbrains.k2js.translate.utils.mutator.LastExpressionMutator;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage.getFunctionResolvedCallWithAssert;
|
||||
import static org.jetbrains.k2js.translate.operation.AssignmentTranslator.isAssignmentOperator;
|
||||
import static org.jetbrains.k2js.translate.operation.CompareToTranslator.isCompareToCall;
|
||||
import static org.jetbrains.k2js.translate.utils.BindingUtils.getCallableDescriptorForOperationExpression;
|
||||
import static org.jetbrains.k2js.translate.utils.BindingUtils.getFunctionResolvedCall;
|
||||
import static org.jetbrains.k2js.translate.utils.JsAstUtils.convertToStatement;
|
||||
import static org.jetbrains.k2js.translate.utils.JsAstUtils.not;
|
||||
import static org.jetbrains.k2js.translate.utils.PsiUtils.*;
|
||||
@@ -154,7 +154,7 @@ public final class BinaryOperationTranslator extends AbstractTranslator {
|
||||
|
||||
@NotNull
|
||||
private JsExpression translateAsOverloadedBinaryOperation() {
|
||||
ResolvedCall<? extends FunctionDescriptor> resolvedCall = getFunctionResolvedCall(bindingContext(), expression.getOperationReference());
|
||||
ResolvedCall<? extends FunctionDescriptor> resolvedCall = getFunctionResolvedCallWithAssert(expression, bindingContext());
|
||||
JsExpression result = CallTranslator.instance$.translate(context(), resolvedCall, getReceiver());
|
||||
return mayBeWrapWithNegation(result);
|
||||
}
|
||||
|
||||
+2
-2
@@ -20,10 +20,10 @@ import com.google.dart.compiler.backend.js.ast.JsExpression;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpression;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.k2js.translate.callTranslator.CallTranslator;
|
||||
import org.jetbrains.k2js.translate.context.TranslationContext;
|
||||
import org.jetbrains.k2js.translate.utils.BindingUtils;
|
||||
|
||||
public final class OverloadedAssignmentTranslator extends AssignmentTranslator {
|
||||
|
||||
@@ -39,7 +39,7 @@ public final class OverloadedAssignmentTranslator extends AssignmentTranslator {
|
||||
private OverloadedAssignmentTranslator(@NotNull JetBinaryExpression expression,
|
||||
@NotNull TranslationContext context) {
|
||||
super(expression, context);
|
||||
resolvedCall = BindingUtils.getFunctionResolvedCall(context.bindingContext(), expression.getOperationReference());
|
||||
resolvedCall = BindingContextUtilPackage.getFunctionResolvedCallWithAssert(expression, context.bindingContext());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+6
-4
@@ -20,20 +20,22 @@ import com.google.dart.compiler.backend.js.ast.JsExpression;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetUnaryExpression;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.k2js.translate.callTranslator.CallTranslator;
|
||||
import org.jetbrains.k2js.translate.context.TranslationContext;
|
||||
import org.jetbrains.k2js.translate.utils.BindingUtils;
|
||||
|
||||
public final class OverloadedIncrementTranslator extends IncrementTranslator {
|
||||
|
||||
@NotNull
|
||||
private final ResolvedCall<? extends FunctionDescriptor> resolvedCall;
|
||||
|
||||
/*package*/ OverloadedIncrementTranslator(@NotNull JetUnaryExpression expression,
|
||||
@NotNull TranslationContext context) {
|
||||
/*package*/ OverloadedIncrementTranslator(
|
||||
@NotNull JetUnaryExpression expression,
|
||||
@NotNull TranslationContext context
|
||||
) {
|
||||
super(expression, context);
|
||||
this.resolvedCall = BindingUtils.getFunctionResolvedCall(context.bindingContext(), expression.getOperationReference());
|
||||
this.resolvedCall = BindingContextUtilPackage.getFunctionResolvedCallWithAssert(expression, context.bindingContext());
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -32,8 +32,8 @@ import org.jetbrains.k2js.translate.callTranslator.CallTranslator;
|
||||
import org.jetbrains.k2js.translate.context.TranslationContext;
|
||||
import org.jetbrains.k2js.translate.utils.TranslationUtils;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage.getFunctionResolvedCallWithAssert;
|
||||
import static org.jetbrains.k2js.translate.general.Translation.translateAsExpression;
|
||||
import static org.jetbrains.k2js.translate.utils.BindingUtils.getFunctionResolvedCall;
|
||||
import static org.jetbrains.k2js.translate.utils.PsiUtils.getBaseExpression;
|
||||
import static org.jetbrains.k2js.translate.utils.PsiUtils.getOperationToken;
|
||||
import static org.jetbrains.k2js.translate.utils.TranslationUtils.*;
|
||||
@@ -64,7 +64,7 @@ public final class UnaryOperationTranslator {
|
||||
return translateExclForBinaryEqualLikeExpr((JsBinaryOperation) baseExpression);
|
||||
}
|
||||
|
||||
ResolvedCall<? extends FunctionDescriptor> resolvedCall = getFunctionResolvedCall(context.bindingContext(), expression.getOperationReference());
|
||||
ResolvedCall<? extends FunctionDescriptor> resolvedCall = getFunctionResolvedCallWithAssert(expression, context.bindingContext());
|
||||
return CallTranslator.instance$.translate(context, resolvedCall, baseExpression);
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -21,12 +21,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetCallExpression;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.k2js.translate.context.TranslationContext;
|
||||
import org.jetbrains.k2js.translate.general.AbstractTranslator;
|
||||
|
||||
import static org.jetbrains.k2js.translate.utils.BindingUtils.getResolvedCallForCallExpression;
|
||||
|
||||
public abstract class AbstractCallExpressionTranslator extends AbstractTranslator {
|
||||
|
||||
@NotNull
|
||||
@@ -43,7 +42,7 @@ public abstract class AbstractCallExpressionTranslator extends AbstractTranslato
|
||||
) {
|
||||
super(context);
|
||||
this.expression = expression;
|
||||
this.resolvedCall = getResolvedCallForCallExpression(bindingContext(), expression);
|
||||
this.resolvedCall = BindingContextUtilPackage.getFunctionResolvedCallWithAssert(expression, bindingContext());
|
||||
this.receiver = receiver;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ public final class InlinedCallExpressionTranslator extends AbstractCallExpressio
|
||||
@SuppressWarnings("UnusedParameters")
|
||||
public static boolean shouldBeInlined(@NotNull JetCallExpression expression, @NotNull TranslationContext context) {
|
||||
//TODO: inlining turned off
|
||||
//ResolvedCall<?> resolvedCall = getResolvedCallForCallExpression(context.bindingContext(), expression);
|
||||
//ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getFunctionResolvedCall(expression, bindingContext());
|
||||
//CallableDescriptor descriptor = resolvedCall.getCandidateDescriptor();
|
||||
//if (descriptor instanceof SimpleFunctionDescriptor) {
|
||||
// return ((SimpleFunctionDescriptor)descriptor).isInline();
|
||||
|
||||
+6
-2
@@ -21,12 +21,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetReferenceExpression;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.k2js.translate.callTranslator.CallTranslator;
|
||||
import org.jetbrains.k2js.translate.context.TemporaryVariable;
|
||||
import org.jetbrains.k2js.translate.context.TranslationContext;
|
||||
import org.jetbrains.k2js.translate.general.AbstractTranslator;
|
||||
import org.jetbrains.k2js.translate.utils.BindingUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -37,7 +38,10 @@ public class VariableAccessTranslator extends AbstractTranslator implements Acce
|
||||
@NotNull JetReferenceExpression referenceExpression,
|
||||
@Nullable JsExpression receiver
|
||||
) {
|
||||
ResolvedCall<?> resolvedCall = BindingUtils.getResolvedCallForProperty(context.bindingContext(), referenceExpression);
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCallWithAssert(referenceExpression, context.bindingContext());
|
||||
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
||||
resolvedCall = ((VariableAsFunctionResolvedCall) resolvedCall).getVariableCall();
|
||||
}
|
||||
assert resolvedCall.getResultingDescriptor() instanceof VariableDescriptor;
|
||||
return new VariableAccessTranslator(context, (ResolvedCall<? extends VariableDescriptor>) resolvedCall, receiver);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.constants.IntegerValueTypeConstant;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -136,39 +135,6 @@ public final class BindingUtils {
|
||||
return context.get(BindingContext.REFERENCE_TARGET, reference);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ResolvedCall<?> getResolvedCall(@NotNull BindingContext context, @NotNull JetExpression expression) {
|
||||
ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, expression);
|
||||
assert resolvedCall != null : message(expression, expression.getText() + " must resolve to a call");
|
||||
return resolvedCall;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ResolvedCall<?> getResolvedCallForProperty(@NotNull BindingContext context, @NotNull JetExpression expression) {
|
||||
ResolvedCall<?> resolvedCall = context.get(BindingContext.RESOLVED_CALL, expression);
|
||||
assert resolvedCall != null : message(expression, expression.getText() + " must resolve to a call");
|
||||
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
||||
return ((VariableAsFunctionResolvedCall) resolvedCall).getVariableCall();
|
||||
}
|
||||
return resolvedCall;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ResolvedCall<? extends FunctionDescriptor> getResolvedCallForCallExpression(@NotNull BindingContext context,
|
||||
@NotNull JetCallExpression expression) {
|
||||
JetExpression calleeExpression = PsiUtils.getCallee(expression);
|
||||
return getFunctionResolvedCall(context, calleeExpression);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ResolvedCall<? extends FunctionDescriptor> getFunctionResolvedCall(@NotNull BindingContext context,
|
||||
@NotNull JetExpression expression) {
|
||||
ResolvedCall<?> resolvedCall = getResolvedCall(context, expression);
|
||||
assert resolvedCall.getResultingDescriptor() instanceof FunctionDescriptor
|
||||
: message(expression, "ResolvedCall for this expression must be ResolvedCall<? extends FunctionDescriptor>");
|
||||
return (ResolvedCall<? extends FunctionDescriptor>) resolvedCall;
|
||||
}
|
||||
|
||||
public static boolean isVariableReassignment(@NotNull BindingContext context, @NotNull JetExpression expression) {
|
||||
return BindingContextUtils.getNotNull(context, BindingContext.VARIABLE_REASSIGNMENT, expression);
|
||||
}
|
||||
|
||||
@@ -93,13 +93,6 @@ public final class PsiUtils {
|
||||
return (binaryExpression.getOperationToken() == JetTokens.IN_KEYWORD);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetExpression getCallee(@NotNull JetCallExpression expression) {
|
||||
JetExpression calleeExpression = expression.getCalleeExpression();
|
||||
assert calleeExpression != null;
|
||||
return calleeExpression;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static JetExpression getLoopBody(@NotNull JetLoopExpression expression) {
|
||||
JetExpression body = expression.getBody();
|
||||
|
||||
Reference in New Issue
Block a user