diff --git a/annotations/com/intellij/codeInsight/lookup/annotations.xml b/annotations/com/intellij/codeInsight/lookup/annotations.xml
new file mode 100644
index 00000000000..ae51da930f5
--- /dev/null
+++ b/annotations/com/intellij/codeInsight/lookup/annotations.xml
@@ -0,0 +1,9 @@
+
+ -
+
+
+ -
+
+
+
\ No newline at end of file
diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml
index 8eaeb45628b..26b3691f0dd 100644
--- a/idea/src/META-INF/plugin.xml
+++ b/idea/src/META-INF/plugin.xml
@@ -202,7 +202,7 @@
-
+
diff --git a/idea/src/org/jetbrains/jet/plugin/completion/DescriptorLookupConverter.java b/idea/src/org/jetbrains/jet/plugin/completion/DescriptorLookupConverter.java
index 6058334de9f..8b823a92dc4 100644
--- a/idea/src/org/jetbrains/jet/plugin/completion/DescriptorLookupConverter.java
+++ b/idea/src/org/jetbrains/jet/plugin/completion/DescriptorLookupConverter.java
@@ -37,14 +37,13 @@ import org.jetbrains.jet.lang.resolve.lazy.KotlinCodeAnalyzer;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.plugin.JetDescriptorIconProvider;
-import org.jetbrains.jet.plugin.completion.handlers.*;
+import org.jetbrains.jet.plugin.completion.handlers.JetClassInsertHandler;
+import org.jetbrains.jet.plugin.completion.handlers.JetJavaClassInsertHandler;
import org.jetbrains.jet.renderer.DescriptorRenderer;
import java.util.List;
-import static org.jetbrains.jet.plugin.completion.handlers.JetFunctionInsertHandler.EMPTY_FUNCTION_HANDLER;
-import static org.jetbrains.jet.plugin.completion.handlers.JetFunctionInsertHandler.PARAMS_BRACES_FUNCTION_HANDLER;
-import static org.jetbrains.jet.plugin.completion.handlers.JetFunctionInsertHandler.PARAMS_PARENTHESIS_FUNCTION_HANDLER;
+import static org.jetbrains.jet.plugin.completion.handlers.JetFunctionInsertHandler.*;
public final class DescriptorLookupConverter {
private DescriptorLookupConverter() {}
@@ -102,7 +101,7 @@ public final class DescriptorLookupConverter {
}
@Nullable
- private static InsertHandler getInsertHandler(@NotNull DeclarationDescriptor descriptor) {
+ public static InsertHandler getInsertHandler(@NotNull DeclarationDescriptor descriptor) {
if (descriptor instanceof FunctionDescriptor) {
FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor;
diff --git a/idea/src/org/jetbrains/jet/plugin/completion/JetCompletionCharFilter.kt b/idea/src/org/jetbrains/jet/plugin/completion/JetCompletionCharFilter.kt
new file mode 100644
index 00000000000..60fa016703b
--- /dev/null
+++ b/idea/src/org/jetbrains/jet/plugin/completion/JetCompletionCharFilter.kt
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2010-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.jet.plugin.completion
+
+import com.intellij.codeInsight.lookup.CharFilter
+import com.intellij.codeInsight.lookup.Lookup
+import com.intellij.codeInsight.lookup.CharFilter.Result
+import org.jetbrains.jet.lang.psi.JetFile
+import org.jetbrains.jet.plugin.completion.handlers.JetFunctionInsertHandler
+
+public open class JetCompletionCharFilter() : CharFilter() {
+ public override fun acceptChar(c : Char, prefixLength : Int, lookup : Lookup) : Result? {
+ if (lookup.getPsiFile() !is JetFile) return null
+
+ fun checkHideLookupForRangeOperator(): Result? {
+ if (c == '.' && prefixLength == 0 && !lookup.isSelectionTouched()) {
+ val caret = lookup.getEditor().getCaretModel().getOffset()
+ if (caret > 0 && (lookup.getEditor().getDocument().getCharsSequence().charAt(caret - 1)) == '.') {
+ return Result.HIDE_LOOKUP
+ }
+ }
+
+ return null
+ }
+
+ fun checkFinishCompletionForOpenBrace(): Result? {
+ if (c == '{') {
+ val currentItem = lookup.getCurrentItem()
+ if (currentItem != null && (currentItem.getObject() is JetLookupObject)) {
+ val lookupObject = (currentItem.getObject() as JetLookupObject)
+ val descriptor = lookupObject.getDescriptor()
+
+ if (descriptor != null) {
+ val handler = DescriptorLookupConverter.getInsertHandler(descriptor)
+ if (handler == JetFunctionInsertHandler.PARAMS_BRACES_FUNCTION_HANDLER) {
+ return Result.SELECT_ITEM_AND_FINISH_LOOKUP
+ }
+ }
+ }
+ }
+
+ return null
+ }
+
+ return checkHideLookupForRangeOperator() ?:
+ checkFinishCompletionForOpenBrace() ?:
+ null
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/plugin/completion/JetReferenceCharFilter.java b/idea/src/org/jetbrains/jet/plugin/completion/JetReferenceCharFilter.java
deleted file mode 100644
index dabe3f42e62..00000000000
--- a/idea/src/org/jetbrains/jet/plugin/completion/JetReferenceCharFilter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2010-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jetbrains.jet.plugin.completion;
-
-import com.intellij.codeInsight.lookup.CharFilter;
-import com.intellij.codeInsight.lookup.Lookup;
-import com.intellij.psi.PsiFile;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.jet.lang.psi.JetFile;
-
-public class JetReferenceCharFilter extends CharFilter {
- @Override
- @Nullable
- public Result acceptChar(char c, int prefixLength, Lookup lookup) {
- PsiFile psiFile = lookup.getPsiFile();
- if (!(psiFile instanceof JetFile)) {
- return null;
- }
-
- if (c == '.' && prefixLength == 0 && !lookup.isSelectionTouched()) {
- int caret = lookup.getEditor().getCaretModel().getOffset();
- if (caret > 0 && lookup.getEditor().getDocument().getCharsSequence().charAt(caret - 1) == '.') {
- return Result.HIDE_LOOKUP;
- }
- }
-
- return null;
- }
-}
\ No newline at end of file
diff --git a/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetFunctionInsertHandler.kt b/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetFunctionInsertHandler.kt
index 5f4bf599e61..24b5ffafbe2 100644
--- a/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetFunctionInsertHandler.kt
+++ b/idea/src/org/jetbrains/jet/plugin/completion/handlers/JetFunctionInsertHandler.kt
@@ -90,7 +90,7 @@ public class JetFunctionInsertHandler(val caretPosition : CaretPosition, val bra
var inBracketsShift = 0
if (openingBracketIndex == -1) {
if (braces) {
- if (completionChar == ' ') {
+ if (completionChar == ' ' || completionChar == '{') {
context.setAddCompletionChar(false)
}
diff --git a/idea/testData/completion/handlers/InsertFunctionWithSingleParameterWithBrace.kt b/idea/testData/completion/handlers/InsertFunctionWithSingleParameterWithBrace.kt
new file mode 100644
index 00000000000..a27e169ac0c
--- /dev/null
+++ b/idea/testData/completion/handlers/InsertFunctionWithSingleParameterWithBrace.kt
@@ -0,0 +1,5 @@
+fun some(f: () -> Unit) { f() }
+
+fun test() {
+ some
+}
\ No newline at end of file
diff --git a/idea/testData/completion/handlers/InsertFunctionWithSingleParameterWithBrace.kt.after b/idea/testData/completion/handlers/InsertFunctionWithSingleParameterWithBrace.kt.after
new file mode 100644
index 00000000000..49ea16e4543
--- /dev/null
+++ b/idea/testData/completion/handlers/InsertFunctionWithSingleParameterWithBrace.kt.after
@@ -0,0 +1,5 @@
+fun some(f: () -> Unit) { f() }
+
+fun test() {
+ some { }
+}
\ No newline at end of file
diff --git a/idea/tests/org/jetbrains/jet/completion/handlers/CompletionHandlerTest.kt b/idea/tests/org/jetbrains/jet/completion/handlers/CompletionHandlerTest.kt
index 70f318ae0d1..a9a69e78ae6 100644
--- a/idea/tests/org/jetbrains/jet/completion/handlers/CompletionHandlerTest.kt
+++ b/idea/tests/org/jetbrains/jet/completion/handlers/CompletionHandlerTest.kt
@@ -90,6 +90,8 @@ public class CompletionHandlerTest() : JetLightCodeInsightFixtureTestCase() {
fun testTabInsertInSimpleName() = doTest(CompletionType.BASIC, 0, "vvvvv", null, '\t')
+ fun testInsertFunctionWithSingleParameterWithBrace() = doTest(CompletionType.BASIC, 0, "some", null, '{')
+
var fixture by Delegates.notNull()
protected override fun setUp() {