本文整理汇总了Java中com.intellij.psi.util.PsiUtilCore.getName方法的典型用法代码示例。如果您正苦于以下问题:Java PsiUtilCore.getName方法的具体用法?Java PsiUtilCore.getName怎么用?Java PsiUtilCore.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.PsiUtilCore
的用法示例。
在下文中一共展示了PsiUtilCore.getName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveConflict
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
@Override
public CandidateInfo resolveConflict(@NotNull List<CandidateInfo> conflicts){
if (conflicts.size() == 1) return conflicts.get(0);
final Map<Object, CandidateInfo> uniqueItems = new HashMap<Object, CandidateInfo>();
for (CandidateInfo info : conflicts) {
final PsiElement element = info.getElement();
Object key;
if (info instanceof MethodCandidateInfo) {
key = ((PsiMethod)element).getSignature(((MethodCandidateInfo)info).getSubstitutor(false));
}
else {
key = PsiUtilCore.getName(element);
}
if (!uniqueItems.containsKey(key)) {
uniqueItems.put(key, info);
}
}
if(uniqueItems.size() == 1) return uniqueItems.values().iterator().next();
return null;
}
示例2: getName
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
private static String getName(final PsiClass psiClass, final LookupElement item, boolean diamond, @NotNull PsiSubstitutor substitutor) {
if (item instanceof JavaPsiClassReferenceElement) {
String forced = ((JavaPsiClassReferenceElement)item).getForcedPresentableName();
if (forced != null) {
return forced;
}
}
String name = PsiUtilCore.getName(psiClass);
if (diamond) {
return name + "<>";
}
if (substitutor != PsiSubstitutor.EMPTY) {
final PsiTypeParameter[] params = psiClass.getTypeParameters();
if (params.length > 0) {
return name + formatTypeParameters(substitutor, params);
}
}
return StringUtil.notNullize(name);
}
示例3: getName
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
private static String getName(final LookupItem item){
final String presentableText = item.getPresentableText();
if (presentableText != null) return presentableText;
final Object o = item.getObject();
String name = null;
if (o instanceof PsiElement) {
final PsiElement element = (PsiElement)o;
if (element.isValid()) {
name = PsiUtilCore.getName(element);
}
}
else if (o instanceof PsiMetaData) {
name = ((PsiMetaData)o).getName();
}
else if (o instanceof PresentableLookupValue ) {
name = ((PresentableLookupValue)o).getPresentation();
}
else {
name = String.valueOf(o);
}
if (name == null){
name = "";
}
return name;
}
示例4: objectToLookupItem
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
public static LookupElement objectToLookupItem(final @NotNull 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;
}
示例5: objectToLookupItem
import com.intellij.psi.util.PsiUtilCore; //导入方法依赖的package包/类
/**
* @deprecated
* @see LookupElementBuilder
*/
@NotNull
public static LookupElement objectToLookupItem(Object object) {
if (object instanceof LookupElement) return (LookupElement)object;
if (object instanceof PsiClass) {
return JavaClassNameCompletionContributor.createClassLookupItem((PsiClass)object, true);
}
if (object instanceof PsiMethod) {
return new JavaMethodCallElement((PsiMethod)object);
}
if (object instanceof PsiVariable) {
return new VariableLookupItem((PsiVariable)object);
}
if (object instanceof PsiExpression) {
return new ExpressionLookupItem((PsiExpression) object);
}
if (object instanceof PsiType) {
return PsiTypeLookupItem.createLookupItem((PsiType)object, null);
}
if (object instanceof PsiPackage) {
return new PackageLookupItem((PsiPackage)object);
}
String s = null;
LookupItem item = new LookupItem(object, "");
if (object instanceof PsiElement){
s = PsiUtilCore.getName((PsiElement)object);
}
TailType tailType = TailType.NONE;
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 (object instanceof LookupValueWithUIHint && ((LookupValueWithUIHint) object).isBold()) {
item.setBold();
}
if (s == null) {
LOG.error("Null string for object: " + object + " of class " + (object != null ? object.getClass() : null));
}
item.setLookupString(s);
item.setTailType(tailType);
return item;
}