use of com.intellij.codeInsight.lookup.PresentableLookupValue in project intellij-community by JetBrains.
the class CompletionData method objectToLookupItem.
public static LookupElement objectToLookupItem(@NotNull final Object object) {
if (object instanceof LookupElement)
return (LookupElement) object;
String s = null;
TailType tailType = TailType.NONE;
if (object instanceof PsiElement) {
s = PsiUtilCore.getName((PsiElement) object);
} else if (object instanceof PsiMetaData) {
s = ((PsiMetaData) object).getName();
} else if (object instanceof String) {
s = (String) object;
} else if (object instanceof Template) {
s = ((Template) object).getKey();
} else if (object instanceof PresentableLookupValue) {
s = ((PresentableLookupValue) object).getPresentation();
}
if (s == null) {
throw new AssertionError("Null string for object: " + object + " of class " + object.getClass());
}
LookupItem item = new LookupItem(object, s);
if (object instanceof LookupValueWithUIHint && ((LookupValueWithUIHint) object).isBold()) {
item.setBold();
}
item.setAttribute(LookupItem.TAIL_TYPE_ATTR, tailType);
return item;
}
Aggregations