Override omitting parentheses on tab char if they are already placed
This commit is contained in:
@@ -77,12 +77,15 @@ public class JetFunctionInsertHandler(val caretPosition : CaretPosition, val bra
|
|||||||
val document = context.getDocument()
|
val document = context.getDocument()
|
||||||
val completionChar = context.getCompletionChar()
|
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 openingBracket = if (braces) '{' else '('
|
||||||
val closingBracket = if (braces) '}' else ')'
|
val closingBracket = if (braces) '}' else ')'
|
||||||
|
|
||||||
var documentText = document.getText()
|
|
||||||
var openingBracketIndex = indexOfSkippingSpace(documentText, openingBracket, offset)
|
var openingBracketIndex = indexOfSkippingSpace(documentText, openingBracket, offset)
|
||||||
var inBracketsShift = 0
|
var inBracketsShift = 0
|
||||||
if (openingBracketIndex == -1) {
|
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 com.intellij.codeInsight.lookup.LookupElementPresentation
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import com.intellij.openapi.application.Result
|
import com.intellij.openapi.application.Result
|
||||||
import kotlin.properties.Delegates
|
|
||||||
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture
|
import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture
|
||||||
|
import kotlin.properties.Delegates
|
||||||
|
|
||||||
public class CompletionHandlerTest() : JetLightCodeInsightFixtureTestCase() {
|
public class CompletionHandlerTest() : JetLightCodeInsightFixtureTestCase() {
|
||||||
fun testClassCompletionImport() = doTest(CompletionType.BASIC, 2, "SortedSet", null, '\n')
|
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 testHigherOrderFunctionWithArg() = doTest(CompletionType.BASIC, 2, "filterNot", null, '\n')
|
||||||
|
|
||||||
|
fun testForceParenthesisForTabChar() = doTest(CompletionType.BASIC, 0, "some", null, '\t')
|
||||||
|
|
||||||
var fixture by Delegates.notNull<JavaCodeInsightTestFixture>()
|
var fixture by Delegates.notNull<JavaCodeInsightTestFixture>()
|
||||||
|
|
||||||
protected override fun setUp() {
|
protected override fun setUp() {
|
||||||
|
|||||||
Reference in New Issue
Block a user