001 /*
002 * Copyright 2010-2013 JetBrains s.r.o.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package org.jetbrains.jet.lang.resolve.calls.context;
018
019 import org.jetbrains.annotations.NotNull;
020 import org.jetbrains.annotations.Nullable;
021 import org.jetbrains.jet.lang.psi.Call;
022 import org.jetbrains.jet.lang.resolve.BindingTrace;
023 import org.jetbrains.jet.lang.resolve.calls.CallResolverExtension;
024 import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
025 import org.jetbrains.jet.lang.resolve.calls.model.MutableDataFlowInfoForArguments;
026 import org.jetbrains.jet.lang.resolve.scopes.JetScope;
027 import org.jetbrains.jet.lang.types.JetType;
028
029 public class BasicCallResolutionContext extends CallResolutionContext<BasicCallResolutionContext> {
030 private BasicCallResolutionContext(
031 @NotNull BindingTrace trace,
032 @NotNull JetScope scope,
033 @NotNull Call call,
034 @NotNull JetType expectedType,
035 @NotNull DataFlowInfo dataFlowInfo,
036 @NotNull ContextDependency contextDependency,
037 @NotNull CheckValueArgumentsMode checkArguments,
038 @NotNull ResolutionResultsCache resolutionResultsCache,
039 @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments,
040 @NotNull CallResolverExtension callResolverExtension,
041 boolean isAnnotationContext,
042 boolean collectAllCandidates
043 ) {
044 super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
045 dataFlowInfoForArguments, callResolverExtension, isAnnotationContext, collectAllCandidates);
046 }
047
048 @NotNull
049 public static BasicCallResolutionContext create(
050 @NotNull BindingTrace trace,
051 @NotNull JetScope scope,
052 @NotNull Call call,
053 @NotNull JetType expectedType,
054 @NotNull DataFlowInfo dataFlowInfo,
055 @NotNull ContextDependency contextDependency,
056 @NotNull CheckValueArgumentsMode checkArguments,
057 @NotNull CallResolverExtension callResolverExtension,
058 boolean isAnnotationContext
059 ) {
060 return new BasicCallResolutionContext(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments,
061 new ResolutionResultsCacheImpl(), null,
062 callResolverExtension, isAnnotationContext, false);
063 }
064
065 @NotNull
066 public static BasicCallResolutionContext create(
067 @NotNull ResolutionContext context, @NotNull Call call, @NotNull CheckValueArgumentsMode checkArguments,
068 @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments
069 ) {
070 return new BasicCallResolutionContext(context.trace, context.scope, call, context.expectedType, context.dataFlowInfo, context.contextDependency, checkArguments,
071 context.resolutionResultsCache, dataFlowInfoForArguments, context.callResolverExtension,
072 context.isAnnotationContext, context.collectAllCandidates);
073 }
074
075 @NotNull
076 public static BasicCallResolutionContext create(
077 @NotNull ResolutionContext context, @NotNull Call call, @NotNull CheckValueArgumentsMode checkArguments
078 ) {
079 return create(context, call, checkArguments, null);
080 }
081
082 @Override
083 protected BasicCallResolutionContext create(
084 @NotNull BindingTrace trace,
085 @NotNull JetScope scope,
086 @NotNull DataFlowInfo dataFlowInfo,
087 @NotNull JetType expectedType,
088 @NotNull ContextDependency contextDependency,
089 @NotNull ResolutionResultsCache resolutionResultsCache,
090 boolean collectAllCandidates
091 ) {
092 return new BasicCallResolutionContext(
093 trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
094 dataFlowInfoForArguments, callResolverExtension, isAnnotationContext, collectAllCandidates);
095 }
096
097 public BasicCallResolutionContext replaceCall(@NotNull Call newCall) {
098 return new BasicCallResolutionContext(
099 trace, scope, newCall, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
100 dataFlowInfoForArguments, callResolverExtension, isAnnotationContext, collectAllCandidates);
101 }
102 }