Override omitting parentheses on tab char if they are already placed

This commit is contained in:
Nikolay Krasko
2013-08-26 14:35:25 +04:00
parent cb10c53040
commit d399465bf3
4 changed files with 24 additions and 3 deletions
@@ -77,12 +77,15 @@ public class JetFunctionInsertHandler(val caretPosition : CaretPosition, val bra
val document = context.getDocument()
val completionChar = context.getCompletionChar()
val braces = bracketType == BracketType.BRACES && completionChar != '('
var documentText = document.getText()
val forceParenthesis = bracketType == BracketType.BRACES && completionChar == '\t' && documentText.charAt(offset) == '('
val braces = bracketType == BracketType.BRACES && completionChar != '(' && !forceParenthesis
val openingBracket = if (braces) '{' else '('
val closingBracket = if (braces) '}' else ')'
var documentText = document.getText()
var openingBracketIndex = indexOfSkippingSpace(documentText, openingBracket, offset)
var inBracketsShift = 0
if (openingBracketIndex == -1) {
@@ -0,0 +1,8 @@
package testing
fun some(f: () -> Unit) = 12
fun other() = 12
fun test() {
som<caret>other()
}
@@ -0,0 +1,8 @@
package testing
fun some(f: () -> Unit) = 12
fun other() = 12
fun test() {
some(<caret>)
}
@@ -30,8 +30,8 @@ import com.intellij.codeInsight.lookup.LookupManager
import com.intellij.codeInsight.lookup.LookupElementPresentation
import org.junit.Assert
import com.intellij.openapi.application.Result
import kotlin.properties.Delegates
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture
import kotlin.properties.Delegates
public class CompletionHandlerTest() : JetLightCodeInsightFixtureTestCase() {
fun testClassCompletionImport() = doTest(CompletionType.BASIC, 2, "SortedSet", null, '\n')
@@ -68,6 +68,8 @@ public class CompletionHandlerTest() : JetLightCodeInsightFixtureTestCase() {
fun testHigherOrderFunctionWithArg() = doTest(CompletionType.BASIC, 2, "filterNot", null, '\n')
fun testForceParenthesisForTabChar() = doTest(CompletionType.BASIC, 0, "some", null, '\t')
var fixture by Delegates.notNull<JavaCodeInsightTestFixture>()
protected override fun setUp() {