ilya-biryukov added a comment.

In https://reviews.llvm.org/D49267#1173291, @simark wrote:

> Ok, I agree that having clangd watch files itself could be necessary at some 
> point (when the client does not support it), but it would have to be 
> configurable.  In our case, we have efficient enough file watching in the 
> client, and already watch the files in the workspace.  Since the inotify 
> watches are limited per-user, having clangd watch them too means we'll have 
> duplicates, and therefore waste a rather limited resource.
>
> Actually, clangd could simply use the client capabilities. If the client 
> advertises support for file watching with dynamic registration, use that, 
> otherwise use the internal mechanism.


Yeah, sounds reasonable. The limits on the number of watches is definitely 
something that could bite the editor+clangd bundle, so that's a good reason to 
use the client watching if that's available.
We want to share some design around this area in Aug-Sep.

> In the mean time, I don't think the current patch paints us in a corner.  The 
> logic of checking whether the effective compile commands for open files 
> changes would stay even if the file watching mechanism changes.

Agreed. But let's try to keep the change minimal, specifically we could get 
away without replacing 'reparseOpenedFiles', see the inline comment about it.



================
Comment at: clangd/ClangdLSPServer.cpp:430
     CDB.clear();
-
-    reparseOpenedFiles();
+    compileCommandsChangePost(CCChangeData);
   }
----------------
Maybe keep the old logic of reparsing all open files? This would make the 
change way simpler and I don't think we need this extra complexity in the long 
run, when we have better integration with the build system.

ClangdServer will reuse the preamble if compile command didn't change anyway, 
so reparse will be very fast and shouldn't be affected.
If the compile command does change, we'll retrigger the full rebuild.


================
Comment at: clangd/clients/clangd-vscode/src/extension.ts:35
         ['cpp', 'c', 'cc', 'cxx', 'c++', 'm', 'mm', 'h', 'hh', 'hpp', 'hxx', 
'inc'].join() + '}';
+    const compileCommandsFilePattern: string = '**/compile_commands.json';
     const clientOptions: vscodelc.LanguageClientOptions = {
----------------
These watches apply to the children of the workspace root only, right?
E.g., I quite often open the workspace in 
'llvm/tools/clang/tools/extra/clangd', would my `compile_commands.json`, that's 
outside the workspace, be watched for changes?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49267



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to