From 41fd9fff765b5bb67b39ac8ed72d519c104ad6f6 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Thu, 26 Sep 2019 19:21:31 +0300 Subject: [PATCH] Minor: reformat CreateTypeParameterUnmatchedTypeArgumentActionFactory --- ...meterUnmatchedTypeArgumentActionFactory.kt | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createTypeParameter/CreateTypeParameterUnmatchedTypeArgumentActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createTypeParameter/CreateTypeParameterUnmatchedTypeArgumentActionFactory.kt index 55ec90be953..71fdee798c8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createTypeParameter/CreateTypeParameterUnmatchedTypeArgumentActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createTypeParameter/CreateTypeParameterUnmatchedTypeArgumentActionFactory.kt @@ -35,48 +35,48 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.scopes.utils.findClassifier -object CreateTypeParameterUnmatchedTypeArgumentActionFactory : KotlinIntentionActionFactoryWithDelegate() { +object CreateTypeParameterUnmatchedTypeArgumentActionFactory : + KotlinIntentionActionFactoryWithDelegate() { override fun getElementOfInterest(diagnostic: Diagnostic) = diagnostic.psiElement as? KtTypeArgumentList override fun extractFixData(element: KtTypeArgumentList, diagnostic: Diagnostic): CreateTypeParameterData? { val project = element.project val typeArguments = element.arguments val context = element.analyze() - val parent = element.parent - val referencedDescriptor = when (parent) { + val referencedDescriptor = when (val parent = element.parent) { is KtUserType -> context[BindingContext.REFERENCE_TARGET, parent.referenceExpression] is KtCallElement -> parent.getResolvedCall(context)?.resultingDescriptor else -> null } ?: return null val referencedDeclaration = DescriptorToSourceUtilsIde.getAnyDeclaration(project, referencedDescriptor) as? KtTypeParameterListOwner - ?: return null + ?: return null val missingParameterCount = typeArguments.size - referencedDeclaration.typeParameters.size if (missingParameterCount <= 0) return null val scope = referencedDeclaration.getResolutionScope() val suggestedNames = KotlinNameSuggester.suggestNamesForTypeParameters( - missingParameterCount, - CollectingNameValidator(referencedDeclaration.typeParameters.mapNotNull { it.name }) { - scope.findClassifier(Name.identifier(it), NoLookupLocation.FROM_IDE) == null - } + missingParameterCount, + CollectingNameValidator(referencedDeclaration.typeParameters.mapNotNull { it.name }) { + scope.findClassifier(Name.identifier(it), NoLookupLocation.FROM_IDE) == null + } ) val typeParameterInfos = suggestedNames.map { name -> - TypeParameterInfo( - name, - null, - createFakeTypeParameterDescriptor(referencedDescriptor, name) - ) - } + TypeParameterInfo( + name, + null, + createFakeTypeParameterDescriptor(referencedDescriptor, name) + ) + } return CreateTypeParameterData(referencedDeclaration, typeParameterInfos) } override fun createFixes( - originalElementPointer: SmartPsiElementPointer, - diagnostic: Diagnostic, - quickFixDataFactory: () -> CreateTypeParameterData? + originalElementPointer: SmartPsiElementPointer, + diagnostic: Diagnostic, + quickFixDataFactory: () -> CreateTypeParameterData? ): List { - return QuickFixWithDelegateFactory factory@ { + return QuickFixWithDelegateFactory factory@{ val originalElement = originalElementPointer.element ?: return@factory null val data = quickFixDataFactory() ?: return@factory null if (!data.declaration.isWritable) return@factory null