Search in sources :

Example 1 with JavaMethodCallElement

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;
}
Also used : JavaMethodCallElement(com.intellij.codeInsight.completion.JavaMethodCallElement) TailType(com.intellij.codeInsight.TailType) Template(com.intellij.codeInsight.template.Template) PsiMetaData(com.intellij.psi.meta.PsiMetaData) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TailType (com.intellij.codeInsight.TailType)1 JavaMethodCallElement (com.intellij.codeInsight.completion.JavaMethodCallElement)1 Template (com.intellij.codeInsight.template.Template)1 PsiMetaData (com.intellij.psi.meta.PsiMetaData)1 NotNull (org.jetbrains.annotations.NotNull)1