diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt index 2922cbc229f..9d8775440ab 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/inline/KotlinInlineValHandler.kt @@ -47,7 +47,7 @@ import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelectorOrThis class KotlinInlineValHandler(private val withPrompt: Boolean) : InlineActionHandler() { - constructor(): this(withPrompt = true) + constructor() : this(withPrompt = true) override fun isEnabledForLanguage(l: Language) = l == KotlinLanguage.INSTANCE @@ -92,8 +92,7 @@ class KotlinInlineValHandler(private val withPrompt: Boolean) : InlineActionHand readReplacement = buildCodeToInline(declaration, descriptor.type, isTypeExplicit, initialization.value, false, editor) ?: return writeReplacement = null assignmentToDelete = initialization.assignment - } - else { + } else { readReplacement = getter?.let { buildCodeToInline(getter, descriptor.type, isTypeExplicit, getter.bodyExpression!!, getter.hasBlockBody(), editor) ?: return } @@ -111,8 +110,7 @@ class KotlinInlineValHandler(private val withPrompt: Boolean) : InlineActionHand project.checkConflictsInteractively(conflictsCopy) { performRefactoring(declaration, readReplacement, writeReplacement, assignmentToDelete, editor, hasHighlightings) } - } - else { + } else { performRefactoring(declaration, readReplacement, writeReplacement, assignmentToDelete, editor, hasHighlightings) } } @@ -145,10 +143,10 @@ class KotlinInlineValHandler(private val withPrompt: Boolean) : InlineActionHand private data class Initialization(val value: KtExpression, val assignment: KtBinaryExpression?) private fun extractInitialization( - declaration: KtProperty, - referenceExpressions: Collection, - project: Project, - editor: Editor? + declaration: KtProperty, + referenceExpressions: Collection, + project: Project, + editor: Editor? ): Initialization? { val writeUsages = referenceExpressions.filter { it.readWriteAccess(useResolveForReadWrite = true) != ReferenceAccess.READ } @@ -159,11 +157,10 @@ class KotlinInlineValHandler(private val withPrompt: Boolean) : InlineActionHand return null } return Initialization(initializerInDeclaration, assignment = null) - } - else { + } else { val assignment = writeUsages.singleOrNull() - ?.getAssignmentByLHS() - ?.takeIf { it.operationToken == KtTokens.EQ } + ?.getAssignmentByLHS() + ?.takeIf { it.operationToken == KtTokens.EQ } val initializer = assignment?.right if (initializer == null) { reportAmbiguousAssignment(project, editor, declaration.name!!, writeUsages) @@ -174,12 +171,12 @@ class KotlinInlineValHandler(private val withPrompt: Boolean) : InlineActionHand } private fun performRefactoring( - declaration: KtProperty, - readReplacement: CodeToInline?, - writeReplacement: CodeToInline?, - assignmentToDelete: KtBinaryExpression?, - editor: Editor?, - hasHighlightings: Boolean + declaration: KtProperty, + readReplacement: CodeToInline?, + writeReplacement: CodeToInline?, + assignmentToDelete: KtBinaryExpression?, + editor: Editor?, + hasHighlightings: Boolean ) { val replacementStrategy = PropertyUsageReplacementStrategy(readReplacement, writeReplacement) val reference = editor?.findSimpleNameReference() @@ -192,8 +189,7 @@ class KotlinInlineValHandler(private val withPrompt: Boolean) : InlineActionHand val statusBar = WindowManager.getInstance().getStatusBar(declaration.project) statusBar?.info = RefactoringBundle.message("press.escape.to.remove.the.highlighting") } - } - else { + } else { dialog.doAction() } } @@ -205,7 +201,13 @@ class KotlinInlineValHandler(private val withPrompt: Boolean) : InlineActionHand } private fun showErrorHint(project: Project, editor: Editor?, message: String) { - CommonRefactoringUtil.showErrorHint(project, editor, message, RefactoringBundle.message("inline.variable.title"), HelpID.INLINE_VARIABLE) + CommonRefactoringUtil.showErrorHint( + project, + editor, + message, + RefactoringBundle.message("inline.variable.title"), + HelpID.INLINE_VARIABLE + ) } }