mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
all possible class names should be a valid lookup strings when completing an inner class after new
This commit is contained in:
@@ -31,6 +31,9 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
@@ -168,17 +171,22 @@ public class PsiTypeLookupItem extends LookupItem {
|
||||
}
|
||||
}
|
||||
PsiClass resolved = JavaPsiFacade.getInstance(psiClass.getProject()).getResolveHelper().resolveReferencedClass(psiClass.getName(), context);
|
||||
|
||||
Set<String> allStrings = new HashSet<String>();
|
||||
String lookupString = psiClass.getName();
|
||||
allStrings.add(lookupString);
|
||||
if (!psiClass.getManager().areElementsEquivalent(resolved, psiClass)) {
|
||||
// inner class name should be shown qualified if its not accessible by single name
|
||||
PsiClass aClass = psiClass.getContainingClass();
|
||||
while (aClass != null) {
|
||||
lookupString = aClass.getName() + '.' + lookupString;
|
||||
allStrings.add(lookupString);
|
||||
aClass = aClass.getContainingClass();
|
||||
}
|
||||
}
|
||||
|
||||
PsiTypeLookupItem item = new PsiTypeLookupItem(psiClass, lookupString, diamond, bracketsCount);
|
||||
item.addLookupStrings(allStrings.toArray(new String[allStrings.size()]));
|
||||
item.setAttribute(SUBSTITUTOR, substitutor);
|
||||
return item;
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
public class JavaClass {
|
||||
{
|
||||
Outer.Boo b = new Outer.Boo();<caret>
|
||||
}
|
||||
}
|
||||
|
||||
class Outer {
|
||||
static class Boo { }
|
||||
}
|
||||
|
||||
|
||||
class ABooImpl extends Outer.Boo { }
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
public class JavaClass {
|
||||
{
|
||||
Outer.Boo b = new B<caret>
|
||||
}
|
||||
}
|
||||
|
||||
class Outer {
|
||||
static class Boo { }
|
||||
}
|
||||
|
||||
|
||||
class ABooImpl extends Outer.Boo { }
|
||||
+4
-2
@@ -411,8 +411,10 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
|
||||
public void testParameterizedConstructor() throws Throwable { doTest(); }
|
||||
|
||||
public void testNewInnerClassNameShortPrefix() throws Throwable { doTest(); }
|
||||
|
||||
public void testNewInnerOfParameterizedClass() throws Throwable { doTest(); }
|
||||
|
||||
|
||||
public void testQualifiedThisInAnonymousConstructor() throws Throwable { doTest(); }
|
||||
|
||||
public void testExceptionTwice() throws Throwable { doTest(); }
|
||||
@@ -684,7 +686,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
public void testSuggestInstanceofedValueInComplexIf() throws Throwable { doTest(); }
|
||||
|
||||
public void testSuggestInstanceofedValueInElseNegated() throws Throwable { doTest(); }
|
||||
|
||||
|
||||
public void testSuggestInstanceofedValueAfterReturn() throws Throwable { doTest(); }
|
||||
|
||||
public void testNoInstanceofedValueWhenBasicSuits() throws Throwable { doTest(); }
|
||||
|
||||
Reference in New Issue
Block a user