Make IntelliJ aware of links to Java elements in XML files

后端 未结 1 991
迷失自我
迷失自我 2021-01-06 03:05

I have a custom XML format that links to Java resources. For the sake of simplicity let\'s assume my XML file would look like this:



        
相关标签:
1条回答
  • 2021-01-06 03:24

    First of all, here's a nice tutorial that came up a few days ago, which explains the basics of IntelliJ plugin development (you should take a look at the section Reference Contributor).

    You will likely have to define your own PsiReferenceContributor, which will be referenced in your plugin.xml like this:

    <psi.referenceContributor implementation="com.yourplugin.YourReferenceContributor"/>
    

    In your reference contributor, there's a method registerReferenceProviders(PsiReferenceRegistrar) where you will be able to call registry.registerReferenceProvider(XmlTag.class, provider).

    Finally, in your instance of PsiReferenceProvider, you will have to test the tag name to filter out tags which don't contain class references, then find the right Java class using JavaPsiFacade.findClass().

    From my experience, the best place to get help regarding IntelliJ plugin development is JetBrains' forums.

    0 讨论(0)
提交回复
热议问题