mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-163834 Smart completion for stream.toArray(..) arg loses "[]" after accepting - when array is of non-static inner class
This commit is contained in:
+3
-2
@@ -52,8 +52,9 @@ public class FunctionalExpressionCompletionProvider extends CompletionProvider<C
|
||||
int start = context.getStartOffset();
|
||||
PsiClass psiClass = PsiUtil.resolveClassInType((PsiType)item.getObject());
|
||||
if (psiClass != null) {
|
||||
JavaCompletionUtil.insertClassReference(psiClass, context.getFile(), start,
|
||||
start + StringUtil.trimEnd(item.getLookupString(), "::new").length());
|
||||
String insertedName = StringUtil.trimEnd(item.getLookupString(), "::new");
|
||||
while (insertedName.endsWith("[]")) insertedName = insertedName.substring(0, insertedName.length() - 2);
|
||||
JavaCompletionUtil.insertClassReference(psiClass, context.getFile(), start, start + insertedName.length());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import java.util.stream.Stream;
|
||||
public class Outer {
|
||||
|
||||
class Inner { }
|
||||
|
||||
private Inner[] innerArr;
|
||||
|
||||
public Outer(Stream<Inner> numbers) {
|
||||
this.innerArr = numbers.toArray(Inner[]::new)<caret>;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import java.util.stream.Stream;
|
||||
public class Outer {
|
||||
|
||||
class Inner { }
|
||||
|
||||
private Inner[] innerArr;
|
||||
|
||||
public Outer(Stream<Inner> numbers) {
|
||||
this.innerArr = numbers.toArray(Ou<caret>);
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user