KT-7259 Space inserted before parenthesis in completion of call

#KT-7259 Fixed
This commit is contained in:
Valentin Kipyatkov
2015-04-03 11:47:07 +03:00
parent 93d9e78047
commit e2979614ad
6 changed files with 44 additions and 4 deletions
@@ -152,11 +152,11 @@ public class KotlinFunctionInsertHandler(val caretPosition : CaretPosition, val
val closingBracket = if (braces) '}' else ')'
if (completionChar == Lookup.REPLACE_SELECT_CHAR) {
offset = skipSpaces(chars, offset)
if (offset < document.getTextLength()) {
if (chars[offset] == '<') {
val offset1 = skipSpaces(chars, offset)
if (offset1 < document.getTextLength()) {
if (chars[offset1] == '<') {
PsiDocumentManager.getInstance(context.getProject()).commitDocument(document)
val token = context.getFile().findElementAt(offset)!!
val token = context.getFile().findElementAt(offset1)!!
if (token.getNode().getElementType() == JetTokens.LT) {
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*/) {
@@ -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'
@@ -63,6 +63,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
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")
public void testNestedTypeArg() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/handlers/basic/NestedTypeArg.kt");
@@ -75,6 +81,12 @@ public class BasicCompletionHandlerTestGenerated extends AbstractBasicCompletion
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")
public void testSuperTypeArg() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/completion/handlers/basic/SuperTypeArg.kt");