001    /*
002     * Copyright 2010-2015 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.kotlin.resolve.calls.context;
018    
019    import org.jetbrains.annotations.NotNull;
020    import org.jetbrains.annotations.Nullable;
021    import org.jetbrains.kotlin.psi.Call;
022    import org.jetbrains.kotlin.resolve.BindingTrace;
023    import org.jetbrains.kotlin.resolve.StatementFilter;
024    import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker;
025    import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker;
026    import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments;
027    import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
028    import org.jetbrains.kotlin.resolve.scopes.JetScope;
029    import org.jetbrains.kotlin.types.JetType;
030    
031    public class BasicCallResolutionContext extends CallResolutionContext<BasicCallResolutionContext> {
032        private BasicCallResolutionContext(
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 ResolutionResultsCache resolutionResultsCache,
041                @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments,
042                @NotNull CallChecker callChecker,
043                @NotNull AdditionalTypeChecker additionalTypeChecker,
044                @NotNull StatementFilter statementFilter,
045                boolean isAnnotationContext,
046                boolean collectAllCandidates
047        ) {
048            super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
049                  dataFlowInfoForArguments, callChecker, additionalTypeChecker, statementFilter, isAnnotationContext, collectAllCandidates);
050        }
051    
052        @NotNull
053        public static BasicCallResolutionContext create(
054                @NotNull BindingTrace trace,
055                @NotNull JetScope scope,
056                @NotNull Call call,
057                @NotNull JetType expectedType,
058                @NotNull DataFlowInfo dataFlowInfo,
059                @NotNull ContextDependency contextDependency,
060                @NotNull CheckValueArgumentsMode checkArguments,
061                @NotNull CallChecker callChecker,
062                @NotNull AdditionalTypeChecker additionalTypeChecker,
063                boolean isAnnotationContext
064        ) {
065            return new BasicCallResolutionContext(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments,
066                 new ResolutionResultsCacheImpl(), null,
067                 callChecker, additionalTypeChecker, StatementFilter.NONE, isAnnotationContext, false);
068        }
069    
070        @NotNull
071        public static BasicCallResolutionContext create(
072                @NotNull ResolutionContext context, @NotNull Call call, @NotNull CheckValueArgumentsMode checkArguments,
073                @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments
074        ) {
075            return new BasicCallResolutionContext(
076                    context.trace, context.scope, call, context.expectedType, context.dataFlowInfo, context.contextDependency, checkArguments,
077                    context.resolutionResultsCache, dataFlowInfoForArguments, context.callChecker, context.additionalTypeChecker, context.statementFilter,
078                    context.isAnnotationContext, context.collectAllCandidates);
079        }
080    
081        @NotNull
082        public static BasicCallResolutionContext create(
083                @NotNull ResolutionContext context, @NotNull Call call, @NotNull CheckValueArgumentsMode checkArguments
084        ) {
085            return create(context, call, checkArguments, null);
086        }
087    
088        @Override
089        protected BasicCallResolutionContext create(
090                @NotNull BindingTrace trace,
091                @NotNull JetScope scope,
092                @NotNull DataFlowInfo dataFlowInfo,
093                @NotNull JetType expectedType,
094                @NotNull ContextDependency contextDependency,
095                @NotNull ResolutionResultsCache resolutionResultsCache,
096                @NotNull StatementFilter statementFilter,
097                boolean collectAllCandidates
098        ) {
099            return new BasicCallResolutionContext(
100                    trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
101                    dataFlowInfoForArguments, callChecker, additionalTypeChecker, statementFilter, isAnnotationContext, collectAllCandidates);
102        }
103    
104        @NotNull
105        public BasicCallResolutionContext replaceCall(@NotNull Call newCall) {
106            return new BasicCallResolutionContext(
107                    trace, scope, newCall, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
108                    dataFlowInfoForArguments, callChecker, additionalTypeChecker, statementFilter, isAnnotationContext, collectAllCandidates);
109        }
110    }