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
6 stars 12 forks source link

Issue when using versionless features related to config elements #303

Closed cherylking closed 1 month ago

cherylking commented 1 month ago

When using versionless features in the server.xml, the missing config element diagnostic is flagging because we no longer have the relationship between the features and their config elements. Those are part of the versioned features. Need to figure out what we want to do about this. Two options I can think of:

  1. Turn off the missing config element diagnostic check if any versionless features are specified.
  2. Associate all config elements for all versioned features that correspond to a versionless feature to that feature so that we do not flag config elements as missing erroneously. The downside to this is we may associate a config element with a versionless feature for a newer version than what gets resolved at runtime (e.g. the latest version of feature x may have a new config element a that is not valid for an older version of feature x).
cherylking commented 1 month ago

I recommend option 2. I think we should maintain a collection of known versionless features (based off of finding features when processing features.json that have a required feature that contains .versionless. in the name). For example, the servlet versionless feature has a requireFeature with value io.openliberty.internal.versionless.servlet-3.0.

When processing the featurelist.xml to collect config elements, for every feature that is related to a versionless feature (e.g. servlet-4.0 is related to servlet versionless feature...just strip off everything after the last - including the - and check if it matches a versionless feature), add all of its config elements to the servlet FeatureListNode in the FeatureListGraph. See method FeatureService.readFeaturesFromFeatureListFile where it is processing configElements.

cherylking commented 1 month ago

Here is an example of the problem reported in this issue. When I change the feature from servlet-5.0 to just servlet and add the platform element for jakartaee-0.1, the httpEnpoint and webApplication elements are flagged with diagnostics stating there is no feature configured relating to that config element.

Screenshot 2024-09-19 at 11 12 59 AM

cherylking commented 1 month ago

Note that Arun came up with a much simpler approach to modify the method that was determining whether a config element had a feature configured for it, to look for the presence of a versionless feature corresponding to a feature that enabled the config element.