[PATCH] D49833: [clangd] Receive compilationDatabasePath in 'initialize' request

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 31 01:36:38 PDT 2018


ilya-biryukov added a comment.

In https://reviews.llvm.org/D49833#1181651, @malaperle wrote:

> Was there any objection to this patch? It would have been nice to have this before the branching.


Sorry for the delay, somehow missed this update in my inbox.

In https://reviews.llvm.org/D49833#1177230, @malaperle wrote:

> LSP:
>
> > Until the server has responded to the initialize request with an InitializeResult, the client must not send any additional requests or notifications to the server.
>
> So the client is free to send "didOpen" or any request after the "initialize", which means we could end up parsing files with wrong commands before we get the first "didChangeConfiguration". In fact, in our indexing prototype we start indexing as soon as the "initialize" is processed and we do not know whether or not there will be a didChangeConfiguration soon after.
>  Setting the CDB path as part of the initialize seems more natural and less error-prone.


Thanks for clarifying the use-case, that does seem like the best option if you want to start indexing as soon as you initialize.

Overall LG, just a small suggestion on how to rearrange the options.



================
Comment at: clangd/Protocol.h:362
+  // than the protocol specified type of 'any'.
+  llvm::Optional<ClangdConfigurationParamsChange> initializationOptions;
 };
----------------
Maybe add another level of indirection from the start to make sure we'll be able to add more init options later without breaking the existing clients?
```
/// Clangd-specific initialization options that can be passed on the initial initialization request.
struct ClangdInitOptions {
  llvm::Optional<ClangdConfigurationParamsChange> initialConfiguration; 
  // can add more options here in a backwards-compatible manner
};

struct InitializeParams {
  /// ....
  llvm::Optional<ClangdConfigurationParamsChange> initializationOptions;
};
```


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49833





More information about the cfe-commits mailing list