コード例 #1
0
  @Override
  public void renderElement(LookupElementPresentation presentation) {
    final Object object = getObject();
    if (object instanceof PsiClass) {
      JavaPsiClassReferenceElement.renderClassItem(
          presentation, this, (PsiClass) object, myDiamond, myLocationString, mySubstitutor);
    } else {
      assert object instanceof PsiType;

      if (!(object instanceof PsiPrimitiveType)) {
        presentation.setIcon(DefaultLookupItemRenderer.getRawIcon(this, presentation.isReal()));
      }

      presentation.setItemText(((PsiType) object).getCanonicalText());
      presentation.setItemTextBold(object instanceof PsiPrimitiveType);
      if (isAddArrayInitializer()) {
        presentation.setTailText("{...}");
      }
    }
    if (myBracketsCount > 0) {
      presentation.setTailText(
          StringUtil.repeat("[]", myBracketsCount)
              + StringUtil.notNullize(presentation.getTailText()),
          true);
    }
  }
コード例 #2
0
  @Override
  public void renderElement(LookupElementPresentation presentation) {
    super.renderElement(presentation);
    final LookupElementPresentation qualifierPresentation = new LookupElementPresentation();
    myQualifier.renderElement(qualifierPresentation);
    String name = maybeAddParentheses(qualifierPresentation.getItemText());
    final String qualifierText =
        myQualifier.as(CastingLookupElementDecorator.CLASS_CONDITION_KEY) != null
            ? "(" + name + ")"
            : name;
    presentation.setItemText(qualifierText + "." + presentation.getItemText());

    if (myQualifier instanceof LookupItem && getQualifierObject() instanceof PsiClass) {
      String locationString =
          JavaPsiClassReferenceElement.getLocationString((LookupItem) myQualifier);
      presentation.setTailText(StringUtil.notNullize(presentation.getTailText()) + locationString);
    }
  }