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    import org.jetbrains.jet.lang.types.expressions.LabelResolver;
029    
030    public class BasicCallResolutionContext extends CallResolutionContext<BasicCallResolutionContext> {
031        @NotNull
032        public static BasicCallResolutionContext create(
033                @NotNull BindingTrace trace,
034                @NotNull JetScope scope,
035                @NotNull Call call,
036                @NotNull JetType expectedType,
037                @NotNull DataFlowInfo dataFlowInfo,
038                @NotNull ContextDependency contextDependency,
039                @NotNull CheckValueArgumentsMode checkArguments,
040                @NotNull ExpressionPosition expressionPosition,
041                @NotNull ResolutionResultsCache resolutionResultsCache,
042                @NotNull LabelResolver labelResolver,
043                @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments,
044                @NotNull CallResolverExtension callResolverExtension
045        ) {
046            return new BasicCallResolutionContext(
047                    trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, expressionPosition,
048                    resolutionResultsCache, labelResolver, dataFlowInfoForArguments, callResolverExtension);
049        }
050    
051        @NotNull
052        public static BasicCallResolutionContext create(
053                @NotNull ResolutionContext context, @NotNull Call call, @NotNull CheckValueArgumentsMode checkArguments,
054                @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments
055        ) {
056            return create(
057                    context.trace, context.scope, call, context.expectedType, context.dataFlowInfo, context.contextDependency, checkArguments,
058                    context.expressionPosition, context.resolutionResultsCache, context.labelResolver, dataFlowInfoForArguments, context.callResolverExtension);
059        }
060    
061        @NotNull
062        public static BasicCallResolutionContext create(
063                @NotNull ResolutionContext context, @NotNull Call call, @NotNull CheckValueArgumentsMode checkArguments
064        ) {
065            return create(context, call, checkArguments, null);
066        }
067    
068        private BasicCallResolutionContext(
069                BindingTrace trace, JetScope scope, Call call, JetType expectedType,
070                DataFlowInfo dataFlowInfo, ContextDependency contextDependency, CheckValueArgumentsMode checkArguments,
071                ExpressionPosition expressionPosition, ResolutionResultsCache resolutionResultsCache,
072                LabelResolver labelResolver, MutableDataFlowInfoForArguments dataFlowInfoForArguments,
073                CallResolverExtension callResolverExtension
074        ) {
075            super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, expressionPosition, resolutionResultsCache,
076                  labelResolver, dataFlowInfoForArguments, callResolverExtension);
077        }
078    
079        @Override
080        protected BasicCallResolutionContext create(
081                @NotNull BindingTrace trace,
082                @NotNull JetScope scope,
083                @NotNull DataFlowInfo dataFlowInfo,
084                @NotNull JetType expectedType,
085                @NotNull ExpressionPosition expressionPosition,
086                @NotNull ContextDependency contextDependency,
087                @NotNull ResolutionResultsCache resolutionResultsCache,
088                @NotNull LabelResolver labelResolver
089        ) {
090            return create(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, expressionPosition,
091                          resolutionResultsCache, labelResolver, dataFlowInfoForArguments, callResolverExtension);
092        }
093    
094        @Override
095        protected BasicCallResolutionContext self() {
096            return this;
097        }
098    }