use of com.intellij.codeInsight.completion.JavaMethodCallElement in project intellij-community by JetBrains.
the class LookupItemUtil method objectToLookupItem.
/**
* @deprecated
* @see LookupElementBuilder
*/
@NotNull
public static LookupElement objectToLookupItem(Object object) {
if (object instanceof LookupElement)
return (LookupElement) object;
if (object instanceof PsiClass) {
return JavaClassNameCompletionContributor.createClassLookupItem((PsiClass) object, true);
}
if (object instanceof PsiMethod) {
return new JavaMethodCallElement((PsiMethod) object);
}
if (object instanceof PsiVariable) {
return new VariableLookupItem((PsiVariable) object);
}
if (object instanceof PsiExpression) {
return new ExpressionLookupItem((PsiExpression) object);
}
if (object instanceof PsiType) {
return PsiTypeLookupItem.createLookupItem((PsiType) object, null);
}
if (object instanceof PsiPackage) {
return new PackageLookupItem((PsiPackage) object);
}
String s = null;
LookupItem item = new LookupItem(object, "");
if (object instanceof PsiElement) {
s = PsiUtilCore.getName((PsiElement) object);
}
TailType tailType = TailType.NONE;
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 (object instanceof LookupValueWithUIHint && ((LookupValueWithUIHint) object).isBold()) {
item.setBold();
}
if (s == null) {
LOG.error("Null string for object: " + object + " of class " + (object != null ? object.getClass() : null));
}
item.setLookupString(s);
item.setTailType(tailType);
return item;
}
Aggregations