UsageProvider in a large framework for different filetypes


Hi guys. Again, i'm working on a plugin for APACHE ERP OFBiz.
I've worked out some references, and now i'd like to use the FindUsagesProvider.
Here is my problem : as far as i understand the documentation, the usages provider uses the caches that's built when importing project, wich is made according to filetype.
But the usages i'm trying to get can occur in multiple fileTypes for a single element.

Here is an example :
This would be a service definition in an XML file :

<service name="createMarketingCampaign" default-entity-name="MarketingCampaign" engine="entity-auto" invoke="create" auth="true">
<description>Create a MarketingCampaign record</description>
<permission-service service-name="marketingPermissionService" main-action="CREATE"/>
<auto-attributes include="pk" mode="OUT" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>

And the name of this service could be called in an other xml file, but also in a java or groovy file :

<event type="service" path="" invoke="createMarketingCampaign"/>


Map<String, Object> serviceResult = dispatcher.runSync("createMarketingCampaign", context);

We also implemented in the plugin some of the dom description.

What would be the best way to achieve the usages search  for this example ? given that references towards the definition are functional.


If your custom PsiReference from code place(s) -> XML declaration (e.g., "name" attribute) are working fully and the names in code vs XML do not differ, you won't need to implement anything special AFAIU.


This would have been my thought, but it doesn't work :

References towards définition works, but not the find usages :

Here is the code i tried :

package org.apache.ofbiz.reference.usages

import com.intellij.lang.HelpID
import com.intellij.lang.findUsages.FindUsagesProvider
import com.intellij.psi.PsiElement
import org.jetbrains.annotations.NotNull

class ServicesUsages implements FindUsagesProvider {

boolean canFindUsagesFor(@NotNull PsiElement psiElement) {
return true

String getHelpId(@NotNull PsiElement psiElement) {

String getType(@NotNull PsiElement psiElement) {
return "Service"

String getDescriptiveName(@NotNull PsiElement psiElement) {
return psiElement.getText()

String getNodeText(@NotNull PsiElement psiElement, boolean b) {
return getDescriptiveName(psiElement)
<lang.findUsagesProvider language="XML" implementationClass="org.apache.ofbiz.reference.usages.ServicesUsages" />



The attribute defining the ID in the XML must be annotated with com.intellij.util.xml.NameValue


It is :

interface ServiceDefFile extends DomElement {

List<Service> getServices()

interface Service extends DomElement {

GenericAttributeValue<String> getName()
// ...


Please disable your custom


Please sign in to leave a comment.