提交 e6020725 编写于 作者: A Andrey Breslav

Refactoring CallResolver to use context objects

上级 7ef65c00
......@@ -91,7 +91,7 @@ public class AnnotationResolver {
private OverloadResolutionResults<FunctionDescriptor> resolveType(@NotNull JetScope scope,
@NotNull JetAnnotationEntry entryElement,
@NotNull AnnotationDescriptor descriptor, BindingTrace trace) {
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCall(trace, scope, CallMaker.makeCall(ReceiverDescriptor.NO_RECEIVER, null, entryElement), NO_EXPECTED_TYPE, DataFlowInfo.EMPTY);
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveFunctionCall(trace, scope, CallMaker.makeCall(ReceiverDescriptor.NO_RECEIVER, null, entryElement), NO_EXPECTED_TYPE, DataFlowInfo.EMPTY);
JetType annotationType = results.getResultingDescriptor().getReturnType();
if (results.isSuccess()) {
descriptor.setAnnotationType(annotationType);
......
......@@ -23,6 +23,7 @@ import com.intellij.util.containers.Queue;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.calls.BasicResolutionContext;
import org.jetbrains.jet.lang.resolve.calls.CallMaker;
import org.jetbrains.jet.lang.resolve.calls.CallResolver;
import org.jetbrains.jet.lang.resolve.calls.OverloadResolutionResults;
......@@ -167,7 +168,7 @@ public class BodyResolver {
assert descriptor.getKind() == ClassKind.TRAIT;
return;
}
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCall(
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveFunctionCall(
context.getTrace(), scopeForConstructor,
CallMaker.makeCall(ReceiverDescriptor.NO_RECEIVER, null, call), NO_EXPECTED_TYPE, DataFlowInfo.EMPTY);
if (results.isSuccess()) {
......@@ -345,7 +346,7 @@ public class BodyResolver {
public void visitDelegationToSuperCallSpecifier(JetDelegatorToSuperCall call) {
JetTypeReference typeReference = call.getTypeReference();
if (typeReference != null) {
callResolver.resolveCall(context.getTrace(), scopeForSupertypeInitializers, CallMaker.makeCall(ReceiverDescriptor.NO_RECEIVER, null, call), NO_EXPECTED_TYPE, dataFlowInfo);
callResolver.resolveFunctionCall(context.getTrace(), scopeForSupertypeInitializers, CallMaker.makeCall(ReceiverDescriptor.NO_RECEIVER, null, call), NO_EXPECTED_TYPE, dataFlowInfo);
}
}
......@@ -355,9 +356,9 @@ public class BodyResolver {
// TODO : check: if a this() call is present, no other initializers are allowed
ClassDescriptor classDescriptor = descriptor.getContainingDeclaration();
callResolver.resolveCall(context.getTrace(),
scopeForSupertypeInitializers,
CallMaker.makeCall(ReceiverDescriptor.NO_RECEIVER, null, call), NO_EXPECTED_TYPE, dataFlowInfo);
callResolver.resolveFunctionCall(context.getTrace(),
scopeForSupertypeInitializers,
CallMaker.makeCall(ReceiverDescriptor.NO_RECEIVER, null, call), NO_EXPECTED_TYPE, dataFlowInfo);
// call.getThisReference(),
// classDescriptor,
// classDescriptor.getDefaultType(),
......
/*
* Copyright 2010-2012 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;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.psi.Call;
import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.JetType;
/**
* @author abreslav
*/
public class BasicResolutionContext extends ResolutionContext {
@NotNull
public static BasicResolutionContext create(@NotNull BindingTrace trace, @NotNull JetScope scope, @NotNull Call call, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo) {
return new BasicResolutionContext(trace, scope, call, expectedType, dataFlowInfo);
}
private BasicResolutionContext(BindingTrace trace, JetScope scope, Call call, JetType expectedType, DataFlowInfo dataFlowInfo) {
super(trace, scope, call, expectedType, dataFlowInfo);
}
}
/*
* Copyright 2010-2012 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;
import org.jetbrains.jet.lang.psi.Call;
import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.JetType;
/**
* @author abreslav
*/
public abstract class ResolutionContext {
/*package*/ final BindingTrace trace;
/*package*/ final JetScope scope;
/*package*/ final Call call;
/*package*/ final JetType expectedType;
/*package*/ final DataFlowInfo dataFlowInfo;
protected ResolutionContext(BindingTrace trace, JetScope scope, Call call, JetType expectedType, DataFlowInfo dataFlowInfo) {
this.trace = trace;
this.scope = scope;
this.call = call;
this.expectedType = expectedType;
this.dataFlowInfo = dataFlowInfo;
}
public BasicResolutionContext toBasic() {
return BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo);
}
}
......@@ -38,7 +38,7 @@ import static org.jetbrains.jet.lang.resolve.BindingContext.REFERENCE_TARGET;
*/
/*package*/ class ValueArgumentsToParametersMapper {
public static <D extends CallableDescriptor> boolean mapValueArgumentsToParameters(
@NotNull ResolutionTask<D> task,
@NotNull Call call,
@NotNull TracingStrategy tracing,
@NotNull ResolvedCallImpl<D> candidateCall
) {
......@@ -58,7 +58,7 @@ import static org.jetbrains.jet.lang.resolve.BindingContext.REFERENCE_TARGET;
parameterByName.put(valueParameter.getName(), valueParameter);
}
List<? extends ValueArgument> valueArguments = task.getCall().getValueArguments();
List<? extends ValueArgument> valueArguments = call.getValueArguments();
boolean error = false;
boolean someNamed = false;
......@@ -117,7 +117,7 @@ import static org.jetbrains.jet.lang.resolve.BindingContext.REFERENCE_TARGET;
}
}
List<JetExpression> functionLiteralArguments = task.getCall().getFunctionLiteralArguments();
List<JetExpression> functionLiteralArguments = call.getFunctionLiteralArguments();
if (!functionLiteralArguments.isEmpty()) {
JetExpression possiblyLabeledFunctionLiteral = functionLiteralArguments.get(0);
......
......@@ -23,6 +23,7 @@ import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.resolve.calls.BasicResolutionContext;
import org.jetbrains.jet.lang.resolve.calls.CallMaker;
import org.jetbrains.jet.lang.resolve.calls.OverloadResolutionResults;
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
......@@ -153,9 +154,13 @@ public class ExpressionTypingContext {
////////// Call resolution utilities
private BasicResolutionContext makeResolutionContext(@NotNull Call call) {
return BasicResolutionContext.create(trace, scope, call, expectedType, dataFlowInfo);
}
@NotNull
public OverloadResolutionResults<FunctionDescriptor> resolveCallWithGivenName(@NotNull Call call, @NotNull JetReferenceExpression functionReference, @NotNull String name) {
return expressionTypingServices.getCallResolver().resolveCallWithGivenName(trace, scope, call, functionReference, name, expectedType, dataFlowInfo);
return expressionTypingServices.getCallResolver().resolveCallWithGivenName(makeResolutionContext(call), functionReference, name);
}
@NotNull
......@@ -166,14 +171,14 @@ public class ExpressionTypingContext {
@Nullable
public FunctionDescriptor resolveCall(@NotNull ReceiverDescriptor receiver, @Nullable ASTNode callOperationNode, @NotNull JetCallExpression callExpression) {
OverloadResolutionResults<FunctionDescriptor> results = expressionTypingServices.getCallResolver().resolveCall(trace, scope, CallMaker.makeCall(receiver, callOperationNode, callExpression), expectedType, dataFlowInfo);
OverloadResolutionResults<FunctionDescriptor> results = expressionTypingServices.getCallResolver().resolveFunctionCall(trace, scope, CallMaker.makeCall(receiver, callOperationNode, callExpression), expectedType, dataFlowInfo);
return results.singleResult() ? results.getResultingDescriptor() : null;
}
@NotNull
public OverloadResolutionResults<VariableDescriptor> resolveSimpleProperty(@NotNull ReceiverDescriptor receiver, @Nullable ASTNode callOperationNode, @NotNull JetSimpleNameExpression nameExpression) {
Call call = CallMaker.makePropertyCall(receiver, callOperationNode, nameExpression);
return expressionTypingServices.getCallResolver().resolveSimpleProperty(trace, scope, call, expectedType, dataFlowInfo);
return expressionTypingServices.getCallResolver().resolveSimpleProperty(makeResolutionContext(call));
}
@NotNull
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册