Custom name for Find Usages of symbol

I've implemented com.intellij.lang.findUsages.FindUsagesProvider and com.intellij.openapi.application.QueryExecutorBase<PsiReference, ReferencesSearch.SearchParameters> for finding usages of LeafPsiElement - value element of YAMLKeyValue (YAML plugin). I want to provide symbol name for popup title in Find Usages - actually popup title looks like this:
and I would like to have it like this one:
How can I change symbol name in this title?



you can register a custom com.intellij.psi.ElementDescriptionProvider.
Here match the getElementDescription method calls where the location is instanceOf com.intellij.usageView.UsageViewLongNameLocation and provide the string that you prefer.

Something like:

public class CustomElementDescriptionProvider implements com.intellij.psi.ElementDescriptionProvider {
    public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {
        if(isTheElementThatShouldBeDescribed(element) && location instanceof UsageViewLongNameLocation)
            return "property codeName";
        return null;

This should do the job


I've implemented that interface like this:

public class ComponentDescriptionProvider implements ElementDescriptionProvider {     @Nullable     @Override     public String getElementDescription(@NotNull PsiElement element, @NotNull ElementDescriptionLocation location) {         if (YamlUtils.isLeafValueFromYamlKeyValue(element)) {             return "value " + element.getText();         }         return null;     } }

Method is called and my value is returned but title is still without this text. Even in Show Usages tab there is still "<anonymous>". It is used as description of searched element but not in the title.

  1. you are missing the check on the location type, for this reason the string is replacing many different labels:

            return "value " + element.getText();


I've added location check as you suggested and put breakpoint at return point but it is never stops there now - location is not instance of UsageViewLongNameLocation. Probably this works only for Java symbols but I'm looking for unclassified usages of non java symbol.


Please sign in to leave a comment.