From 725704e70fcf97792b0dfada25d9af63359f2e02 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 19 Jan 2018 10:54:41 +0300 Subject: [PATCH] ExclExclCallFixes: reformat --- .../kotlin/idea/quickfix/ExclExclCallFixes.kt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt index b7c6336f844..aff6f4653fd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt @@ -55,7 +55,7 @@ class RemoveExclExclCallFix(psiElement: PsiElement) : ExclExclCallFix(psiElement override fun getText(): String = KotlinBundle.message("remove.unnecessary.non.null.assertion") override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean = - getExclExclPostfixExpression() != null + getExclExclPostfixExpression() != null override fun invoke(project: Project, editor: Editor?, file: KtFile) { if (!FileModificationService.getInstance().prepareFileForWrite(file)) return @@ -74,8 +74,7 @@ class RemoveExclExclCallFix(psiElement: PsiElement) : ExclExclCallFix(psiElement } companion object : KotlinSingleIntentionActionFactory() { - override fun createAction(diagnostic: Diagnostic): IntentionAction - = RemoveExclExclCallFix(diagnostic.psiElement) + override fun createAction(diagnostic: Diagnostic): IntentionAction = RemoveExclExclCallFix(diagnostic.psiElement) } } @@ -85,7 +84,7 @@ class AddExclExclCallFix(psiElement: PsiElement, val checkImplicitReceivers: Boo override fun getText() = KotlinBundle.message("introduce.non.null.assertion") override fun isAvailable(project: Project, editor: Editor?, file: KtFile): Boolean = - getExpressionForIntroduceCall() != null + getExpressionForIntroduceCall() != null override fun invoke(project: Project, editor: Editor?, file: KtFile) { if (!FileModificationService.getInstance().prepareFileForWrite(file)) return @@ -130,13 +129,12 @@ class AddExclExclCallFix(psiElement: PsiElement, val checkImplicitReceivers: Boo if (checkImplicitReceivers && psiElement.getResolvedCall(context)?.getImplicitReceiverValue() != null) { val expressionToReplace = psiElement.parent as? KtCallExpression ?: psiElement expressionToReplace.expressionForCall(implicitReceiver = true) - } - else { + } else { context[BindingContext.EXPRESSION_TYPE_INFO, psiElement]?.let { val type = it.type if (type != null) { val nullability = it.dataFlowInfo.getStableNullability( - DataFlowValueFactory.createDataFlowValue(psiElement, type, context, psiElement.findModuleDescriptor()) + DataFlowValueFactory.createDataFlowValue(psiElement, type, context, psiElement.findModuleDescriptor()) ) if (!nullability.canBeNonNull()) return null } @@ -153,7 +151,7 @@ class AddExclExclCallFix(psiElement: PsiElement, val checkImplicitReceivers: Boo } } -object SmartCastImpossibleExclExclFixFactory: KotlinSingleIntentionActionFactory() { +object SmartCastImpossibleExclExclFixFactory : KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): IntentionAction? { if (diagnostic.factory !== Errors.SMARTCAST_IMPOSSIBLE) return null val element = diagnostic.psiElement as? KtExpression ?: return null @@ -179,10 +177,10 @@ object MissingIteratorExclExclFixFactory : KotlinSingleIntentionActionFactory() val analyze = element.analyze(BodyResolveMode.PARTIAL) val type = analyze.getType(element) if (type == null || !TypeUtils.isNullableType(type)) return null - + val descriptor = type.constructor.declarationDescriptor - fun hasIteratorFunction(classifierDescriptor: ClassifierDescriptor?) : Boolean { + fun hasIteratorFunction(classifierDescriptor: ClassifierDescriptor?): Boolean { if (classifierDescriptor !is ClassDescriptor) return false val memberScope = classifierDescriptor.unsubstitutedMemberScope