KotlinChangeSignatureData: cleanup code

This commit is contained in:
Dmitry Gridin
2019-09-03 18:30:42 +07:00
parent 7271e65851
commit cbdda6f9a8
@@ -78,9 +78,11 @@ class KotlinChangeSignatureData(
val receiverName = suggestReceiverNames(baseDeclaration.project, baseDescriptor).first() val receiverName = suggestReceiverNames(baseDeclaration.project, baseDescriptor).first()
val receiverTypeText = (baseDeclaration as? KtCallableDeclaration)?.receiverTypeReference?.text val receiverTypeText = (baseDeclaration as? KtCallableDeclaration)?.receiverTypeReference?.text
?: IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.renderType(receiverType) ?: IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.renderType(receiverType)
return KotlinParameterInfo(callableDescriptor = baseDescriptor, return KotlinParameterInfo(
callableDescriptor = baseDescriptor,
name = receiverName, name = receiverName,
originalTypeInfo = KotlinTypeInfo(false, receiverType, receiverTypeText)) originalTypeInfo = KotlinTypeInfo(false, receiverType, receiverTypeText)
)
} }
override val original: KotlinMethodDescriptor override val original: KotlinMethodDescriptor
@@ -89,7 +91,7 @@ class KotlinChangeSignatureData(
override val primaryCallables: Collection<KotlinCallableDefinitionUsage<PsiElement>> by lazy { override val primaryCallables: Collection<KotlinCallableDefinitionUsage<PsiElement>> by lazy {
descriptorsForSignatureChange.map { descriptorsForSignatureChange.map {
val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(baseDeclaration.project, it) val declaration = DescriptorToSourceUtilsIde.getAnyDeclaration(baseDeclaration.project, it)
assert(declaration != null) { "No declaration found for " + baseDescriptor } assert(declaration != null) { "No declaration found for $baseDescriptor" }
KotlinCallableDefinitionUsage(declaration!!, it, null, null) KotlinCallableDefinitionUsage(declaration!!, it, null, null)
} }
} }
@@ -104,8 +106,7 @@ class KotlinChangeSignatureData(
if (primaryDeclaration.isExpectDeclaration()) { if (primaryDeclaration.isExpectDeclaration()) {
return@flatMapTo primaryDeclaration.actualsForExpected().mapNotNull { return@flatMapTo primaryDeclaration.actualsForExpected().mapNotNull {
val descriptor = it.unsafeResolveToDescriptor() val callableDescriptor = when (val descriptor = it.unsafeResolveToDescriptor()) {
val callableDescriptor = when (descriptor) {
is CallableDescriptor -> descriptor is CallableDescriptor -> descriptor
is ClassDescriptor -> descriptor.unsubstitutedPrimaryConstructor ?: return@mapNotNull null is ClassDescriptor -> descriptor.unsubstitutedPrimaryConstructor ?: return@mapNotNull null
else -> return@mapNotNull null else -> return@mapNotNull null