Problems understanding LineMarkerProvider and ReferenceContributor

Hi There,

I am working on a plugin that should provide navigation between different XML files and between XML and Java sources. It's a bit similar to the Spring support.
The XML files have a <name> child (in contrast to the id attribute in Spring) and references are just like spring: ref="..." Navigation to Java sources will be a later step. There is also a naming convention for the xml files to support for the new plugin: *-definitions.xml

At the moment, I am stuck at one of the first steps: LineMarkerProvider and ReferenceContributor.

I used the "Custom Language Support" example as starting point. Because I do not have a custom language but want to extend xml functionality instead, I omitted the lexer, parser, file factory etc ... and went directly to LineMarkerProvider and ReferenceContributor.

What I have up to now is:

  • class DefinitionsReference extends PsiReferenceBase<PsiElement>
  • class DefinitionsUtil (similar to SimplePsiImplUtil)
  • class DefinitionsLineMarkerProvider extends RelatedItemLineMarkerProvider
  • class DefinitionsReferenceContributor extends PsiReferenceContributor

I registered the LineMarkerProvider (language=XML) and ReferenceContributor in plugin.xml and I added some logging output to verify if they are called and if the results are empty or not.

Although ReferenceContributor.PsiReferenceProvider.getReferencesByElement() as well as DefinitionsReference.multiResolve() and reslove() indeed return some non-emptyresults and LineMarkerProvider.collectNavigationMarkers() does find some plces to mark, I do neither get navigation gutter icons nor can I navigate from a ref= to the corresponding <name> tag. It says "cannot find declaration to go to".

Seems I missed some important detail.
What should I look for first ?

Thanks and Regards,


Apologies for a late answer. The steps you have performed look correct; if you haven't yet figured out the solution yet, is there a chance that you could post the code somewhere so that we could take a look?


I have cleaned up some experimental stuff. You can download (source code and example xml) from (auto-deleted after one month from today).


You might wanna consider using DOM model for your XML files, especially for cross-references in XML/XML->Java it's easier than building ReferenceContributors for every single element.


Please sign in to leave a comment.