下面列出了com.intellij.psi.ElementDescriptionLocation#com.intellij.usageView.UsageViewShortNameLocation 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Nullable
@Override
public String getElementDescription(PsiElement element, ElementDescriptionLocation location) {
if (!(element instanceof BuildElement)) {
return null;
}
if (location instanceof UsageViewLongNameLocation) {
return ((BuildElement) element).getPresentableText();
}
if (location instanceof UsageViewShortNameLocation) {
if (element instanceof PsiNameIdentifierOwner) {
// this is used by rename operations, so needs to be accurate
return ((PsiNameIdentifierOwner) element).getName();
}
if (element instanceof PsiFile) {
return ((PsiFile) element).getName();
}
return ((BuildElement) element).getPresentableText();
}
return null;
}
@Nullable
@Override
@RequiredReadAction
public String getElementDescription(@Nonnull PsiElement element, @Nonnull ElementDescriptionLocation location)
{
if(location == UsageViewShortNameLocation.INSTANCE && element instanceof CSharpNamedElement)
{
return ((CSharpNamedElement) element).getNameWithAt();
}
return null;
}
@Nullable
private static String getQuickNavigateInfo(PsiElement element) {
final String name = ElementDescriptionUtil.getElementDescription(element, UsageViewShortNameLocation.INSTANCE);
if (StringUtil.isEmpty(name)) return null;
final String typeName = ElementDescriptionUtil.getElementDescription(element, UsageViewTypeLocation.INSTANCE);
final PsiFile file = element.getContainingFile();
final StringBuilder sb = new StringBuilder();
if (StringUtil.isNotEmpty(typeName)) sb.append(typeName).append(" ");
sb.append("\"").append(name).append("\"");
if (file != null && file.isPhysical()) {
sb.append(" [").append(file.getName()).append("]");
}
return sb.toString();
}