I am developing a plugin for a custom language. I am following the tutorial at http://confluence.jetbrains.com/display/IntelliJIDEA/Custom+Language+Support. I followed all the steps in the "Reference Contributor" section to support navigation from usage to declaration of a module in my language(when Ctrl + B) is pressed. The usage and declaration are in different files.
When I ran the project, on pressing Ctrl + B on a module usage, control did not come to the PsiReferenceProvider.getReferencesByElement. I spent quite some time figuring this out but was not able to make it work. Then I came across another post http://devnet.jetbrains.com/message/5482729#5482729 where it was posted
"In your custom language, there is usually no need to go through ReferenceProvidersRegistry to provide references for an element. Instead, you can put all your logic directly into the getReferences() method of your PsiElement."
In my case, SimpleNamedElementImpl from http://confluence.jetbrains.com/display/IntelliJIDEA/Reference+Contributor is the class from PsiElement where I updated the getReferences() method. That worked and I was able to successfully navigate.
Is this the right way to support navigation? Why didn't the reference contributor work? Is there any other tutorial which goes into this in more detail. It took me a combination of going through the forums, the tutorial mentioned above, the CE source code and some debugging to figure this out. I would appreciate any help. Thanks