Java Code Examples for com.intellij.codeInsight.lookup.LookupElementPresentation#setItemTextBold()

The following examples show how to use com.intellij.codeInsight.lookup.LookupElementPresentation#setItemTextBold() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DoctrineModelFieldLookupElement.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Override
public void renderElement(LookupElementPresentation presentation) {
    super.renderElement(presentation);

    presentation.setItemTextBold(withBoldness);
    presentation.setIcon(Symfony2Icons.DOCTRINE);
    presentation.setTypeGrayed(true);

    if(this.doctrineModelField.getTypeName() != null) {
        presentation.setTypeText(this.doctrineModelField.getTypeName());
    }

    if(this.doctrineModelField.getRelationType() != null) {
        presentation.setTailText(String.format("(%s)", this.doctrineModelField.getRelationType()), true);
    }

    if(this.doctrineModelField.getRelation() != null) {
        presentation.setTypeText(this.doctrineModelField.getRelation());
        presentation.setIcon(PhpIcons.CLASS_ICON);
    }

}
 
Example 2
Source File: LiveTemplateLookupElement.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void renderElement(LookupElementPresentation presentation) {
  super.renderElement(presentation);
  char shortcut = getTemplateShortcut();
  presentation.setItemText(getItemText());
  if (sudden) {
    presentation.setItemTextBold(true);
    if (!presentation.isReal() || !((RealLookupElementPresentation)presentation).isLookupSelectionTouched()) {
      if (shortcut == TemplateSettings.DEFAULT_CHAR) {
        shortcut = TemplateSettings.getInstance().getDefaultShortcutChar();
      }
      presentation.setTypeText("  [" + KeyEvent.getKeyText(shortcut) + "] ");
    }
    if (StringUtil.isNotEmpty(myDescription)) {
      presentation.setTailText(" (" + myDescription + ")", true);
    }
  }
  else {
    presentation.setTypeText(myDescription);
  }
}
 
Example 3
Source File: TabNineCompletionContributor.java    From tabnine-intellij with MIT License 5 votes vote down vote up
@Override
public void renderElement(LookupElementPresentation presentation) {
    if (this.detail != null) {
        presentation.setTypeText(this.detail);
    }
    presentation.setItemTextBold(true);
    presentation.setStrikeout(this.deprecated);
    presentation.setItemText(this.newPrefix);
}
 
Example 4
Source File: Suggestion.java    From intellij-spring-assistant with MIT License 5 votes vote down vote up
public void renderElement(LookupElement element, LookupElementPresentation presentation) {
  Suggestion suggestion = (Suggestion) element.getObject();
  if (suggestion.icon != null) {
    presentation.setIcon(suggestion.icon);
  }

  presentation.setStrikeout(suggestion.deprecationLevel != null);
  if (suggestion.deprecationLevel != null) {
    if (suggestion.deprecationLevel == SpringConfigurationMetadataDeprecationLevel.error) {
      presentation.setItemTextForeground(RED);
    } else {
      presentation.setItemTextForeground(YELLOW);
    }
  }

  String lookupString = element.getLookupString();
  presentation.setItemText(lookupString);
  if (!lookupString.equals(suggestion.suggestionToDisplay)) {
    presentation.setItemTextBold(true);
  }

  String shortDescription;
  if (suggestion.defaultValue != null) {
    shortDescription = shortenTextWithEllipsis(suggestion.defaultValue, 60, 0, true);
    TextAttributes attrs =
        EditorColorsManager.getInstance().getGlobalScheme().getAttributes(SCALAR_TEXT);
    presentation.setTailText("=" + shortDescription, attrs.getForegroundColor());
  }

  if (suggestion.description != null) {
    presentation
        .appendTailText(" (" + getFirstSentenceWithoutDot(suggestion.description) + ")",
            true);
  }

  if (suggestion.shortType != null) {
    presentation.setTypeText(suggestion.shortType);
  }
}
 
Example 5
Source File: HaxeLookupElement.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Override
public void renderElement(LookupElementPresentation presentation) {
  final ItemPresentation myComponentNamePresentation = myComponentName.getPresentation();
  if (myComponentNamePresentation == null) {
    presentation.setItemText(getLookupString());
    return;
  }

  String presentableText = myComponentNamePresentation.getPresentableText();

  // Check for members: methods and fields
  HaxeBaseMemberModel model = HaxeBaseMemberModel.fromPsi(myComponentName);

  if (model != null) {
    // TODO: Specialization support required
    presentableText = model.getPresentableText(context);

    // Check deprecated modifiers
    if (model instanceof HaxeMemberModel && ((HaxeMemberModel)model).getModifiers().hasModifier(HaxePsiModifier.DEPRECATED)) {
      presentation.setStrikeout(true);
    }

    // Check for non-inherited members to highlight them as intellij-java does
    // @TODO: Self members should be displayed first!
    if (leftReference != null) {
      if (model.getDeclaringClass().getPsi() == leftReference.getHaxeClass()) {
        presentation.setItemTextBold(true);
      }
    }
  }

  presentation.setItemText(presentableText);
  presentation.setIcon(myComponentNamePresentation.getIcon(true));
  final String pkg = myComponentNamePresentation.getLocationString();
  if (StringUtil.isNotEmpty(pkg)) {
    presentation.setTailText(" " + pkg, true);
  }
}
 
Example 6
Source File: ServiceStringLookupElement.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void renderElement(LookupElementPresentation presentation) {
    presentation.setItemText(getLookupString());
    presentation.setTypeGrayed(true);

    String className = getClassName(containerService);
    if(className != null) {
        presentation.setTypeText(StringUtils.strip(className, "\\"));
    }

    // private or non container services
    if(className == null || containerService.isWeak()) {
        presentation.setIcon(Symfony2Icons.SERVICE_OPACITY);
    } else {
        presentation.setIcon(Symfony2Icons.SERVICE);
    }

    if(this.containerService.isPrivate()) {
        presentation.setIcon(Symfony2Icons.SERVICE_PRIVATE_OPACITY);
    }

    presentation.setItemTextBold(this.boldText);
    if(this.boldText) {
        presentation.setTypeGrayed(false);
        presentation.setItemTextUnderlined(true);
    }

    if(containerService.getService() != null) {
        presentation.setStrikeout(containerService.getService().isDeprecated());
    }
}