[NI] Refactoring. Move properties from KotlinCall to external component
This commit is contained in:
committed by
Mikhail Zarechenskiy
parent
ef93088a42
commit
93d80c252f
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.IsDescriptorFromSourcePredicateImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.KotlinResolutionExternalPredicatesImpl
|
||||
import org.jetbrains.kotlin.resolve.lazy.*
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
|
||||
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory
|
||||
@@ -61,7 +61,7 @@ fun StorageComponentContainer.configureModule(
|
||||
|
||||
private fun StorageComponentContainer.configurePlatformIndependentComponents() {
|
||||
useImpl<SupertypeLoopCheckerImpl>()
|
||||
useInstance(IsDescriptorFromSourcePredicateImpl)
|
||||
useImpl<KotlinResolutionExternalPredicatesImpl>()
|
||||
}
|
||||
|
||||
fun StorageComponentContainer.configureModule(
|
||||
|
||||
-6
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.resolve.calls.tower
|
||||
import org.jetbrains.kotlin.builtins.createFunctionType
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
@@ -41,7 +40,6 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategyImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.util.CallMaker
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.isHiddenInResolution
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||
@@ -221,8 +219,4 @@ class KotlinResolutionCallbacksImpl(
|
||||
|
||||
expressionTypingServices.getTypeInfo(psiCallArgument.collectionLiteralExpression, actualContext)
|
||||
}
|
||||
|
||||
override fun isHiddenInResolution(descriptor: DeclarationDescriptor, isSuperCall: Boolean): Boolean {
|
||||
return descriptor.isHiddenInResolution(languageVersionSettings, isSuperCall)
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.tower
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isConventionCall
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isInfixCall
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isSuperOrDelegatingConstructorCall
|
||||
import org.jetbrains.kotlin.resolve.calls.components.KotlinResolutionExternalPredicates
|
||||
import org.jetbrains.kotlin.resolve.calls.model.KotlinCall
|
||||
import org.jetbrains.kotlin.resolve.isHiddenInResolution
|
||||
|
||||
class KotlinResolutionExternalPredicatesImpl(
|
||||
private val languageVersionSettings: LanguageVersionSettings
|
||||
) : KotlinResolutionExternalPredicates {
|
||||
override fun isDescriptorFromSource(descriptor: CallableDescriptor) =
|
||||
DescriptorToSourceUtils.descriptorToDeclaration(descriptor) != null
|
||||
|
||||
override fun isInfixCall(kotlinCall: KotlinCall) =
|
||||
kotlinCall is PSIKotlinCallImpl && isInfixCall(kotlinCall.psiCall)
|
||||
|
||||
override fun isOperatorCall(kotlinCall: KotlinCall) =
|
||||
(kotlinCall is PSIKotlinCallForInvoke) ||
|
||||
(kotlinCall is PSIKotlinCallImpl && isConventionCall(kotlinCall.psiCall))
|
||||
|
||||
override fun isSuperOrDelegatingConstructorCall(kotlinCall: KotlinCall) =
|
||||
kotlinCall is PSIKotlinCallImpl && isSuperOrDelegatingConstructorCall(kotlinCall.psiCall)
|
||||
|
||||
override fun isHiddenInResolution(descriptor: DeclarationDescriptor, kotlinCall: KotlinCall) =
|
||||
descriptor.isHiddenInResolution(languageVersionSettings, isSuperOrDelegatingConstructorCall(kotlinCall))
|
||||
}
|
||||
@@ -39,10 +39,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.createLookupLocation
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall
|
||||
import org.jetbrains.kotlin.resolve.calls.components.ArgumentsToParametersMapper
|
||||
import org.jetbrains.kotlin.resolve.calls.components.CallableReferenceResolver
|
||||
import org.jetbrains.kotlin.resolve.calls.components.KotlinResolutionCallbacks
|
||||
import org.jetbrains.kotlin.resolve.calls.components.TypeArgumentsToParametersMapper
|
||||
import org.jetbrains.kotlin.resolve.calls.components.*
|
||||
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintInjector
|
||||
@@ -75,11 +72,12 @@ class PSICallResolver(
|
||||
private val dynamicCallableDescriptors: DynamicCallableDescriptors,
|
||||
private val syntheticScopes: SyntheticScopes,
|
||||
private val argumentsToParametersMapper: ArgumentsToParametersMapper,
|
||||
val typeArgumentsToParametersMapper: TypeArgumentsToParametersMapper,
|
||||
val resultTypeResolver: ResultTypeResolver,
|
||||
val callableReferenceResolver: CallableReferenceResolver,
|
||||
val constraintInjector: ConstraintInjector,
|
||||
val reflectionTypes: ReflectionTypes,
|
||||
private val externalPredicates: KotlinResolutionExternalPredicates,
|
||||
private val typeArgumentsToParametersMapper: TypeArgumentsToParametersMapper,
|
||||
private val resultTypeResolver: ResultTypeResolver,
|
||||
private val callableReferenceResolver: CallableReferenceResolver,
|
||||
private val constraintInjector: ConstraintInjector,
|
||||
private val reflectionTypes: ReflectionTypes,
|
||||
private val kotlinToResolvedCallTransformer: KotlinToResolvedCallTransformer,
|
||||
private val kotlinCallResolver: KotlinCallResolver,
|
||||
private val typeApproximator: TypeApproximator,
|
||||
@@ -179,7 +177,8 @@ class PSICallResolver(
|
||||
}
|
||||
|
||||
private fun createCallContext(scopeTower: ASTScopeTower, resolutionCallbacks: KotlinResolutionCallbacks) =
|
||||
KotlinCallContext(scopeTower, resolutionCallbacks, argumentsToParametersMapper, typeArgumentsToParametersMapper, resultTypeResolver,
|
||||
KotlinCallContext(scopeTower, resolutionCallbacks, externalPredicates, argumentsToParametersMapper,
|
||||
typeArgumentsToParametersMapper, resultTypeResolver,
|
||||
callableReferenceResolver, constraintInjector, reflectionTypes)
|
||||
|
||||
private fun <D : CallableDescriptor> convertToOverloadResolutionResults(
|
||||
|
||||
@@ -18,11 +18,7 @@ package org.jetbrains.kotlin.resolve.calls.tower
|
||||
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.Call
|
||||
import org.jetbrains.kotlin.resolve.calls.model.KotlinCallKind
|
||||
import org.jetbrains.kotlin.resolve.calls.CallTransformer
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isConventionCall
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isInfixCall
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isSuperOrDelegatingConstructorCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||
@@ -57,11 +53,7 @@ class PSIKotlinCallImpl(
|
||||
override val externalArgument: KotlinCallArgument?,
|
||||
override val startingDataFlowInfo: DataFlowInfo,
|
||||
override val resultDataFlowInfo: DataFlowInfo
|
||||
) : PSIKotlinCall() {
|
||||
override val isInfixCall: Boolean get() = isInfixCall(psiCall)
|
||||
override val isOperatorCall: Boolean get() = isConventionCall(psiCall)
|
||||
override val isSuperOrDelegatingConstructorCall: Boolean get() = isSuperOrDelegatingConstructorCall(psiCall)
|
||||
}
|
||||
) : PSIKotlinCall()
|
||||
|
||||
class PSIKotlinCallForVariable(
|
||||
val baseCall: PSIKotlinCallImpl,
|
||||
@@ -80,10 +72,6 @@ class PSIKotlinCallForVariable(
|
||||
override val psiCall: Call = CallTransformer.stripCallArguments(baseCall.psiCall).let {
|
||||
if (explicitReceiver == null) CallTransformer.stripReceiver(it) else it
|
||||
}
|
||||
|
||||
override val isInfixCall: Boolean get() = false
|
||||
override val isOperatorCall: Boolean get() = false
|
||||
override val isSuperOrDelegatingConstructorCall: Boolean get() = false
|
||||
}
|
||||
|
||||
class PSIKotlinCallForInvoke(
|
||||
@@ -102,10 +90,6 @@ class PSIKotlinCallForInvoke(
|
||||
override val psiCall: Call
|
||||
override val tracingStrategy: TracingStrategy
|
||||
|
||||
override val isInfixCall: Boolean get() = false
|
||||
override val isOperatorCall: Boolean get() = true
|
||||
override val isSuperOrDelegatingConstructorCall: Boolean get() = false
|
||||
|
||||
init {
|
||||
val variableReceiver = dispatchReceiverForInvokeExtension ?: explicitReceiver
|
||||
val explicitExtensionReceiver = if (dispatchReceiverForInvokeExtension == null) null else explicitReceiver
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.tower
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.components.IsDescriptorFromSourcePredicate
|
||||
|
||||
object IsDescriptorFromSourcePredicateImpl: IsDescriptorFromSourcePredicate {
|
||||
override fun invoke(p1: CallableDescriptor) = DescriptorToSourceUtils.descriptorToDeclaration(p1) != null
|
||||
}
|
||||
Reference in New Issue
Block a user