How to make XML attributes reference to SQL tables?

Answered

I'm developing a plugin for InteliJ Platform.

I'm trying to provide SQL table and fields references inside XML attributes and tags.

Let's say I have an XML:

When user wants to go to declaration of a table or a field (by Ctrl+Click or Ctrl+B), the database panel should open showing target table or field.


What I have tried:
I created a reference contributor and a reference provider. I obtain a string value containing table name "users" but don't know what to do with it.
I have not found any API to create an SQL table reference and resolve it. I have added com.intellij.database as dependency in my plugin.xml

Also I tried to use XML DOM API for this, but did not succeed:

It seems that XML DOM API cannot auto-resolve DOM <-> non DOM references.


I achieved the behaviour I need (for sql table name only) by configuring an Injected Language (language - SQL, prefix = "SELECT * from "), but I don't like this solution.

Any help would be appreciated.

 

0
1 comment
Avatar
Permanently deleted user

I found a solution. I used the class "com.intellij.database.psi.DbPsiFacade".

I have to iterate over all datasources to find schemas and tables.

 

0

Please sign in to leave a comment.