Special behaviour for space completion char on function literal insertion
This commit is contained in:
@@ -104,6 +104,10 @@ public class JetFunctionInsertHandler implements InsertHandler<LookupElement> {
|
|||||||
if (openingBracketIndex == -1) {
|
if (openingBracketIndex == -1) {
|
||||||
// Insert ()/{} if it's not already exist
|
// Insert ()/{} if it's not already exist
|
||||||
if (braces) {
|
if (braces) {
|
||||||
|
if (context.getCompletionChar() == ' ') {
|
||||||
|
context.setAddCompletionChar(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (isInsertSpacesInOneLineFunctionEnabled(offsetElement.getProject())) {
|
if (isInsertSpacesInOneLineFunctionEnabled(offsetElement.getProject())) {
|
||||||
document.insertString(offset, " { }");
|
document.insertString(offset, " { }");
|
||||||
inBracketsShift = 1;
|
inBracketsShift = 1;
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
class Some
|
||||||
|
fun <T> Some.filter(predicate : (T) -> jet.Boolean) = throw UnsupportedOperationException()
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
Some().fil<caret>
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
class Some
|
||||||
|
fun <T> Some.filter(predicate : (T) -> jet.Boolean) = throw UnsupportedOperationException()
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
Some().filter { <caret> }
|
||||||
|
}
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ import java.io.File;
|
|||||||
public class CompletionHandlerTest extends LightCompletionTestCase {
|
public class CompletionHandlerTest extends LightCompletionTestCase {
|
||||||
|
|
||||||
public void testClassCompletionImport() {
|
public void testClassCompletionImport() {
|
||||||
doTest(CompletionType.BASIC, 2, "SortedSet", null);
|
doTest(CompletionType.BASIC, 2, "SortedSet", null, '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDoNotInsertImportForAlreadyImported() {
|
public void testDoNotInsertImportForAlreadyImported() {
|
||||||
@@ -46,7 +46,7 @@ public class CompletionHandlerTest extends LightCompletionTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testNonStandardArray() {
|
public void testNonStandardArray() {
|
||||||
doTest(CompletionType.BASIC, 2, "Array", "java.lang.reflect");
|
doTest(CompletionType.BASIC, 2, "Array", "java.lang.reflect", '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNoParamsFunction() {
|
public void testNoParamsFunction() {
|
||||||
@@ -79,6 +79,10 @@ public class CompletionHandlerTest extends LightCompletionTestCase {
|
|||||||
doTest();
|
doTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testFunctionLiteralInsertOnSpace() {
|
||||||
|
doTest(' ');
|
||||||
|
}
|
||||||
|
|
||||||
public void testFunctionLiteralInsertWhenNoSpacesForBraces() {
|
public void testFunctionLiteralInsertWhenNoSpacesForBraces() {
|
||||||
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
|
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
|
||||||
JetCodeStyleSettings jetSettings = settings.getCustomSettings(JetCodeStyleSettings.class);
|
JetCodeStyleSettings jetSettings = settings.getCustomSettings(JetCodeStyleSettings.class);
|
||||||
@@ -96,14 +100,18 @@ public class CompletionHandlerTest extends LightCompletionTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testHigherOrderFunctionWithArg() {
|
public void testHigherOrderFunctionWithArg() {
|
||||||
doTest(CompletionType.BASIC, 2, "filterNot", null);
|
doTest(CompletionType.BASIC, 2, "filterNot", null, '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doTest() {
|
public void doTest() {
|
||||||
doTest(CompletionType.BASIC, 2, null, null);
|
doTest('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doTest(CompletionType type, int time, @Nullable String lookupString, @Nullable String tailText) {
|
public void doTest(char completionChar) {
|
||||||
|
doTest(CompletionType.BASIC, 2, null, null, completionChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doTest(CompletionType type, int time, @Nullable String lookupString, @Nullable String tailText, char completionChar) {
|
||||||
try {
|
try {
|
||||||
configureByFileNoComplete(getBeforeFileName());
|
configureByFileNoComplete(getBeforeFileName());
|
||||||
setType(type);
|
setType(type);
|
||||||
@@ -113,7 +121,7 @@ public class CompletionHandlerTest extends LightCompletionTestCase {
|
|||||||
|
|
||||||
LookupElement item = getExistentLookupElement(lookupString, tailText);
|
LookupElement item = getExistentLookupElement(lookupString, tailText);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
selectItem(item, '\n');
|
selectItem(item, completionChar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user