# Resolve references from custom language

**URL:** <https://platform.jetbrains.com/t/resolve-references-from-custom-language/1583>\
**Category:** IntelliJ Platform\
**Created:** [May 2, 2025, 11:35pm UTC](https://platform.jetbrains.com/t/resolve-references-from-custom-language/1583 "2025-05-02T23:35:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![xterao\_haruka](https://avatars.discourse-cdn.com/v4/letter/x/8baadc/32.png) [@xterao\_haruka](https://platform.jetbrains.com/u/xterao_haruka)\
**Post date:** [May 28, 2025, 9:05am UTC](https://platform.jetbrains.com/t/resolve-references-from-custom-language/1583/2 "2025-05-28T09:05:49Z")

</div>

The string element you’re trying to resolve in the sample is a `PsiLiteralExpression`, which appears to be one of the classes that `getReferencesByElement()` can accept.

Although the exact rules aren’t clear, an element seems to be passed to `getReferencesByElement()` if it (1) inherits from certain PSI classes **or** (2) overrides `PsiElement.getReferences()` as shown below. (This is the technique I used to enable reference resolution for elements in my own custom language.)

> [@ReferenceContributor not work from custom langauge](https://platform.jetbrains.com/t/referencecontributor-not-work-from-custom-langauge/733/2):
>
> Hi. I’ve spent much time to understand how to do it in my own custom languages and why it didn’t work grin Things that help me to inject references to my psi elements: add override fun getReferences(): Array\<PsiReference\> = ReferenceProvidersRegistry.getReferencesFromProviders(this) to the element should have references 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 not…

```JAVA
@Override
public @NotNull PsiReference[] getReferences() {
  return ReferenceProvidersRegistry.getReferencesFromProviders(this);
}

```

With that in mind, would it be possible to create a custom PSI element class for a dummy call, then have your injection recognize that element type and add the above overrides?

---

_[View the full topic](https://platform.jetbrains.com/t/resolve-references-from-custom-language/1583)._
