<div dir="ltr">Is there a particular reason why this commit didn't have a corresponding test included?<div>Cheers,</div><div>Alex</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 1 August 2018 at 04:28, Simon Marchi via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: simark<br>
Date: Wed Aug  1 04:28:49 2018<br>
New Revision: 338518<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=338518&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=338518&view=rev</a><br>
Log:<br>
[clangd] Receive compilationDatabasePath in 'initialize' request<br>
<br>
Summary:<br>
That way, as soon as the "initialize" is received by the server, it can start<br>
parsing/indexing with a valid compilation database and not have to wait for a<br>
an initial 'didChangeConfiguration' that might or might not happen.<br>
Then, when the user changes configuration, a didChangeConfiguration can be sent.<br>
<br>
Signed-off-by: Marc-Andre Laperle <<a href="mailto:marc-andre.laperle@ericsson.com">marc-andre.laperle@ericsson.<wbr>com</a>><br>
<br>
Reviewers: malaperle<br>
<br>
Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D49833" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D49833</a><br>
<br>
Modified:<br>
    clang-tools-extra/trunk/<wbr>clangd/ClangdLSPServer.cpp<br>
    clang-tools-extra/trunk/<wbr>clangd/ClangdLSPServer.h<br>
    clang-tools-extra/trunk/<wbr>clangd/Protocol.cpp<br>
    clang-tools-extra/trunk/<wbr>clangd/Protocol.h<br>
<br>
Modified: clang-tools-extra/trunk/<wbr>clangd/ClangdLSPServer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=338518&r1=338517&r2=338518&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-extra/<wbr>trunk/clangd/ClangdLSPServer.<wbr>cpp?rev=338518&r1=338517&r2=<wbr>338518&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- clang-tools-extra/trunk/<wbr>clangd/ClangdLSPServer.cpp (original)<br>
+++ clang-tools-extra/trunk/<wbr>clangd/ClangdLSPServer.cpp Wed Aug  1 04:28:49 2018<br>
@@ -72,6 +72,9 @@ SymbolKindBitset defaultSymbolKinds() {<br>
 } // namespace<br>
<br>
 void ClangdLSPServer::onInitialize(<wbr>InitializeParams &Params) {<br>
+  if (Params.initializationOptions)<br>
+    applyConfiguration(*Params.<wbr>initializationOptions);<br>
+<br>
   if (Params.rootUri && *Params.rootUri)<br>
     Server.setRootPath(Params.<wbr>rootUri->file());<br>
   else if (Params.rootPath && !Params.rootPath->empty())<br>
@@ -398,11 +401,8 @@ void ClangdLSPServer::onHover(<wbr>TextDocume<br>
                    });<br>
 }<br>
