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