LookupElement (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 = TailTypes.noneType(); if (object instanceof PsiMetaData) { s = ((PsiMetaData)object).getName(); } else if (object instanceof String) { s = (String)object; } else if (object instanceof PresentableLookupValue) { s = ((PresentableLookupValue)object).getPresentation(); } 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; }