<br>
-// FIXME: This function needs to be properly tested.<br>
-void ClangdLSPServer::<wbr>onChangeConfiguration(<br>
-    DidChangeConfigurationParams &Params) {<br>
-  ClangdConfigurationParamsChang<wbr>e &Settings = Params.settings;<br>
-<br>
+void ClangdLSPServer::<wbr>applyConfiguration(<br>
+    const ClangdConfigurationParamsChang<wbr>e &Settings) {<br>
   // Compilation database change.<br>
   if (Settings.<wbr>compilationDatabasePath.<wbr>hasValue()) {<br>
     NonCachedCDB.<wbr>setCompileCommandsDir(<br>
@@ -413,6 +413,12 @@ void ClangdLSPServer::<wbr>onChangeConfigurat<br>
   }<br>
 }<br>
<br>
+// FIXME: This function needs to be properly tested.<br>
+void ClangdLSPServer::<wbr>onChangeConfiguration(<br>
+    DidChangeConfigurationParams &Params) {<br>
+  applyConfiguration(Params.<wbr>settings);<br>
+}<br>
+<br>
 ClangdLSPServer::<wbr>ClangdLSPServer(JSONOutput &Out,<br>
                                  const clangd::CodeCompleteOptions &CCOpts,<br>
                                  llvm::Optional<Path> CompileCommandsDir,<br>
<br>
Modified: clang-tools-extra/trunk/<wbr>clangd/ClangdLSPServer.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=338518&r1=338517&r2=338518&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-extra/<wbr>trunk/clangd/ClangdLSPServer.<wbr>h?rev=338518&r1=338517&r2=<wbr>338518&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- clang-tools-extra/trunk/<wbr>clangd/ClangdLSPServer.h (original)<br>
+++ clang-tools-extra/trunk/<wbr>clangd/ClangdLSPServer.h Wed Aug  1 04:28:49 2018<br>
@@ -82,6 +82,7 @@ private:<br>
   /// may be very expensive.  This method is normally called when the<br>
   /// compilation database is changed.<br>
   void reparseOpenedFiles();<br>
+  void applyConfiguration(const ClangdConfigurationParamsChang<wbr>e &Settings);<br>
<br>
   JSONOutput &Out;<br>
   /// Used to indicate that the 'shutdown' request was received from the<br>
<br>
Modified: clang-tools-extra/trunk/<wbr>clangd/Protocol.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=338518&r1=338517&r2=338518&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-extra/<wbr>trunk/clangd/Protocol.cpp?rev=<wbr>338518&r1=338517&r2=338518&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- clang-tools-extra/trunk/<wbr>clangd/Protocol.cpp (original)<br>
+++ clang-tools-extra/trunk/<wbr>clangd/Protocol.cpp Wed Aug  1 04:28:49 2018<br>
@@ -263,7 +263,7 @@ bool fromJSON(const json::Value &Params,<br>
   O.map("rootPath", R.rootPath);<br>
   O.map("capabilities", R.capabilities);<br>
   O.map("trace", R.trace);<br>
-  // initializationOptions, capabilities unused<br>
+  O.map("initializationOptions", R.initializationOptions);<br>
   return true;<br>
 }<br>
<br>
<br>
Modified: clang-tools-extra/trunk/<wbr>clangd/Protocol.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.h?rev=338518&r1=338517&r2=338518&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-extra/<wbr>trunk/clangd/Protocol.h?rev=<wbr>338518&r1=338517&r2=338518&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- clang-tools-extra/trunk/<wbr>clangd/Protocol.h (original)<br>
+++ clang-tools-extra/trunk/<wbr>clangd/Protocol.h Wed Aug  1 04:28:49 2018<br>
@@ -322,6 +322,16 @@ struct ClientCapabilities {<br>
<br>
 bool fromJSON(const llvm::json::Value &, ClientCapabilities &);<br>
<br>
+/// Clangd extension to set clangd-specific "initializationOptions" in the<br>
+/// "initialize" request and for the "workspace/<wbr>didChangeConfiguration"<br>
+/// notification since the data received is described as 'any' type in LSP.<br>
+struct ClangdConfigurationParamsChang<wbr>e {<br>
+  llvm::Optional<std::string> compilationDatabasePath;<br>
+};<br>
+bool fromJSON(const llvm::json::Value &, ClangdConfigurationParamsChang<wbr>e &);<br>
+<br>
+struct ClangdInitializationOptions : public ClangdConfigurationParamsChang<wbr>e {};<br>
+<br>
 struct InitializeParams {<br>
   /// The process Id of the parent process that started<br>
   /// the server. Is null if the process has not been started by another<br>
@@ -348,6 +358,10 @@ struct InitializeParams {<br>
<br>
   /// The initial trace setting. If omitted trace is disabled ('off').<br>
   llvm::Optional<TraceLevel> trace;<br>
+<br>
+  // We use this predefined struct because it is easier to use<br>
+  // than the protocol specified type of 'any'.<br>
+  llvm::Optional<<wbr>ClangdInitializationOptions> initializationOptions;<br>
 };<br>
 bool fromJSON(const llvm::json::Value &, InitializeParams &);<br>
<br>
@@ -419,13 +433,6 @@ struct DidChangeWatchedFilesParams {<br>
 };<br>
 bool fromJSON(const llvm::json::Value &, DidChangeWatchedFilesParams &);<br>
<br>
-/// Clangd extension to manage a workspace/<wbr>didChangeConfiguration notification<br>
-/// since the data received is described as 'any' type in LSP.<br>
-struct ClangdConfigurationParamsChang<wbr>e {<br>
-  llvm::Optional<std::string> compilationDatabasePath;<br>
-};<br>
-bool fromJSON(const llvm::json::Value &, ClangdConfigurationParamsChang<wbr>e &);<br>
-<br>
 struct DidChangeConfigurationParams {<br>
   // We use this predefined struct because it is easier to use<br>
   // than the protocol specified type of 'any'.<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>