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