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 ResolutionResultsCache resolutionResultsCache,
041                @NotNull LabelResolver labelResolver,
042                @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments,
043                @NotNull CallResolverExtension callResolverExtension,
044                boolean isAnnotationContext
045        ) {
046            return new BasicCallResolutionContext(
047                    trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache, labelResolver,
048                    dataFlowInfoForArguments, callResolverExtension, isAnnotationContext);
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.resolutionResultsCache, context.labelResolver, dataFlowInfoForArguments, context.callResolverExtension,
059                    context.isAnnotationContext);
060        }
061    
062        @NotNull
063        public static BasicCallResolutionContext create(
064                @NotNull ResolutionContext context, @NotNull Call call, @NotNull CheckValueArgumentsMode checkArguments
065        ) {
066            return create(context, call, checkArguments, null);
067        }
068    
069        private BasicCallResolutionContext(
070                BindingTrace trace, JetScope scope, Call call, JetType expectedType,
071                DataFlowInfo dataFlowInfo, ContextDependency contextDependency, CheckValueArgumentsMode checkArguments,
072                ResolutionResultsCache resolutionResultsCache, LabelResolver labelResolver,
073                MutableDataFlowInfoForArguments dataFlowInfoForArguments, CallResolverExtension callResolverExtension,
074                boolean isAnnotationContext
075        ) {
076            super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache, labelResolver,
077                  dataFlowInfoForArguments, callResolverExtension, isAnnotationContext);
078        }
079    
080        @Override
081        protected BasicCallResolutionContext create(
082                @NotNull BindingTrace trace,
083                @NotNull JetScope scope,
084                @NotNull DataFlowInfo dataFlowInfo,
085                @NotNull JetType expectedType,
086                @NotNull ContextDependency contextDependency,
087                @NotNull ResolutionResultsCache resolutionResultsCache,
088                @NotNull LabelResolver labelResolver
089        ) {
090            return create(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
091                          labelResolver, dataFlowInfoForArguments, callResolverExtension, isAnnotationContext);
092        }
093    
094        public BasicCallResolutionContext replaceCall(@NotNull Call newCall) {
095            return create(trace, scope, newCall, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache,
096                          labelResolver, dataFlowInfoForArguments, callResolverExtension, isAnnotationContext);
097        }
098    }