IDEA-135296 Code completion should complete lambda parameters
authorpeter <peter@jetbrains.com>
Fri, 6 Feb 2015 16:14:18 +0000 (17:14 +0100)
committerpeter <peter@jetbrains.com>
Fri, 6 Feb 2015 16:26:15 +0000 (17:26 +0100)
java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/Normal8CompletionTest.groovy

index e12fad06e77f7bfebaa5554e66d472a3790cc30d..98df5dcc0621ca032edd809c7475504a367a99b3 100644 (file)
@@ -248,6 +248,10 @@ public class JavaCompletionContributor extends CompletionContributor {
 
     JavaGenerateMemberCompletionContributor.fillCompletionVariants(parameters, result);
 
+    if (JavaSmartCompletionContributor.LAMBDA.accepts(parameters.getPosition())) {
+      new LambdaCompletionProvider().addCompletions(parameters, new ProcessingContext(), result);
+    }
+
     addAllClasses(parameters, result, inheritors);
 
     final PsiElement parent = position.getParent();
index ddd15947a768ea25130da1f8db762192964e746a..1e55eb39db943b6a0a6589f5de3ea4b3e1b58a96 100644 (file)
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 package com.intellij.codeInsight.daemon.lambda
-
 import com.intellij.JavaTestUtil
 import com.intellij.codeInsight.completion.LightFixtureCompletionTestCase
+import com.intellij.codeInsight.lookup.LookupElementPresentation
 import com.intellij.testFramework.LightProjectDescriptor
 import org.jetbrains.annotations.NotNull
 /**
@@ -58,4 +58,20 @@ class Foo {{ Object o = StringBuilder::append.<caret> }}
     assertEmpty(myFixture.completeBasic())
     myFixture.checkResult(text)
   }
+
+  public void "test suggest lambda signature"() {
+    myFixture.configureByText "a.java", """
+interface I {
+  void m(int x);
+}
+
+class Test {
+  public static void main(String[] args) {
+    I i = <caret>
+  }
+}"""
+    def items = myFixture.completeBasic()
+    assert items.find { LookupElementPresentation.renderElement(it).itemText == 'x -> {}' }
+  }
+
 }