当前位置: 首页>>代码示例>>Java>>正文


Java LookupItem.getAttribute方法代码示例

本文整理汇总了Java中com.intellij.codeInsight.lookup.LookupItem.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java LookupItem.getAttribute方法的具体用法?Java LookupItem.getAttribute怎么用?Java LookupItem.getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.codeInsight.lookup.LookupItem的用法示例。


在下文中一共展示了LookupItem.getAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderClassItem

import com.intellij.codeInsight.lookup.LookupItem; //导入方法依赖的package包/类
public static void renderClassItem(LookupElementPresentation presentation, LookupItem item, PsiClass psiClass, boolean diamond) {
  if (!(psiClass instanceof PsiTypeParameter)) {
    presentation.setIcon(DefaultLookupItemRenderer.getRawIcon(item, presentation.isReal()));
  }

  final boolean bold = item.getAttribute(LookupItem.HIGHLIGHTED_ATTR) != null;
  boolean strikeout = JavaElementLookupRenderer.isToStrikeout(item);
  presentation.setItemText(getName(psiClass, item, diamond));
  presentation.setStrikeout(strikeout);
  presentation.setItemTextBold(bold);

  String tailText = getLocationString(item);
  PsiSubstitutor substitutor = (PsiSubstitutor)item.getAttribute(LookupItem.SUBSTITUTOR);

  if (item instanceof PsiTypeLookupItem) {
    if (((PsiTypeLookupItem)item).isIndicateAnonymous() &&
        (psiClass.isInterface() || psiClass.hasModifierProperty(PsiModifier.ABSTRACT)) ||
        ((PsiTypeLookupItem)item).isAddArrayInitializer()) {
      tailText = "{...}" + tailText;
    }
  }
  if (substitutor == null && !diamond && psiClass.getTypeParameters().length > 0) {
    tailText = "<" + StringUtil.join(psiClass.getTypeParameters(), new Function<PsiTypeParameter, String>() {
      @Override
      public String fun(PsiTypeParameter psiTypeParameter) {
        return psiTypeParameter.getName();
      }
    }, "," + (showSpaceAfterComma(psiClass) ? " " : "")) + ">" + tailText;
  }
  presentation.setTailText(tailText, true);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:32,代码来源:JavaPsiClassReferenceElement.java

示例2: getName

import com.intellij.codeInsight.lookup.LookupItem; //导入方法依赖的package包/类
private static String getName(final PsiClass psiClass, final LookupItem<?> item, boolean diamond) {
  if (item instanceof JavaPsiClassReferenceElement) {
    String forced = ((JavaPsiClassReferenceElement)item).getForcedPresentableName();
    if (forced != null) {
      return forced;
    }
  }

  String name = PsiUtilCore.getName(psiClass);

  if (item.getAttribute(LookupItem.FORCE_QUALIFY) != null) {
    if (psiClass.getContainingClass() != null) {
      name = psiClass.getContainingClass().getName() + "." + name;
    }
  }

  if (diamond) {
    return name + "<>";
  }

  PsiSubstitutor substitutor = (PsiSubstitutor)item.getAttribute(LookupItem.SUBSTITUTOR);
  if (substitutor != null) {
    final PsiTypeParameter[] params = psiClass.getTypeParameters();
    if (params.length > 0) {
      return name + formatTypeParameters(substitutor, params);
    }
  }

  return StringUtil.notNullize(name);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:31,代码来源:JavaPsiClassReferenceElement.java

示例3: getName

import com.intellij.codeInsight.lookup.LookupItem; //导入方法依赖的package包/类
private static String getName(final Object o, final LookupItem<?> item) {
  final String presentableText = item.getPresentableText();
  if (presentableText != null) {
    return presentableText;
  }

  String name = "";
  if (o instanceof PsiElement) {
    final PsiElement element = (PsiElement)o;
    if (element.isValid()) {
      if (element instanceof PsiKeyword || element instanceof PsiExpression || element instanceof PsiTypeElement) {
        name = element.getText();
      } else {
        name = PsiUtilCore.getName(element);
      }
    }
  }
  else if (o instanceof PsiArrayType) {
    name = ((PsiArrayType)o).getDeepComponentType().getPresentableText();
  }
  else if (o instanceof PsiType) {
    name = ((PsiType)o).getPresentableText();
  }

  if (item.getAttribute(LookupItem.FORCE_QUALIFY) != null) {
    if (o instanceof PsiMember && ((PsiMember)o).getContainingClass() != null) {
      name = ((PsiMember)o).getContainingClass().getName() + "." + name;
    }
  }

  return StringUtil.notNullize(name);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:JavaElementLookupRenderer.java

示例4: getTypeText

import com.intellij.codeInsight.lookup.LookupItem; //导入方法依赖的package包/类
@Nullable
private static String getTypeText(LookupItem item, @Nullable PsiType returnType) {
  if (returnType == null) {
    return null;
  }

  final PsiSubstitutor substitutor = (PsiSubstitutor)item.getAttribute(LookupItem.SUBSTITUTOR);
  if (substitutor != null) {
    return substitutor.substitute(returnType).getPresentableText();
  }
  return returnType.getPresentableText();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:13,代码来源:JavaElementLookupRenderer.java


注:本文中的com.intellij.codeInsight.lookup.LookupItem.getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。