OpenLiberty / liberty-language-server

The Liberty Config Language Server provides language server features for Liberty server configuration files through any of the supported client IDEs.
Eclipse Public License 2.0
5 stars 11 forks source link

Provide DS type-aware diagnostics + code actions for server.xml refs #258

Open scottkurz opened 8 months ago

scottkurz commented 8 months ago

When we have an 'xyzRef' attribute like jobStoreRef in:

<batchPersistence jobStoreRef="xyz"/>

we only do validation and code-assist in the XSD space. This doesn't capture the level of type-awareness we could provide if we built a model of the DS types of the elements configured within the server.xml.

(Here I'll stop and acknowledge I'm probably not using the correct terminology. Apologies for that).

On the other hand, WDT/LDT does build such a model and so it is able to offer a code action of specific values of elements of the right (DS) type . So here I get a code action completion suggestion of the databaseStore-typed elements that are actually configured in this server.xml

image

and a diagnostic if the value doesn't match an actually-configured element of the right type:

image

The XSD validation is a much-simpler validation, just ensuring there are no spaces or commas.

Not sure if the WDT/LDT validation happens after all server config files (dropins/includes) are merged or not. (A bit of a separate issue though).

One more point

I could nitpick a bit with the WDT/LDT validation design with the above example. It seems to complain about a server.xml with just this:

 <batchPersistence jobStoreRef="defaultDatabaseStore"/>
 <dataSource id="DefaultDataSource">

saying An element of type 'databaseStore' with ID 'defaultDatabaseStore' could not be found.

Well, defaultDatabaseStore may not explicitly be listed in server.xml, but it's still active as a default instance defined at another level, in this case.

Perhaps since it's only a warning we are close enough. But something to think about before we add new code, libraries, etc. to the mix here.