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