KT-7259 Space inserted before parenthesis in completion of call
#KT-7259 Fixed
This commit is contained in:
+4
-4
@@ -152,11 +152,11 @@ public class KotlinFunctionInsertHandler(val caretPosition : CaretPosition, val
|
|||||||
val closingBracket = if (braces) '}' else ')'
|
val closingBracket = if (braces) '}' else ')'
|
||||||
|
|
||||||
if (completionChar == Lookup.REPLACE_SELECT_CHAR) {
|
if (completionChar == Lookup.REPLACE_SELECT_CHAR) {
|
||||||
offset = skipSpaces(chars, offset)
|
val offset1 = skipSpaces(chars, offset)
|
||||||
if (offset < document.getTextLength()) {
|
if (offset1 < document.getTextLength()) {
|
||||||
if (chars[offset] == '<') {
|
if (chars[offset1] == '<') {
|
||||||
PsiDocumentManager.getInstance(context.getProject()).commitDocument(document)
|
PsiDocumentManager.getInstance(context.getProject()).commitDocument(document)
|
||||||
val token = context.getFile().findElementAt(offset)!!
|
val token = context.getFile().findElementAt(offset1)!!
|
||||||
if (token.getNode().getElementType() == JetTokens.LT) {
|
if (token.getNode().getElementType() == JetTokens.LT) {
|
||||||
val parent = token.getParent()
|
val parent = token.getParent()
|
||||||
if (parent is JetTypeArgumentList && parent.getText().indexOf('\n') < 0/* if type argument list is on multiple lines this is more likely wrong parsing*/) {
|
if (parent is JetTypeArgumentList && parent.getText().indexOf('\n') < 0/* if type argument list is on multiple lines this is more likely wrong parsing*/) {
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun <T> foo() {}
|
||||||
|
|
||||||
|
fun use() = f<caret> <String>()
|
||||||
|
|
||||||
|
// ELEMENT: foo
|
||||||
|
// CHAR: '\t'
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fun <T> foo() {}
|
||||||
|
|
||||||
|
fun use() = foo <String>()<caret>
|
||||||
|
|
||||||
|
// ELEMENT: foo
|
||||||
|
// CHAR: '\t'
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
class Pair(val first: Int, val second: Int)
|
||||||
|
|
||||||
|
fun foo(p: Pair) {
|
||||||
|
if (p.<caret>first < p.second)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ELEMENT: hashCode
|
||||||
|
// CHAR: '\t'
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
class Pair(val first: Int, val second: Int)
|
||||||
|
|
||||||
|
fun foo(p: Pair) {
|
||||||
|
if (p.hashCode()<caret> < p.second)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ELEMENT: hashCode
|
||||||
|
// CHAR: '\t'
|
||||||
+12
@@ -63,6 +63,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("GenericFunctionWithTab2.kt")
|
||||||
|
public void testGenericFunctionWithTab2() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/handlers/basic/GenericFunctionWithTab2.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("NestedTypeArg.kt")
|
@TestMetadata("NestedTypeArg.kt")
|
||||||
public void testNestedTypeArg() throws Exception {
|
public void testNestedTypeArg() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/handlers/basic/NestedTypeArg.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/handlers/basic/NestedTypeArg.kt");
|
||||||
@@ -75,6 +81,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("SpaceAfterParenthesisBug.kt")
|
||||||
|
public void testSpaceAfterParenthesisBug() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/handlers/basic/SpaceAfterParenthesisBug.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("SuperTypeArg.kt")
|
@TestMetadata("SuperTypeArg.kt")
|
||||||
public void testSuperTypeArg() throws Exception {
|
public void testSuperTypeArg() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/handlers/basic/SuperTypeArg.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/handlers/basic/SuperTypeArg.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user