diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt index 5883f2694bb..f631af080fa 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/CompletionUtils.kt @@ -264,7 +264,7 @@ private fun createKeywordElementWithSpace( return if (addSpaceAfter) { object: LookupElementDecorator(element) { override fun handleInsert(context: InsertionContext) { - WithTailInsertHandler.spaceTail().handleInsert(context, getDelegate()) + WithTailInsertHandler.SPACE.handleInsert(context, getDelegate()) } } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt index 6ed5ca93189..47fff4ec60a 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt @@ -99,9 +99,9 @@ class LookupElementsCollector( if (context.shouldAddCompletionChar() && !isJustTyping(context, this)) { when (context.getCompletionChar()) { - ',' -> WithTailInsertHandler.commaTail().postHandleInsert(context, getDelegate()) + ',' -> WithTailInsertHandler.COMMA.postHandleInsert(context, getDelegate()) - '=' -> WithTailInsertHandler.eqTail().postHandleInsert(context, getDelegate()) + '=' -> WithTailInsertHandler.EQ.postHandleInsert(context, getDelegate()) '!' -> { WithExpressionPrefixInsertHandler("!").postHandleInsert(context) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt index 1fc934194ac..72140cb05c2 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/NamedArgumentCompletion.kt @@ -73,7 +73,7 @@ object NamedArgumentCompletion { editor.getDocument().replaceString(context.getStartOffset(), context.getTailOffset(), text) editor.getCaretModel().moveToOffset(context.getStartOffset() + text.length()) - WithTailInsertHandler.eqTail().postHandleInsert(context, item) + WithTailInsertHandler.EQ.postHandleInsert(context, item) } } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinKeywordInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinKeywordInsertHandler.kt index cd4f01f1cc5..4166099623f 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinKeywordInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/KotlinKeywordInsertHandler.kt @@ -44,7 +44,7 @@ object KotlinKeywordInsertHandler : InsertHandler { override fun handleInsert(context: InsertionContext, item: LookupElement) { val keyword = item.lookupString if (keyword !in NO_SPACE_AFTER) { - WithTailInsertHandler.spaceTail().postHandleInsert(context, item) + WithTailInsertHandler.SPACE.postHandleInsert(context, item) } } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithTailInsertHandler.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithTailInsertHandler.kt index a85589b220e..bd85e567eee 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithTailInsertHandler.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/handlers/WithTailInsertHandler.kt @@ -86,12 +86,12 @@ class WithTailInsertHandler(val tailText: String, } companion object { - fun commaTail() = WithTailInsertHandler(",", spaceBefore = false, spaceAfter = true /*TODO: use code style option*/) - fun rparenthTail() = WithTailInsertHandler(")", spaceBefore = false, spaceAfter = false) - fun rbracketTail() = WithTailInsertHandler("]", spaceBefore = false, spaceAfter = false) - fun rbraceTail() = WithTailInsertHandler("}", spaceBefore = true, spaceAfter = false) - fun elseTail() = WithTailInsertHandler("else", spaceBefore = true, spaceAfter = true) - fun eqTail() = WithTailInsertHandler("=", spaceBefore = true, spaceAfter = true) /*TODO: use code style options*/ - fun spaceTail() = WithTailInsertHandler(" ", spaceBefore = false, spaceAfter = false, overwriteText = false) + val COMMA = WithTailInsertHandler(",", spaceBefore = false, spaceAfter = true /*TODO: use code style option*/) + val RPARENTH = WithTailInsertHandler(")", spaceBefore = false, spaceAfter = false) + val RBRACKET = WithTailInsertHandler("]", spaceBefore = false, spaceAfter = false) + val RBRACE = WithTailInsertHandler("}", spaceBefore = true, spaceAfter = false) + val ELSE = WithTailInsertHandler("else", spaceBefore = true, spaceAfter = true) + val EQ = WithTailInsertHandler("=", spaceBefore = true, spaceAfter = true) /*TODO: use code style options*/ + val SPACE = WithTailInsertHandler(" ", spaceBefore = false, spaceAfter = false, overwriteText = false) } } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt index fdbad07cdaf..6fd8e7b2fa8 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/Utils.kt @@ -65,31 +65,31 @@ fun LookupElement.addTail(tail: Tail?): LookupElement { Tail.COMMA -> object: LookupElementDecorator(this) { override fun handleInsert(context: InsertionContext) { - WithTailInsertHandler.commaTail().handleInsert(context, getDelegate()) + WithTailInsertHandler.COMMA.handleInsert(context, getDelegate()) } } Tail.RPARENTH -> object: LookupElementDecorator(this) { override fun handleInsert(context: InsertionContext) { - WithTailInsertHandler.rparenthTail().handleInsert(context, getDelegate()) + WithTailInsertHandler.RPARENTH.handleInsert(context, getDelegate()) } } Tail.RBRACKET -> object: LookupElementDecorator(this) { override fun handleInsert(context: InsertionContext) { - WithTailInsertHandler.rbracketTail().handleInsert(context, getDelegate()) + WithTailInsertHandler.RBRACKET.handleInsert(context, getDelegate()) } } Tail.ELSE -> object: LookupElementDecorator(this) { override fun handleInsert(context: InsertionContext) { - WithTailInsertHandler.elseTail().handleInsert(context, getDelegate()) + WithTailInsertHandler.ELSE.handleInsert(context, getDelegate()) } } Tail.RBRACE -> object: LookupElementDecorator(this) { override fun handleInsert(context: InsertionContext) { - WithTailInsertHandler.rbraceTail().handleInsert(context, getDelegate()) + WithTailInsertHandler.RBRACE.handleInsert(context, getDelegate()) } } }