本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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();
}