Resolving to a java class name from a custom language



I'm writing a custom language which can have references to Java class names inside of strings. I'm hoping to get code completion of the class names for whatever classpath is available in the current project, sort of like XML does:

After looking through the source code, it seems to me that this is done using the class, registered as a reference contributor in the java-i18n plugin.xml file. But I cannot figure out how to a add a similar reference contributor to my language, so that I could get java class code completion, like this:

Is there a way to leverage this functionality?



You should implement a similar reference contributor but for your language, instead of XML. It should contribute Java class references in your language string literal elements.

More about references:


I tried to create a reference contributor, but I don't seem to have access to com.intellij.psi.impl.source.resolve.reference.impl.providers.JavaClassListReferenceProvider on my classpath in the plugin code. Is there a way for me to contribute java class references using an out-of-the-box solution like this? Maybe there's a dependency I can add to my gradle build to put java-impl classes on my classpath?

I'd rather not have to implement retrieving all the class references from scratch…


You most likely need to add a dependency on the Java plugin. See

Please also note that JavaClassListReferenceProvider is not a part of the open API, and may be changed in the future without preserving backward compatibility.


Please sign in to leave a comment.