Java Code Examples for com.intellij.codeInsight.TailType#NONE

The following examples show how to use com.intellij.codeInsight.TailType#NONE . 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: CompletionData.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void addLookupItem(Set<LookupElement> set, TailType tailType, @Nonnull Object completion, final CompletionVariant variant) {
  LookupElement ret = objectToLookupItem(completion);
  if (ret == null) return;
  if (!(ret instanceof LookupItem)) {
    set.add(ret);
    return;
  }

  LookupItem item = (LookupItem)ret;

  final InsertHandler insertHandler = variant.getInsertHandler();
  if(insertHandler != null && item.getInsertHandler() == null) {
    item.setInsertHandler(insertHandler);
    item.setTailType(TailType.UNKNOWN);
  }
  else if (tailType != TailType.NONE) {
    item.setTailType(tailType);
  }
  final Map<Object, Object> itemProperties = variant.getItemProperties();
  for (final Object key : itemProperties.keySet()) {
    item.setAttribute(key, itemProperties.get(key));
  }

  set.add(ret);
}
 
Example 2
Source File: LookupItem.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static TailType handleCompletionChar(@Nonnull final Editor editor, @Nonnull final LookupElement lookupElement, final char completionChar) {
  final TailType type = getDefaultTailType(completionChar);
  if (type != null) {
    return type;
  }

  if (lookupElement instanceof LookupItem) {
    final LookupItem<?> item = (LookupItem)lookupElement;
    final TailType attr = item.getAttribute(TAIL_TYPE_ATTR);
    if (attr != null) {
      return attr;
    }
  }
  return TailType.NONE;
}
 
Example 3
Source File: CompletionData.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static LookupElement objectToLookupItem(final @Nonnull Object object) {
  if (object instanceof LookupElement) return (LookupElement)object;

  String s = null;
  TailType tailType = TailType.NONE;
  if (object instanceof PsiElement){
    s = PsiUtilCore.getName((PsiElement)object);
  }
  else 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 (s == null) {
    throw new AssertionError("Null string for object: " + object + " of class " + object.getClass());
  }

  LookupItem item = new LookupItem(object, s);

  if (object instanceof LookupValueWithUIHint && ((LookupValueWithUIHint) object).isBold()) {
    item.setBold();
  }
  item.setAttribute(LookupItem.TAIL_TYPE_ATTR, tailType);
  return item;
}