netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Refactored configuration management for LSP module

Open Achal1607 opened this issue 7 months ago • 1 comments

Currently, configuration requests require a round trip every time the language server needs a value from the client. For example, in TextDocumentServiceImpl, the completion method, which provides auto-complete suggestions, performs a round trip to fetch configuration values like netbeans.javadoc.load.timeout and netbeans.completion.warning.time. Additionally, listening to changes in specific configurations is difficult, as it requires registration in WorkspaceServiceImpl and it is not extensible.

This PR aims to address these challenges by introducing a new class, ClientConfigurationManager, which manages clients along with their configurations. It serves configuration values from a local cache if available, and only performs a request to the client when necessary. It also listens for configuration changes to keep the cache in sync. There is also a new class ConfigValueCache which takes care of all the business logic of traversing the tree and maintaining configs according to the scopes as well. Moreover, it allows listeners in the form of BiConsumer to be attached to specific configuration keys, enabling appropriate actions to be taken automatically when those configurations change.

PS: Thanks to @sid-srini for helping in the design.

Achal1607 avatar May 21 '25 10:05 Achal1607

@lahodaj addressed your review comments, please have a look again whenever it is possible. Thanks.

Achal1607 avatar Jun 07 '25 09:06 Achal1607

Seems sensible to me. Please note that there was a test in java.lsp.server failing - I've restarted the test, so we'll see.

@sdedic - please let us know if you have any comments. Thanks!

lahodaj avatar Jun 30 '25 06:06 lahodaj

@Achal1607 just a nitpick for future PRs: it is better to describe in the commit msg what the commit changed or why the changes were made. When looking through history or running a git bisect "addressed review comments" is no longer helpful at this point.

mbien avatar Nov 06 '25 13:11 mbien

@Achal1607 just a nitpick for future PRs: it is better to describe in the commit msg what the commit changed or why the changes were made. When looking through history or running a git bisect "addressed review comments" is no longer helpful at this point.

Thank you for the feedback, I’ll make sure to include more descriptive and meaningful commit messages in future PRs.

Achal1607 avatar Nov 06 '25 13:11 Achal1607

@Achal1607 you can still change it if you want ;)

mbien avatar Nov 06 '25 13:11 mbien

Since it is a very old PR, I don't rember exact details, but will try to modify the commit by reading through the history of this PR.

Achal1607 avatar Nov 06 '25 14:11 Achal1607

@Achal1607 , I think what @mbien means is that it would be cleaner if the commit message just said "Refactored configuration management for LSP module", and didn't include these details:

addressed review comments

addressed some review comments

addressed review comments

fixed unit tests

lahodaj avatar Nov 06 '25 15:11 lahodaj

@lahodaj , @mbien pushed again with the updated commit message.

Achal1607 avatar Nov 07 '25 05:11 Achal1607