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.resolve.validation.SymbolUsageValidator;
030    import org.jetbrains.kotlin.types.JetType;
031    
032    public class BasicCallResolutionContext extends CallResolutionContext<BasicCallResolutionContext> {
033        private BasicCallResolutionContext(
034                @NotNull BindingTrace trace,
035                @NotNull JetScope scope,
036                @NotNull Call call,
037                @NotNull JetType expectedType,
038                @NotNull DataFlowInfo dataFlowInfo,
039                @NotNull ContextDependency contextDependency,
040                @NotNull CheckValueArgumentsMode checkArguments,
041                @NotNull ResolutionResultsCache resolutionResultsCache,
042                @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments,
043                @NotNull CallChecker callChecker,
044                @NotNull SymbolUsageValidator symbolUsageValidator,
045                @NotNull AdditionalTypeChecker additionalTypeChecker,
046                @NotNull StatementFilter statementFilter,
047                boolean isAnnotationContext,
048                boolean collectAllCandidates,
049                boolean insideSafeCallChain
050        ) {
051            super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
052                  dataFlowInfoForArguments, callChecker, symbolUsageValidator, additionalTypeChecker, statementFilter, isAnnotationContext, collectAllCandidates, insideSafeCallChain);
053        }
054    
055        @NotNull
056        public static BasicCallResolutionContext create(
057                @NotNull BindingTrace trace,
058                @NotNull JetScope scope,
059                @NotNull Call call,
060                @NotNull JetType expectedType,
061                @NotNull DataFlowInfo dataFlowInfo,
062                @NotNull ContextDependency contextDependency,
063                @NotNull CheckValueArgumentsMode checkArguments,
064                @NotNull CallChecker callChecker,
065                @NotNull SymbolUsageValidator symbolUsageValidator,
066                @NotNull AdditionalTypeChecker additionalTypeChecker,
067                boolean isAnnotationContext
068        ) {
069            return new BasicCallResolutionContext(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments,
070                 new ResolutionResultsCacheImpl(), null,
071                 callChecker, symbolUsageValidator, additionalTypeChecker, StatementFilter.NONE, isAnnotationContext, false, false);
072        }
073    
074        @NotNull
075        public static BasicCallResolutionContext create(
076                @NotNull ResolutionContext context, @NotNull Call call, @NotNull CheckValueArgumentsMode checkArguments,
077                @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments
078        ) {
079            return new BasicCallResolutionContext(
080                    context.trace, context.scope, call, context.expectedType, context.dataFlowInfo, context.contextDependency, checkArguments,
081                    context.resolutionResultsCache, dataFlowInfoForArguments,
082                    context.callChecker, context.symbolUsageValidator, context.additionalTypeChecker,
083                    context.statementFilter, context.isAnnotationContext, context.collectAllCandidates, context.insideCallChain);
084        }
085    
086        @NotNull
087        public static BasicCallResolutionContext create(
088                @NotNull ResolutionContext context, @NotNull Call call, @NotNull CheckValueArgumentsMode checkArguments
089        ) {
090            return create(context, call, checkArguments, null);
091        }
092    
093        @Override
094        protected BasicCallResolutionContext create(
095                @NotNull BindingTrace trace,
096                @NotNull JetScope scope,
097                @NotNull DataFlowInfo dataFlowInfo,
098                @NotNull JetType expectedType,
099                @NotNull ContextDependency contextDependency,
100                @NotNull ResolutionResultsCache resolutionResultsCache,
101                @NotNull StatementFilter statementFilter,
102                boolean collectAllCandidates,
103                boolean insideSafeCallChain
104        ) {
105            return new BasicCallResolutionContext(
106                    trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
107                    dataFlowInfoForArguments, callChecker, symbolUsageValidator, additionalTypeChecker, statementFilter, isAnnotationContext, collectAllCandidates, insideSafeCallChain);
108        }
109    
110        @NotNull
111        public BasicCallResolutionContext replaceCall(@NotNull Call newCall) {
112            return new BasicCallResolutionContext(
113                    trace, scope, newCall, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
114                    dataFlowInfoForArguments, callChecker, symbolUsageValidator, additionalTypeChecker, statementFilter, isAnnotationContext, collectAllCandidates, insideCallChain);
115        }
116    }