This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Isolate logic for setting LSPServer options
Needs ReviewPublic

Authored by kadircet on Sep 6 2022, 12:18 AM.

Details

Reviewers
sammccall
Summary

Moves clangdserveropt gathering into a separate function to make sure
it's done before we take any actions based on options.

This also moves some state that controls how we handle certain requests from
LSPServer to options.

Diff Detail

Event Timeline

kadircet created this revision.Sep 6 2022, 12:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 6 2022, 12:18 AM
Herald added a subscriber: arphaman. · View Herald Transcript
kadircet requested review of this revision.Sep 6 2022, 12:18 AM
kadircet updated this revision to Diff 458128.Sep 6 2022, 3:17 AM

rename helper & add comment

I like the change to initialize() a lot.

clang-tools-extra/clangd/ClangdLSPServer.h
64

I don't really like making these options part of this struct.

Currently this struct is largely used to send data from main->ClangdLSPServer.
After this patch, half of the fields are for that and half of them are scratch space for ClangdLSPServer to use itself. Worse, they *look* like things that can/should be set beforehand, but will in fact the passed values are ignored.
(Admittedly, some of the *inherited* fields are used in the same way, sigh).

Additionally, these options are publicly exposed when they don't need to be - these are internals leaking into API without a use case.


Having updateServerOptions be a hidden helper rather than a member is nice, but I think not as important as the actual public interface.

Grouping the options is also nice. Having the members be consecutive seems enough to me (they're almost grouped: background queue state is in the wrong place). Adding a second struct also seems like an option though?

kadircet updated this revision to Diff 458769.Sep 8 2022, 9:21 AM

I agree this is creating confusing state for constructors of ClangdLSPServer. It
would be interesting to create LSPServer after the initialize request one day.

  • Make client-capability related options private again.