# ReferenceContributor not work from custom langauge

**URL:** <https://platform.jetbrains.com/t/referencecontributor-not-work-from-custom-langauge/733>\
**Category:** IntelliJ Platform\
**Created:** [February 28, 2025, 11:01am UTC](https://platform.jetbrains.com/t/referencecontributor-not-work-from-custom-langauge/733 "2025-02-28T11:01:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhuohuang.yu](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/zhuohuang.yu/32/624_2.png) [@zhuohuang.yu](https://platform.jetbrains.com/u/zhuohuang.yu)\
**Post date:** [February 28, 2025, 11:01am UTC](https://platform.jetbrains.com/t/referencecontributor-not-work-from-custom-langauge/733/1 "2025-02-28T11:01:28Z")

</div>

I’m developing a custom language plugin.  
The language support @xxxx to refer to xxxx argument in corresponding Golang method.

I follow the Simple language plugin and develop my MyReferenceContributor and register it in the plugin.xml.

```auto
<psi.referenceContributor language="MyLanguage" "xxxxx.MyReferenceContributor" />

```

But it seems that MyReferenceContributor is NEVER called via LOG / DEBUG.

Is there anything special for ReferenceContributor when it is from custom language?

---

<div class="post-metadata">

**Author:** ![xepozz](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/xepozz/32/589_2.png) [@xepozz](https://platform.jetbrains.com/u/xepozz)\
**Post date:** [February 28, 2025, 11:44am UTC](https://platform.jetbrains.com/t/referencecontributor-not-work-from-custom-langauge/733/2 "2025-02-28T11:44:25Z")

</div>

Hi.

I’ve spent much time to understand how to do it in my own custom languages and why it didn’t work 😁

Things that help me to inject references to my psi elements:

1. add `override fun getReferences(): Array<PsiReference> = ReferenceProvidersRegistry.getReferencesFromProviders(this)` to the element should have references
2. add `{ implements=["com.intellij.psi.NavigatablePsiElement"] }` into the `bnf` to the according psi element pattern declaration

Do not forget to rebuild parser.  
Also I’ve noticed that your snippet has error, there are no “implementation” attribute, so correct version will be: `<psi.referenceContributor language="MyLanguage" implementation="xxxxx.MyReferenceContributor" />`

---

<div class="post-metadata">

**Author:** ![yuriy.artamonov](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/yuriy.artamonov/32/48_2.png) [@yuriy.artamonov](https://platform.jetbrains.com/u/yuriy.artamonov)\
**Post date:** [February 28, 2025, 1:37pm UTC](https://platform.jetbrains.com/t/referencecontributor-not-work-from-custom-langauge/733/3 "2025-02-28T13:37:28Z")

</div>

Languages must explicitly enable references in places where they expect contributed references. It cannot be done automatically since has performance and correctness consequences.

---

<div class="post-metadata">

**Author:** ![zhuohuang.yu](https://sea1.discourse-cdn.com/flex001/user_avatar/platform.jetbrains.com/zhuohuang.yu/32/624_2.png) [@zhuohuang.yu](https://platform.jetbrains.com/u/zhuohuang.yu)\
**Post date:** [March 3, 2025, 9:47am UTC](https://platform.jetbrains.com/t/referencecontributor-not-work-from-custom-langauge/733/4 "2025-03-03T09:47:43Z")

</div>

Thanks guy. After implementing getReferences to my language element. The reference and completion works.
