make breadcrumbs shorter: strip lambda & anonymous

This commit is contained in:
Gregory.Shrago
2016-07-06 03:18:41 +03:00
parent 550a8c84d3
commit 6cb4ad5f77
@@ -48,12 +48,14 @@ public class JavaBreadcrumbsInfoProvider extends BreadcrumbsInfoProvider {
public String getElementInfo(@NotNull PsiElement e) {
if (e instanceof PsiLambdaExpression) {
PsiType type = DumbService.isDumb(e.getProject()) ? null : ((PsiFunctionalExpression)e).getFunctionalInterfaceType();
return type == null ? "<lambda>" : "lambda " + getShortClassName(type.getCanonicalText());
return type == null ? "->" : "-> " + getShortClassName(type.getCanonicalText());
}
else if (e instanceof PsiAnonymousClass) {
String name = ((PsiAnonymousClass)e).getBaseClassReference().getReferenceName();
return "new " + StringUtil.notNullize(name, "class");
}
String description = ElementDescriptionUtil.getElementDescription(e, UsageViewShortNameLocation.INSTANCE);
String suffix = e instanceof PsiParameterListOwner? "()" :
//e instanceof PsiAnonymousClass || e instanceof PsiClassInitializer ? " {}" :
null;
String suffix = e instanceof PsiParameterListOwner? "()" : null;
return suffix != null ? description + suffix : description;
}