mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
IDEA-98132 Improve type parameter lookup
This commit is contained in:
+3
-1
@@ -142,7 +142,9 @@ public class JavaPsiClassReferenceElement extends LookupItem<Object> {
|
||||
}
|
||||
|
||||
public static void renderClassItem(LookupElementPresentation presentation, LookupItem item, PsiClass psiClass, boolean diamond) {
|
||||
presentation.setIcon(DefaultLookupItemRenderer.getRawIcon(item, presentation.isReal()));
|
||||
if (!(psiClass instanceof PsiTypeParameter)) {
|
||||
presentation.setIcon(DefaultLookupItemRenderer.getRawIcon(item, presentation.isReal()));
|
||||
}
|
||||
|
||||
final boolean bold = item.getAttribute(LookupItem.HIGHLIGHTED_ATTR) != null;
|
||||
boolean strikeout = JavaElementLookupRenderer.isToStrikeout(item);
|
||||
|
||||
@@ -431,6 +431,20 @@ public class PsiFormatUtil extends PsiFormatUtilBase {
|
||||
}
|
||||
|
||||
public static String getPackageDisplayName(@NotNull final PsiClass psiClass) {
|
||||
if (psiClass instanceof PsiTypeParameter) {
|
||||
PsiTypeParameterListOwner owner = ((PsiTypeParameter)psiClass).getOwner();
|
||||
String ownerName = null;
|
||||
if (owner instanceof PsiClass) {
|
||||
ownerName = ((PsiClass)owner).getQualifiedName();
|
||||
if (ownerName == null) {
|
||||
ownerName = owner.getName();
|
||||
}
|
||||
} else if (owner instanceof PsiMethod) {
|
||||
ownerName = owner.getName();
|
||||
}
|
||||
return ownerName == null ? "type parameter" : "type parameter of " + ownerName;
|
||||
}
|
||||
|
||||
@NonNls String packageName = psiClass.getQualifiedName();
|
||||
packageName = packageName == null || packageName.lastIndexOf('.') <= 0 ? "" : packageName.substring(0, packageName.lastIndexOf('.'));
|
||||
if (packageName.isEmpty()) {
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public class Foo<Param> {
|
||||
<Param2> int goo() {
|
||||
Pa<caret>
|
||||
}
|
||||
}
|
||||
+14
@@ -85,6 +85,20 @@ public class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
|
||||
public void testSimpleVariable() throws Exception { doTest('\n') }
|
||||
|
||||
public void testTypeParameterItemPresentation() {
|
||||
configure()
|
||||
LookupElementPresentation presentation = renderElement(myItems[0])
|
||||
assert "Param" == presentation.itemText
|
||||
assert presentation.tailText == " (type parameter of Foo)"
|
||||
assert !presentation.typeText
|
||||
assert !presentation.icon
|
||||
assert !presentation.itemTextBold
|
||||
|
||||
presentation = renderElement(myItems[1])
|
||||
assert "Param2" == presentation.itemText
|
||||
assert presentation.tailText == " (type parameter of goo)"
|
||||
}
|
||||
|
||||
public void testMethodItemPresentation() {
|
||||
configure()
|
||||
LookupElementPresentation presentation = renderElement(myItems[0])
|
||||
|
||||
Reference in New Issue
Block a user