From 7a8bd025903ca20b36da814effbf1ffa0b7dcffb Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 21 Nov 2016 17:19:15 +0100 Subject: [PATCH] IDEA-163834 Smart completion for stream.toArray(..) arg loses "[]" after accepting - when array is of non-static inner class --- .../FunctionalExpressionCompletionProvider.java | 5 +++-- .../smartType/InnerArrayConstructorRef-out.java | 11 +++++++++++ .../smartType/InnerArrayConstructorRef.java | 11 +++++++++++ .../completion/SmartType18CompletionTest.java | 6 ++++-- 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 java/java-tests/testData/codeInsight/completion/smartType/InnerArrayConstructorRef-out.java create mode 100644 java/java-tests/testData/codeInsight/completion/smartType/InnerArrayConstructorRef.java diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/FunctionalExpressionCompletionProvider.java b/java/java-impl/src/com/intellij/codeInsight/completion/FunctionalExpressionCompletionProvider.java index f1532eff4179..a63682e50edf 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/FunctionalExpressionCompletionProvider.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/FunctionalExpressionCompletionProvider.java @@ -52,8 +52,9 @@ public class FunctionalExpressionCompletionProvider extends CompletionProvider numbers) { + this.innerArr = numbers.toArray(Inner[]::new); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completion/smartType/InnerArrayConstructorRef.java b/java/java-tests/testData/codeInsight/completion/smartType/InnerArrayConstructorRef.java new file mode 100644 index 000000000000..12f996453969 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/smartType/InnerArrayConstructorRef.java @@ -0,0 +1,11 @@ +import java.util.stream.Stream; +public class Outer { + + class Inner { } + + private Inner[] innerArr; + + public Outer(Stream numbers) { + this.innerArr = numbers.toArray(Ou); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java index bca92e33b24c..7607f427d242 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/SmartType18CompletionTest.java @@ -85,6 +85,8 @@ public class SmartType18CompletionTest extends LightFixtureCompletionTestCase { doTest(false); } + public void testInnerArrayConstructorRef() { doTest(true); } + public void testNoConstraintsWildcard() throws Exception { doTest(); } @@ -200,9 +202,9 @@ public void testConvertToObjectStream() { doTest(true); } - private void doTest(boolean checkItems) { + private void doTest(boolean insertSelectedItem) { configureByFile("/" + getTestName(false) + ".java"); - if (checkItems) { + if (insertSelectedItem) { assertNotNull(myItems); assertTrue(myItems.length > 0); final Lookup lookup = getLookup();