Refactoring: moved methods to call util
This commit is contained in:
@@ -45,7 +45,7 @@ import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind.DELEGATION;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage.getResolvedCall;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage.getResolvedCall;
|
||||
|
||||
public abstract class AnnotationCodegen {
|
||||
|
||||
|
||||
@@ -81,8 +81,7 @@ import static org.jetbrains.jet.lang.psi.PsiPackage.JetPsiFactory;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.getNotNull;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.isVarCapturedInClosure;
|
||||
import static org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage.getResolvedCall;
|
||||
import static org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage.getResolvedCallWithAssert;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage.*;
|
||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.*;
|
||||
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass;
|
||||
import static org.jetbrains.jet.lang.resolve.java.diagnostics.DiagnosticsPackage.OtherOrigin;
|
||||
|
||||
@@ -44,8 +44,8 @@ import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DeclarationResolver;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.DefaultValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ExpressionValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
@@ -75,7 +75,7 @@ import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
||||
import static org.jetbrains.jet.descriptors.serialization.NameSerializationUtil.createNameResolver;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.*;
|
||||
import static org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage.getResolvedCallWithAssert;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage.getResolvedCallWithAssert;
|
||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.*;
|
||||
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass;
|
||||
import static org.jetbrains.jet.lang.resolve.java.diagnostics.DiagnosticsPackage.DelegationToTraitImpl;
|
||||
@@ -1360,7 +1360,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
private PropertyDescriptor getDelegatePropertyIfAny(JetExpression expression) {
|
||||
PropertyDescriptor propertyDescriptor = null;
|
||||
if (expression instanceof JetSimpleNameExpression) {
|
||||
ResolvedCall<?> call = BindingContextUtilPackage.getResolvedCall(expression, bindingContext);
|
||||
ResolvedCall<?> call = CallUtilPackage.getResolvedCall(expression, bindingContext);
|
||||
if (call != null) {
|
||||
CallableDescriptor callResultingDescriptor = call.getResultingDescriptor();
|
||||
if (callResultingDescriptor instanceof ValueParameterDescriptor) {
|
||||
@@ -1549,7 +1549,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
) {
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
|
||||
ResolvedCall<?> resolvedCall = getResolvedCallWithAssert(superCall, bindingContext);
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCallWithAssert(superCall, bindingContext);
|
||||
ConstructorDescriptor superConstructor = (ConstructorDescriptor) resolvedCall.getResultingDescriptor();
|
||||
|
||||
CallableMethod superCallable = typeMapper.mapToCallableMethod(superConstructor);
|
||||
@@ -1701,7 +1701,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
throw new UnsupportedOperationException("unsupported type of enum constant initializer: " + specifier);
|
||||
}
|
||||
|
||||
ResolvedCall<?> resolvedCall = getResolvedCallWithAssert(specifier, bindingContext);
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCallWithAssert(specifier, bindingContext);
|
||||
|
||||
CallableMethod method = typeMapper.mapToCallableMethod((ConstructorDescriptor) resolvedCall.getResultingDescriptor());
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.TAIL_RECURSION_CALL;
|
||||
import static org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage.getResolvedCall;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage.getResolvedCall;
|
||||
|
||||
public class TailRecursionCodegen {
|
||||
|
||||
|
||||
+3
-3
@@ -34,7 +34,7 @@ import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ExpressionValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedValueArgument;
|
||||
@@ -323,7 +323,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
||||
// working around a problem with shallow analysis
|
||||
if (functionDescriptor == null) return;
|
||||
|
||||
ResolvedCall<?> referencedFunction = BindingContextUtilPackage.getResolvedCall(expression.getCallableReference(), bindingContext);
|
||||
ResolvedCall<?> referencedFunction = CallUtilPackage.getResolvedCall(expression.getCallableReference(), bindingContext);
|
||||
if (referencedFunction == null) return;
|
||||
Collection<JetType> supertypes =
|
||||
runtimeTypes.getSupertypesForFunctionReference((FunctionDescriptor) referencedFunction.getResultingDescriptor());
|
||||
@@ -414,7 +414,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
|
||||
@Override
|
||||
public void visitCallExpression(@NotNull JetCallExpression expression) {
|
||||
super.visitCallExpression(expression);
|
||||
ResolvedCall<?> call = BindingContextUtilPackage.getResolvedCall(expression, bindingContext);
|
||||
ResolvedCall<?> call = CallUtilPackage.getResolvedCall(expression, bindingContext);
|
||||
if (call == null) return;
|
||||
|
||||
CallableDescriptor descriptor = call.getResultingDescriptor();
|
||||
|
||||
@@ -44,7 +44,7 @@ import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.codegen.JvmCodegenUtil.isInterface;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||
import static org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage.getResolvedCall;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage.getResolvedCall;
|
||||
|
||||
public class CodegenBinding {
|
||||
public static final WritableSlice<ClassDescriptor, MutableClosure> CLOSURE = Slices.createSimpleSlice();
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage.getResolvedCallWithAssert;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage.getResolvedCallWithAssert;
|
||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
|
||||
|
||||
public class Clone extends IntrinsicMethod {
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage.getResolvedCallWithAssert;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage.getResolvedCallWithAssert;
|
||||
|
||||
public class JavaClassArray extends IntrinsicMethod {
|
||||
@NotNull
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
@@ -45,7 +45,7 @@ public class JavaClassFunction extends IntrinsicMethod {
|
||||
@Nullable List<JetExpression> arguments,
|
||||
StackValue receiver
|
||||
) {
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCallWithAssert(
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCallWithAssert(
|
||||
(JetElement) element, codegen.getBindingContext());
|
||||
JetType returnType = resolvedCall.getResultingDescriptor().getReturnType();
|
||||
assert returnType != null;
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage.getResolvedCallWithAssert;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage.getResolvedCallWithAssert;
|
||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
|
||||
|
||||
public class MonitorInstruction extends IntrinsicMethod {
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.CompileTimeConstantUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.*;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
@@ -55,7 +56,7 @@ import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.cfg.JetControlFlowBuilder.PredefinedOperation.*;
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
import static org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage.getResolvedCall;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage.getResolvedCall;
|
||||
import static org.jetbrains.jet.lexer.JetTokens.*;
|
||||
|
||||
public class JetControlFlowProcessor {
|
||||
|
||||
@@ -70,8 +70,8 @@ import static org.jetbrains.jet.lang.cfg.pseudocodeTraverser.TraversalOrder.FORW
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.CAPTURED_IN_CLOSURE;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.TAIL_RECURSION_CALL;
|
||||
import static org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage.getResolvedCall;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.TailRecursionKind.*;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage.getResolvedCall;
|
||||
import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE;
|
||||
import static org.jetbrains.jet.lang.types.TypeUtils.noExpectedType;
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ import org.jetbrains.jet.JetNodeTypes
|
||||
import java.math.BigInteger
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||
|
||||
public class ConstantExpressionEvaluator private (val trace: BindingTrace) : JetVisitor<CompileTimeConstant<*>, JetType>() {
|
||||
|
||||
|
||||
@@ -318,15 +318,4 @@ public fun JetSimpleNameExpression.isImportDirectiveExpression(): Boolean {
|
||||
}
|
||||
}
|
||||
|
||||
public fun JetElement.getCalleeExpressionIfAny(): JetExpression? {
|
||||
val element = if (this is JetExpression) JetPsiUtil.safeDeparenthesize(this, false) else this
|
||||
return when (element) {
|
||||
is JetSimpleNameExpression -> element
|
||||
is JetCallElement -> element.getCalleeExpression()
|
||||
is JetQualifiedExpression -> element.getSelectorExpression()?.getCalleeExpressionIfAny()
|
||||
is JetOperationExpression -> element.getOperationReference()
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
public fun JetElement.getTextWithLocation(): String = "'${this.getText()}' at ${DiagnosticUtils.atLocation(this)}"
|
||||
public fun JetElement.getTextWithLocation(): String = "'${this.getText()}' at ${DiagnosticUtils.atLocation(this)}"
|
||||
@@ -30,10 +30,10 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationsImpl;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.evaluate.ConstantExpressionEvaluator;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.ArgumentTypeResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
|
||||
@@ -325,7 +325,7 @@ public class AnnotationResolver {
|
||||
@NotNull JetCallExpression expression,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(expression, trace.getBindingContext());
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCall(expression, trace.getBindingContext());
|
||||
if (resolvedCall == null || !CompileTimeConstantUtils.isArrayMethodCall(resolvedCall)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -158,7 +158,7 @@ public class BindingContextUtils {
|
||||
@NotNull BindingContext context
|
||||
) {
|
||||
if (expression instanceof JetCallExpression) {
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(expression, context);
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCall(expression, context);
|
||||
return resolvedCall instanceof VariableAsFunctionResolvedCall;
|
||||
}
|
||||
return expression instanceof JetReferenceExpression;
|
||||
|
||||
@@ -16,13 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.bindingContextUtil
|
||||
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import org.jetbrains.jet.lang.psi.Call
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil
|
||||
import org.jetbrains.jet.lang.psi.JetCallExpression
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext.CALL
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext.RESOLVED_CALL
|
||||
import org.jetbrains.jet.lang.psi.JetReturnExpression
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext.LABEL_TARGET
|
||||
@@ -32,104 +26,8 @@ import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
|
||||
import org.jetbrains.jet.lang.psi.JetDeclarationWithBody
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.calls.ArgumentTypeResolver
|
||||
import org.jetbrains.jet.lang.psi.JetArrayAccessExpression
|
||||
import org.jetbrains.jet.lang.psi.JetUnaryExpression
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpression
|
||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.jet.lang.psi.JetThisExpression
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import org.jetbrains.jet.lang.psi.JetElement
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.getCalleeExpressionIfAny
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallTransformer.CallForImplicitInvoke
|
||||
import org.jetbrains.kotlin.util.sure
|
||||
import org.jetbrains.jet.lang.psi.JetCallElement
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.getTextWithLocation
|
||||
import org.jetbrains.jet.lang.psi.JetInstanceExpressionWithLabel
|
||||
import org.jetbrains.jet.lang.psi.JetConstructorCalleeExpression
|
||||
import org.jetbrains.jet.lang.psi.JetUserType
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
|
||||
/**
|
||||
* For expressions like <code>a(), a[i], a.b.c(), +a, a + b, (a()), a(): Int, @label a()</code>
|
||||
* returns a corresponding call.
|
||||
*
|
||||
* Note: special construction like <code>a!!, a ?: b, if (c) a else b</code> are resolved as calls,
|
||||
* so there is a corresponding call for them.
|
||||
*/
|
||||
public fun JetElement.getCall(context: BindingContext): Call? {
|
||||
val element = if (this is JetExpression) JetPsiUtil.deparenthesize(this) else this
|
||||
if (element == null) return null
|
||||
|
||||
val parent = element.getParent()
|
||||
val reference = when {
|
||||
parent is JetInstanceExpressionWithLabel -> parent : JetInstanceExpressionWithLabel
|
||||
parent is JetUserType -> parent.getParent()?.getParent() as? JetConstructorCalleeExpression
|
||||
else -> element.getCalleeExpressionIfAny()
|
||||
}
|
||||
if (reference != null) {
|
||||
return context[CALL, reference]
|
||||
}
|
||||
return context[CALL, element]
|
||||
}
|
||||
|
||||
public fun JetElement.getParentCall(context: BindingContext, strict: Boolean = true): Call? {
|
||||
val callExpressionTypes = array<Class<out JetElement>?>(
|
||||
javaClass<JetSimpleNameExpression>(), javaClass<JetCallElement>(), javaClass<JetBinaryExpression>(),
|
||||
javaClass<JetUnaryExpression>(), javaClass<JetArrayAccessExpression>())
|
||||
|
||||
val parent = if (strict) {
|
||||
PsiTreeUtil.getParentOfType(this, *callExpressionTypes)
|
||||
} else {
|
||||
PsiTreeUtil.getNonStrictParentOfType(this, *callExpressionTypes)
|
||||
}
|
||||
return parent?.getCall(context)
|
||||
}
|
||||
|
||||
public fun Call?.getResolvedCall(context: BindingContext): ResolvedCall<out CallableDescriptor>? {
|
||||
return context[RESOLVED_CALL, this]
|
||||
}
|
||||
|
||||
public fun JetElement?.getResolvedCall(context: BindingContext): ResolvedCall<out CallableDescriptor>? {
|
||||
return this?.getCall(context)?.getResolvedCall(context)
|
||||
}
|
||||
|
||||
public fun JetElement?.getParentResolvedCall(context: BindingContext, strict: Boolean = true): ResolvedCall<out CallableDescriptor>? {
|
||||
return this?.getParentCall(context, strict)?.getResolvedCall(context)
|
||||
}
|
||||
|
||||
public fun JetElement.getCallWithAssert(context: BindingContext): Call {
|
||||
return getCall(context).sure("No call for ${this.getTextWithLocation()}")
|
||||
}
|
||||
|
||||
public fun JetElement.getResolvedCallWithAssert(context: BindingContext): ResolvedCall<out CallableDescriptor> {
|
||||
return getResolvedCall(context).sure("No resolved call for ${this.getTextWithLocation()}")
|
||||
}
|
||||
|
||||
public fun Call.getResolvedCallWithAssert(context: BindingContext): ResolvedCall<out CallableDescriptor> {
|
||||
return getResolvedCall(context).sure("No resolved call for ${this.getCallElement().getTextWithLocation()}")
|
||||
}
|
||||
|
||||
public fun JetExpression.getFunctionResolvedCallWithAssert(context: BindingContext): ResolvedCall<out FunctionDescriptor> {
|
||||
val resolvedCall = getResolvedCallWithAssert(context)
|
||||
assert(resolvedCall.getResultingDescriptor() is FunctionDescriptor) {
|
||||
"ResolvedCall for this expression must be ResolvedCall<? extends FunctionDescriptor>: ${this.getTextWithLocation()}"
|
||||
}
|
||||
[suppress("UNCHECKED_CAST")]
|
||||
return resolvedCall as ResolvedCall<out FunctionDescriptor>
|
||||
}
|
||||
|
||||
public fun Call.hasUnresolvedArguments(context: BindingContext): Boolean {
|
||||
val arguments = getValueArguments().map { it?.getArgumentExpression() }
|
||||
return arguments.any {
|
||||
argument ->
|
||||
val expressionType = context[BindingContext.EXPRESSION_TYPE, argument]
|
||||
argument != null && !ArgumentTypeResolver.isFunctionLiteralArgument(argument)
|
||||
&& (expressionType == null || expressionType.isError())
|
||||
}
|
||||
}
|
||||
|
||||
public fun JetReturnExpression.getTargetFunctionDescriptor(context: BindingContext): FunctionDescriptor? {
|
||||
val targetLabel = getTargetLabel()
|
||||
|
||||
@@ -47,8 +47,8 @@ import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
import static org.jetbrains.jet.lang.psi.PsiPackage.JetPsiFactory;
|
||||
import static org.jetbrains.jet.lang.psi.psiUtil.PsiUtilPackage.getCalleeExpressionIfAny;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage.getCalleeExpressionIfAny;
|
||||
import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE;
|
||||
import static org.jetbrains.jet.lang.types.TypeUtils.noExpectedType;
|
||||
import static org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils.createFakeExpressionOfType;
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMapping;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMatch;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
@@ -50,7 +50,7 @@ public class InlineDescriptorUtils {
|
||||
boolean allowsNonLocalReturns = false;
|
||||
JetExpression call = JetPsiUtil.getParentCallIfPresent((JetFunctionLiteralExpression) containingFunction);
|
||||
if (call != null) {
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(call, bindingContext);
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCall(call, bindingContext);
|
||||
CallableDescriptor resultingDescriptor = resolvedCall == null ? null : resolvedCall.getResultingDescriptor();
|
||||
if (resultingDescriptor instanceof SimpleFunctionDescriptor &&
|
||||
((SimpleFunctionDescriptor) resultingDescriptor).getInlineStrategy().isInline()) {
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls
|
||||
|
||||
import javax.inject.Inject
|
||||
import kotlin.properties.Delegates
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.BasicCallResolutionContext
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResultsImpl
|
||||
@@ -41,9 +39,9 @@ import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMapping
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentUnmapped
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMatch
|
||||
import org.jetbrains.jet.lang.psi.JetWhenExpression
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.ResolutionContext
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.*
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.CallResolutionContext
|
||||
import org.jetbrains.jet.lang.types.expressions.DataFlowUtils
|
||||
@@ -52,11 +50,9 @@ import org.jetbrains.jet.lang.psi.Call
|
||||
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils
|
||||
import org.jetbrains.jet.lang.psi.JetBlockExpression
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getCall
|
||||
import org.jetbrains.jet.lang.psi.JetSafeQualifiedExpression
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS
|
||||
import org.jetbrains.jet.lang.resolve.TemporaryBindingTrace
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.getAllValueArguments
|
||||
import org.jetbrains.jet.lang.psi.JetQualifiedExpression
|
||||
import java.util.ArrayList
|
||||
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.BasicCallResolutionContext;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.DefaultValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
@@ -187,7 +187,7 @@ public class InlineCallResolverExtension implements CallResolverExtension {
|
||||
) {
|
||||
if (!(expression instanceof JetSimpleNameExpression || expression instanceof JetThisExpression)) return null;
|
||||
|
||||
ResolvedCall<?> thisCall = BindingContextUtilPackage.getResolvedCall(expression, context.trace.getBindingContext());
|
||||
ResolvedCall<?> thisCall = CallUtilPackage.getResolvedCall(expression, context.trace.getBindingContext());
|
||||
if (unwrapVariableAsFunction && thisCall instanceof VariableAsFunctionResolvedCall) {
|
||||
return ((VariableAsFunctionResolvedCall) thisCall).getVariableCall().getResultingDescriptor();
|
||||
}
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.JetModuleUtil;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.*;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -166,7 +166,7 @@ public class DataFlowValueFactory {
|
||||
) {
|
||||
DeclarationDescriptor declarationDescriptor = bindingContext.get(REFERENCE_TARGET, simpleNameExpression);
|
||||
if (declarationDescriptor instanceof VariableDescriptor) {
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(simpleNameExpression, bindingContext);
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCall(simpleNameExpression, bindingContext);
|
||||
// todo uncomment assert
|
||||
// KT-4113
|
||||
// for now it fails for resolving 'invoke' convention, return it after 'invoke' algorithm changes
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.OverrideResolver;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.CheckValueArgumentsMode;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.ResolutionTask;
|
||||
@@ -102,7 +102,7 @@ public class ResolutionResultsHandler {
|
||||
// This check is needed for the following case:
|
||||
// x.foo(unresolved) -- if there are multiple foo's, we'd report an ambiguity, and it does not make sense here
|
||||
if (task.checkArguments == CheckValueArgumentsMode.DISABLED ||
|
||||
!BindingContextUtilPackage.hasUnresolvedArguments(task.call, task.trace.getBindingContext())) {
|
||||
!CallUtilPackage.hasUnresolvedArguments(task.call, task.trace.getBindingContext())) {
|
||||
if (allCandidatesIncomplete) {
|
||||
task.tracing.cannotCompleteResolve(task.trace, results.getResultingCalls());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls.callUtil
|
||||
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentUnmapped
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMatch
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMatchStatus
|
||||
import org.jetbrains.jet.lang.psi.Call
|
||||
import org.jetbrains.jet.lang.psi.ValueArgument
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.resolve.calls.ArgumentTypeResolver
|
||||
import org.jetbrains.jet.lang.psi.JetElement
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil
|
||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
||||
import org.jetbrains.jet.lang.psi.JetCallElement
|
||||
import org.jetbrains.jet.lang.psi.JetQualifiedExpression
|
||||
import org.jetbrains.jet.lang.psi.JetOperationExpression
|
||||
import org.jetbrains.jet.lang.psi.JetInstanceExpressionWithLabel
|
||||
import org.jetbrains.jet.lang.psi.JetUserType
|
||||
import org.jetbrains.jet.lang.psi.JetConstructorCalleeExpression
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext.CALL
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpression
|
||||
import org.jetbrains.jet.lang.psi.JetUnaryExpression
|
||||
import org.jetbrains.jet.lang.psi.JetArrayAccessExpression
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext.RESOLVED_CALL
|
||||
import org.jetbrains.kotlin.util.sure
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.getTextWithLocation
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
|
||||
|
||||
// resolved call
|
||||
|
||||
public fun <D : CallableDescriptor> ResolvedCall<D>.noErrorsInValueArguments(): Boolean {
|
||||
return getCall().getValueArguments().all { argument -> !getArgumentMapping(argument!!).isError() }
|
||||
}
|
||||
|
||||
public fun <D : CallableDescriptor> ResolvedCall<D>.hasUnmappedArguments(): Boolean {
|
||||
return getCall().getValueArguments().any { argument -> getArgumentMapping(argument!!) == ArgumentUnmapped }
|
||||
}
|
||||
|
||||
public fun <D : CallableDescriptor> ResolvedCall<D>.hasUnmappedParameters(): Boolean {
|
||||
val parameterToArgumentMap = getValueArguments()
|
||||
return !parameterToArgumentMap.keySet().containsAll(getResultingDescriptor().getValueParameters())
|
||||
}
|
||||
|
||||
public fun <D : CallableDescriptor> ResolvedCall<D>.hasTypeMismatchErrorOnParameter(parameter: ValueParameterDescriptor): Boolean {
|
||||
val resolvedValueArgument = getValueArguments()[parameter]
|
||||
if (resolvedValueArgument == null) return true
|
||||
|
||||
return resolvedValueArgument.getArguments().any { argument ->
|
||||
val argumentMapping = getArgumentMapping(argument)
|
||||
argumentMapping is ArgumentMatch && argumentMapping.status == ArgumentMatchStatus.TYPE_MISMATCH
|
||||
}
|
||||
}
|
||||
|
||||
// call
|
||||
|
||||
public fun Call.hasUnresolvedArguments(context: BindingContext): Boolean {
|
||||
val arguments = getValueArguments().map { it?.getArgumentExpression() }
|
||||
return arguments.any {
|
||||
argument ->
|
||||
val expressionType = context[BindingContext.EXPRESSION_TYPE, argument]
|
||||
argument != null && !ArgumentTypeResolver.isFunctionLiteralArgument(argument)
|
||||
&& (expressionType == null || expressionType.isError())
|
||||
}
|
||||
}
|
||||
|
||||
public fun Call.getAllValueArguments(): List<ValueArgument> {
|
||||
val arguments = getValueArguments() +
|
||||
getFunctionLiteralArguments().map { functionLiteral -> CallMaker.makeValueArgument(functionLiteral) }
|
||||
[suppress("UNCHECKED_CAST")]
|
||||
return arguments as List<ValueArgument>
|
||||
}
|
||||
|
||||
// Get call / resolved call from binding context
|
||||
|
||||
public fun JetElement.getCalleeExpressionIfAny(): JetExpression? {
|
||||
val element = if (this is JetExpression) JetPsiUtil.safeDeparenthesize(this, false) else this
|
||||
return when (element) {
|
||||
is JetSimpleNameExpression -> element
|
||||
is JetCallElement -> element.getCalleeExpression()
|
||||
is JetQualifiedExpression -> element.getSelectorExpression()?.getCalleeExpressionIfAny()
|
||||
is JetOperationExpression -> element.getOperationReference()
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For expressions like <code>a(), a[i], a.b.c(), +a, a + b, (a()), a(): Int, @label a()</code>
|
||||
* returns a corresponding call.
|
||||
*
|
||||
* Note: special construction like <code>a!!, a ?: b, if (c) a else b</code> are resolved as calls,
|
||||
* so there is a corresponding call for them.
|
||||
*/
|
||||
public fun JetElement.getCall(context: BindingContext): Call? {
|
||||
val element = if (this is JetExpression) JetPsiUtil.deparenthesize(this) else this
|
||||
if (element == null) return null
|
||||
|
||||
val parent = element.getParent()
|
||||
val reference = when {
|
||||
parent is JetInstanceExpressionWithLabel -> parent : JetInstanceExpressionWithLabel
|
||||
parent is JetUserType -> parent.getParent()?.getParent() as? JetConstructorCalleeExpression
|
||||
else -> element.getCalleeExpressionIfAny()
|
||||
}
|
||||
if (reference != null) {
|
||||
return context[CALL, reference]
|
||||
}
|
||||
return context[CALL, element]
|
||||
}
|
||||
|
||||
public fun JetElement.getParentCall(context: BindingContext, strict: Boolean = true): Call? {
|
||||
val callExpressionTypes = array<Class<out JetElement>?>(
|
||||
javaClass<JetSimpleNameExpression>(), javaClass<JetCallElement>(), javaClass<JetBinaryExpression>(),
|
||||
javaClass<JetUnaryExpression>(), javaClass<JetArrayAccessExpression>())
|
||||
|
||||
val parent = if (strict) {
|
||||
PsiTreeUtil.getParentOfType(this, *callExpressionTypes)
|
||||
} else {
|
||||
PsiTreeUtil.getNonStrictParentOfType(this, *callExpressionTypes)
|
||||
}
|
||||
return parent?.getCall(context)
|
||||
}
|
||||
|
||||
public fun Call?.getResolvedCall(context: BindingContext): ResolvedCall<out CallableDescriptor>? {
|
||||
return context[RESOLVED_CALL, this]
|
||||
}
|
||||
|
||||
public fun JetElement?.getResolvedCall(context: BindingContext): ResolvedCall<out CallableDescriptor>? {
|
||||
return this?.getCall(context)?.getResolvedCall(context)
|
||||
}
|
||||
|
||||
public fun JetElement?.getParentResolvedCall(context: BindingContext, strict: Boolean = true): ResolvedCall<out CallableDescriptor>? {
|
||||
return this?.getParentCall(context, strict)?.getResolvedCall(context)
|
||||
}
|
||||
|
||||
public fun JetElement.getCallWithAssert(context: BindingContext): Call {
|
||||
return getCall(context).sure("No call for ${this.getTextWithLocation()}")
|
||||
}
|
||||
|
||||
public fun JetElement.getResolvedCallWithAssert(context: BindingContext): ResolvedCall<out CallableDescriptor> {
|
||||
return getResolvedCall(context).sure("No resolved call for ${this.getTextWithLocation()}")
|
||||
}
|
||||
|
||||
public fun Call.getResolvedCallWithAssert(context: BindingContext): ResolvedCall<out CallableDescriptor> {
|
||||
return getResolvedCall(context).sure("No resolved call for ${this.getCallElement().getTextWithLocation()}")
|
||||
}
|
||||
|
||||
public fun JetExpression.getFunctionResolvedCallWithAssert(context: BindingContext): ResolvedCall<out FunctionDescriptor> {
|
||||
val resolvedCall = getResolvedCallWithAssert(context)
|
||||
assert(resolvedCall.getResultingDescriptor() is FunctionDescriptor) {
|
||||
"ResolvedCall for this expression must be ResolvedCall<? extends FunctionDescriptor>: ${this.getTextWithLocation()}"
|
||||
}
|
||||
[suppress("UNCHECKED_CAST")]
|
||||
return resolvedCall as ResolvedCall<out FunctionDescriptor>
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.resolve.calls.util
|
||||
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentUnmapped
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMatch
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMatchStatus
|
||||
import org.jetbrains.jet.lang.psi.Call
|
||||
import org.jetbrains.jet.lang.psi.ValueArgument
|
||||
|
||||
public fun <D : CallableDescriptor> ResolvedCall<D>.noErrorsInValueArguments(): Boolean {
|
||||
return getCall().getValueArguments().all { argument -> !getArgumentMapping(argument!!).isError() }
|
||||
}
|
||||
|
||||
public fun <D : CallableDescriptor> ResolvedCall<D>.hasUnmappedArguments(): Boolean {
|
||||
return getCall().getValueArguments().any { argument -> getArgumentMapping(argument!!) == ArgumentUnmapped }
|
||||
}
|
||||
|
||||
public fun <D : CallableDescriptor> ResolvedCall<D>.hasUnmappedParameters(): Boolean {
|
||||
val parameterToArgumentMap = getValueArguments()
|
||||
return !parameterToArgumentMap.keySet().containsAll(getResultingDescriptor().getValueParameters())
|
||||
}
|
||||
|
||||
public fun <D : CallableDescriptor> ResolvedCall<D>.hasTypeMismatchErrorOnParameter(parameter: ValueParameterDescriptor): Boolean {
|
||||
val resolvedValueArgument = getValueArguments()[parameter]
|
||||
if (resolvedValueArgument == null) return true
|
||||
|
||||
return resolvedValueArgument.getArguments().any { argument ->
|
||||
val argumentMapping = getArgumentMapping(argument)
|
||||
argumentMapping is ArgumentMatch && argumentMapping.status == ArgumentMatchStatus.TYPE_MISMATCH
|
||||
}
|
||||
}
|
||||
|
||||
fun Call.getAllValueArguments(): List<ValueArgument> {
|
||||
val arguments = getValueArguments() +
|
||||
getFunctionLiteralArguments().map { functionLiteral -> CallMaker.makeValueArgument(functionLiteral) }
|
||||
[suppress("UNCHECKED_CAST")]
|
||||
return arguments as List<ValueArgument>
|
||||
}
|
||||
+2
-2
@@ -32,8 +32,8 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintPosition;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemImpl;
|
||||
@@ -155,7 +155,7 @@ public class ExpressionTypingUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(callExpression, context);
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCall(callExpression, context);
|
||||
if (resolvedCall == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.io.File
|
||||
import org.jetbrains.jet.lang.resolve.lazy.JvmResolveUtil
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMapping
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ArgumentMatch
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.getAllValueArguments
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getAllValueArguments
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.jet.lang.psi.ValueArgument
|
||||
@@ -36,7 +36,7 @@ import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getParentResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getParentResolvedCall
|
||||
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.intellij.psi.PsiDocumentManager
|
||||
import org.jetbrains.jet.plugin.caches.resolve.getLazyResolveSession
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer.FQ_NAMES_IN_TYPES
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||
|
||||
public object ShortenReferences {
|
||||
public fun process(element: JetElement) {
|
||||
|
||||
@@ -43,9 +43,8 @@ import org.jetbrains.jet.lang.psi.JetIfExpression
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||
import org.jetbrains.jet.lang.psi.JetContainerNode
|
||||
import org.jetbrains.jet.plugin.completion.smart.isSubtypeOf
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.DelegatingCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.noErrorsInValueArguments
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.hasUnmappedParameters
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.noErrorsInValueArguments
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.hasUnmappedParameters
|
||||
import org.jetbrains.jet.lang.descriptors.Visibilities
|
||||
import org.jetbrains.jet.lang.psi.JetBlockExpression
|
||||
import org.jetbrains.jet.plugin.util.makeNotNullable
|
||||
@@ -57,6 +56,7 @@ import org.jetbrains.jet.lang.types.TypeUtils
|
||||
import org.jetbrains.jet.lang.resolve.calls.context.BasicCallResolutionContext
|
||||
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace
|
||||
import org.jetbrains.jet.lang.psi.JetPrefixExpression
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.DelegatingCall
|
||||
|
||||
enum class Tail {
|
||||
COMMA
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.jetbrains.jet.plugin.completion.smart
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.noErrorsInValueArguments
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.hasUnmappedParameters
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.noErrorsInValueArguments
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.hasUnmappedParameters
|
||||
|
||||
|
||||
fun <D : CallableDescriptor> OverloadResolutionResults<D>.getCandidatesForCompletion(): Collection<ResolvedCall<D>> {
|
||||
|
||||
@@ -43,7 +43,7 @@ import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.extension.InlineAnalyzerExtension;
|
||||
@@ -284,7 +284,7 @@ public class JetPositionManager implements PositionManager {
|
||||
|
||||
if (!(parent instanceof JetElement)) return false;
|
||||
|
||||
ResolvedCall<?> call = BindingContextUtilPackage.getResolvedCall((JetElement) parent, context);
|
||||
ResolvedCall<?> call = CallUtilPackage.getResolvedCall((JetElement) parent, context);
|
||||
if (call == null) return false;
|
||||
|
||||
InlineStrategy inlineType = InlineUtil.getInlineType(call.getResultingDescriptor());
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.intellij.util.Range
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
||||
import org.jetbrains.jet.asJava.LightClassUtil
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.jet.lang.psi.*
|
||||
@@ -38,7 +37,7 @@ import com.sun.jdi.Location
|
||||
import com.intellij.psi.PsiMethod
|
||||
import org.jetbrains.jet.plugin.codeInsight.CodeInsightUtils
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
public class KotlinSmartStepIntoHandler : JvmSmartStepIntoHandler() {
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
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;
|
||||
@@ -63,7 +63,7 @@ public class DeprecatedAnnotationVisitor extends AfterAnalysisHighlightingVisito
|
||||
@Override
|
||||
public void visitReferenceExpression(@NotNull JetReferenceExpression expression) {
|
||||
super.visitReferenceExpression(expression);
|
||||
ResolvedCall resolvedCall = BindingContextUtilPackage.getResolvedCall(expression, bindingContext);
|
||||
ResolvedCall resolvedCall = CallUtilPackage.getResolvedCall(expression, bindingContext);
|
||||
if (resolvedCall != null && resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
||||
// Deprecated for invoke()
|
||||
JetCallExpression parent = PsiTreeUtil.getParentOfType(expression, JetCallExpression.class);
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -67,7 +67,7 @@ public class FunctionsHighlightingVisitor extends AfterAnalysisHighlightingVisit
|
||||
@Override
|
||||
public void visitCallExpression(@NotNull JetCallExpression expression) {
|
||||
JetExpression callee = expression.getCalleeExpression();
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(expression, bindingContext);
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCall(expression, bindingContext);
|
||||
if (callee instanceof JetReferenceExpression && resolvedCall != null) {
|
||||
DeclarationDescriptor calleeDescriptor = resolvedCall.getResultingDescriptor();
|
||||
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
||||
|
||||
@@ -19,12 +19,8 @@ package org.jetbrains.jet.plugin.highlighter.renderersUtil
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer
|
||||
import org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.jet.lang.types.JetType
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.*
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.*
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName
|
||||
import org.jetbrains.jet.plugin.highlighter.IdeRenderers
|
||||
|
||||
@@ -28,7 +28,7 @@ import kotlin.properties.Delegates
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||
import org.jetbrains.jet.lang.psi.JetIfExpression
|
||||
import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.psi.JetBlockExpression
|
||||
import org.jetbrains.jet.lang.psi.JetThrowExpression
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.replaced
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.jet.lang.psi.JetThrowExpression
|
||||
import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import org.jetbrains.jet.plugin.intentions.branchedTransformations.isNullExpression
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||
|
||||
public class ConvertIfWithThrowToAssertIntention :
|
||||
JetSelfTargetingIntention<JetIfExpression>("convert.if.with.throw.to.assert", javaClass()) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.psi.JetBinaryExpression
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||
import org.jetbrains.jet.plugin.caches.resolve.getLazyResolveSession
|
||||
import org.jetbrains.jet.lang.psi.JetParenthesizedExpression
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||
|
||||
public class ConvertToForEachLoopIntention : JetSelfTargetingIntention<JetExpression>("convert.to.for.each.loop.intention", javaClass()) {
|
||||
private fun getFunctionLiteralArgument(element: JetExpression): JetFunctionLiteralExpression? {
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer
|
||||
import org.jetbrains.jet.plugin.codeInsight.ShortenReferences
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||
|
||||
public class InsertExplicitTypeArguments : JetSelfTargetingIntention<JetCallExpression>(
|
||||
"insert.explicit.type.arguments", javaClass()) {
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import com.intellij.openapi.editor.Editor
|
||||
import org.jetbrains.jet.lang.psi.JetCallExpression
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||
import org.jetbrains.jet.plugin.caches.resolve.getBindingContext
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||
|
||||
public class MoveLambdaInsideParenthesesIntention : JetSelfTargetingIntention<JetCallExpression>(
|
||||
"move.lambda.inside.parentheses", javaClass()) {
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.jetbrains.jet.lang.psi.JetDotQualifiedExpression
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||
|
||||
public class OperatorToFunctionIntention : JetSelfTargetingIntention<JetExpression>("operator.to.function", javaClass()) {
|
||||
fun isApplicablePrefix(element: JetPrefixExpression): Boolean {
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.jetbrains.jet.lang.psi.JetProperty
|
||||
import org.jetbrains.jet.lang.psi.JetTypeArgumentList
|
||||
import org.jetbrains.jet.lang.psi.JetReturnExpression
|
||||
import org.jetbrains.jet.lang.psi.JetDeclarationWithBody
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.getTextWithLocation
|
||||
|
||||
public class RemoveExplicitTypeArguments : JetSelfTargetingIntention<JetTypeArgumentList>(
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ import org.jetbrains.jet.lang.types.PackageType
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUnparsingUtils
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||
import com.intellij.codeInsight.hint.HintManager
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||
|
||||
public open class ReplaceWithInfixFunctionCallIntention : JetSelfTargetingIntention<JetCallExpression>("replace.with.infix.function.call.intention", javaClass()) {
|
||||
override fun isApplicableTo(element: JetCallExpression): Boolean {
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ import org.jetbrains.jet.plugin.util.Maybe
|
||||
import org.jetbrains.jet.plugin.util.MaybeError
|
||||
import org.jetbrains.jet.plugin.util.MaybeValue
|
||||
import com.intellij.codeInsight.hint.HintManager
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||
|
||||
// Internal because you shouldn't construct this manually. You can end up with an inconsistant CallDescription.
|
||||
public class CallDescription internal (
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetValueArgument;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
@@ -69,7 +69,7 @@ public class AddNameToArgumentFix extends JetIntentionAction<JetValueArgument> {
|
||||
assert callElement != null : "The argument has to be inside a function or constructor call";
|
||||
|
||||
BindingContext context = ResolvePackage.getBindingContext(argument.getContainingJetFile());
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(callElement, context);
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCall(callElement, context);
|
||||
if (resolvedCall == null) return Collections.emptyList();
|
||||
|
||||
CallableDescriptor callableDescriptor = resolvedCall.getResultingDescriptor();
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
@@ -188,7 +188,7 @@ public class ChangeFunctionReturnTypeFix extends JetIntentionAction<JetFunction>
|
||||
JetBinaryExpression expression = QuickFixUtil.getParentElementOfType(diagnostic, JetBinaryExpression.class);
|
||||
assert expression != null : "COMPARE_TO_TYPE_MISMATCH reported on element that is not within any expression";
|
||||
BindingContext context = ResolvePackage.getBindingContext(expression.getContainingJetFile());
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(expression, context);
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCall(expression, context);
|
||||
if (resolvedCall == null) return null;
|
||||
PsiElement compareTo = DescriptorToSourceUtils.descriptorToDeclaration(resolvedCall.getCandidateDescriptor());
|
||||
if (!(compareTo instanceof JetFunction)) return null;
|
||||
|
||||
@@ -26,8 +26,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithParameters2;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.plugin.caches.resolve.ResolvePackage;
|
||||
@@ -71,7 +70,7 @@ public class QuickFixFactoryForTypeMismatchError implements JetIntentionActionsF
|
||||
|
||||
// Fixing overloaded operators:
|
||||
if (expression instanceof JetOperationExpression) {
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(expression, context);
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCall(expression, context);
|
||||
if (resolvedCall != null) {
|
||||
JetFunction declaration = getFunctionDeclaration(resolvedCall);
|
||||
if (declaration != null) {
|
||||
@@ -82,7 +81,7 @@ public class QuickFixFactoryForTypeMismatchError implements JetIntentionActionsF
|
||||
if (expression.getParent() instanceof JetBinaryExpression) {
|
||||
JetBinaryExpression parentBinary = (JetBinaryExpression) expression.getParent();
|
||||
if (parentBinary.getRight() == expression) {
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(parentBinary, context);
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCall(parentBinary, context);
|
||||
if (resolvedCall != null) {
|
||||
JetFunction declaration = getFunctionDeclaration(resolvedCall);
|
||||
if (declaration != null) {
|
||||
@@ -95,7 +94,7 @@ public class QuickFixFactoryForTypeMismatchError implements JetIntentionActionsF
|
||||
|
||||
// Change function return type when TYPE_MISMATCH is reported on call expression:
|
||||
if (expression instanceof JetCallExpression) {
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(expression, context);
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCall(expression, context);
|
||||
if (resolvedCall != null) {
|
||||
JetFunction declaration = getFunctionDeclaration(resolvedCall);
|
||||
if (declaration != null) {
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.types.DeferredType;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -108,7 +108,7 @@ public class QuickFixUtil {
|
||||
@Nullable
|
||||
public static JetParameterList getParameterListOfCallee(@NotNull JetCallExpression callExpression) {
|
||||
BindingContext context = ResolvePackage.getBindingContext(callExpression.getContainingJetFile());
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(callExpression, context);
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCall(callExpression, context);
|
||||
if (resolvedCall == null) return null;
|
||||
PsiElement declaration = safeGetDeclaration(resolvedCall);
|
||||
if (declaration instanceof JetFunction) {
|
||||
|
||||
@@ -49,7 +49,7 @@ import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||
import org.jetbrains.jet.lang.psi.JetFunctionLiteral
|
||||
import org.jetbrains.jet.lang.psi.JetClassInitializer
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorToSourceUtils
|
||||
|
||||
data class ExtractionOptions(val inferUnitTypeForUnusedValues: Boolean) {
|
||||
|
||||
@@ -53,7 +53,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -325,7 +325,7 @@ public class KotlinInlineValHandler extends InlineActionHandler {
|
||||
ResolveSessionForBodies resolveSessionForBodies = ResolvePackage.getLazyResolveSession(containingFile);
|
||||
for (JetExpression inlinedExpression : inlinedExpressions) {
|
||||
BindingContext context = resolveSessionForBodies.resolveToElement(inlinedExpression);
|
||||
Call call = BindingContextUtilPackage.getCallWithAssert(inlinedExpression, context);
|
||||
Call call = CallUtilPackage.getCallWithAssert(inlinedExpression, context);
|
||||
|
||||
JetElement callElement = call.getCallElement();
|
||||
if (callElement instanceof JetCallExpression && hasIncompleteTypeInferenceDiagnostic(call, context) &&
|
||||
@@ -344,7 +344,7 @@ public class KotlinInlineValHandler extends InlineActionHandler {
|
||||
@Nullable
|
||||
private static String getTypeArgumentsStringForCall(@NotNull JetExpression initializer) {
|
||||
BindingContext context = AnalyzerFacadeWithCache.getContextForElement(initializer);
|
||||
ResolvedCall<?> call = BindingContextUtilPackage.getResolvedCall(initializer, context);
|
||||
ResolvedCall<?> call = CallUtilPackage.getResolvedCall(initializer, context);
|
||||
if (call == null) return null;
|
||||
|
||||
List<JetType> typeArguments = Lists.newArrayList();
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.psi.PsiPackage.JetPsiFactory;
|
||||
import static org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage.getResolvedCall;
|
||||
import static org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage.getResolvedCall;
|
||||
|
||||
public class KotlinIntroduceVariableHandler extends KotlinIntroduceHandlerBase {
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
@@ -47,8 +47,8 @@ class JetInvokeFunctionReference extends JetSimpleReference<JetCallExpression> i
|
||||
@Override
|
||||
@NotNull
|
||||
protected Collection<DeclarationDescriptor> getTargetDescriptors(@NotNull BindingContext context) {
|
||||
Call call = BindingContextUtilPackage.getCall(getElement(), context);
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCall(call, context);
|
||||
Call call = CallUtilPackage.getCall(getElement(), context);
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCall(call, context);
|
||||
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
||||
return Collections.<DeclarationDescriptor>singleton(
|
||||
((VariableAsFunctionResolvedCall) resolvedCall).getFunctionCall().getCandidateDescriptor());
|
||||
|
||||
+2
-2
@@ -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.bindingContextUtil.BindingContextUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
@@ -124,7 +124,7 @@ public final class ClassInitializerTranslator extends AbstractTranslator {
|
||||
|
||||
@NotNull
|
||||
private List<JsExpression> translateArguments(@NotNull JetDelegatorToSuperCall superCall) {
|
||||
ResolvedCall<?> call = BindingContextUtilPackage.getResolvedCallWithAssert(superCall, context().bindingContext());
|
||||
ResolvedCall<?> call = CallUtilPackage.getResolvedCallWithAssert(superCall, context().bindingContext());
|
||||
return CallArgumentTranslator.translate(call, null, context()).getTranslateArguments();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ 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.jet.lang.resolve.calls.callUtil.CallUtilPackage.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;
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ 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.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.k2js.translate.callTranslator.CallTranslator;
|
||||
import org.jetbrains.k2js.translate.context.TranslationContext;
|
||||
@@ -39,7 +39,7 @@ public final class OverloadedAssignmentTranslator extends AssignmentTranslator {
|
||||
private OverloadedAssignmentTranslator(@NotNull JetBinaryExpression expression,
|
||||
@NotNull TranslationContext context) {
|
||||
super(expression, context);
|
||||
resolvedCall = BindingContextUtilPackage.getFunctionResolvedCallWithAssert(expression, context.bindingContext());
|
||||
resolvedCall = CallUtilPackage.getFunctionResolvedCallWithAssert(expression, context.bindingContext());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ 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.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.k2js.translate.callTranslator.CallTranslator;
|
||||
import org.jetbrains.k2js.translate.context.TranslationContext;
|
||||
@@ -35,7 +35,7 @@ public final class OverloadedIncrementTranslator extends IncrementTranslator {
|
||||
@NotNull TranslationContext context
|
||||
) {
|
||||
super(expression, context);
|
||||
this.resolvedCall = BindingContextUtilPackage.getFunctionResolvedCallWithAssert(expression, context.bindingContext());
|
||||
this.resolvedCall = CallUtilPackage.getFunctionResolvedCallWithAssert(expression, context.bindingContext());
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ 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.jet.lang.resolve.calls.callUtil.CallUtilPackage.getFunctionResolvedCallWithAssert;
|
||||
import static org.jetbrains.k2js.translate.general.Translation.translateAsExpression;
|
||||
import static org.jetbrains.k2js.translate.utils.PsiUtils.getBaseExpression;
|
||||
import static org.jetbrains.k2js.translate.utils.PsiUtils.getOperationToken;
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ 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.callUtil.CallUtilPackage;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.k2js.translate.context.TranslationContext;
|
||||
import org.jetbrains.k2js.translate.general.AbstractTranslator;
|
||||
@@ -42,7 +42,7 @@ public abstract class AbstractCallExpressionTranslator extends AbstractTranslato
|
||||
) {
|
||||
super(context);
|
||||
this.expression = expression;
|
||||
this.resolvedCall = BindingContextUtilPackage.getFunctionResolvedCallWithAssert(expression, bindingContext());
|
||||
this.resolvedCall = CallUtilPackage.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 = BindingContextUtilPackage.getFunctionResolvedCall(expression, bindingContext());
|
||||
//ResolvedCall<?> resolvedCall = CallUtilPackage.getFunctionResolvedCall(expression, bindingContext());
|
||||
//CallableDescriptor descriptor = resolvedCall.getCandidateDescriptor();
|
||||
//if (descriptor instanceof SimpleFunctionDescriptor) {
|
||||
// return ((SimpleFunctionDescriptor)descriptor).isInline();
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@ 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.callUtil.CallUtilPackage;
|
||||
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;
|
||||
@@ -38,7 +38,7 @@ public class VariableAccessTranslator extends AbstractTranslator implements Acce
|
||||
@NotNull JetReferenceExpression referenceExpression,
|
||||
@Nullable JsExpression receiver
|
||||
) {
|
||||
ResolvedCall<?> resolvedCall = BindingContextUtilPackage.getResolvedCallWithAssert(referenceExpression, context.bindingContext());
|
||||
ResolvedCall<?> resolvedCall = CallUtilPackage.getResolvedCallWithAssert(referenceExpression, context.bindingContext());
|
||||
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
||||
resolvedCall = ((VariableAsFunctionResolvedCall) resolvedCall).getVariableCall();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user