<div dir="ltr"><div dir="ltr">On Tue, Nov 9, 2021 at 7:30 PM Demi Marie Obenour <<a href="mailto:demiobenour@gmail.com" target="_blank">demiobenour@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 11/9/21 1:03 PM, Sam McCall wrote:<br>
>> Could an index be persisted to disk, reloaded at startup<br>
> <br>
> (Clangd does have this too, FWIW)<br>
> <br>
> <br>
>> and incrementally changed as the user edits?<br>
> <br>
> User edits mean we need to parse new code.<br>
> Absent a pseudoparser, the only thing that parses code is clang.<br>
> Clang needs a full AST, so this step is slow.<br>
<br>
What I meant is that clang could reparse only the code the user has<br>
edited, rather than reparsing the entire source file from scratch.<br>
I believe rust-analyzer does exactly this for Rust source, and my<br>
understanding is that it is considered fast enough.</blockquote><div>Yes, you could do this, but not with clang as the parser.</div><div><br></div><div>Rust-analyzer has a custom parser, it does not reuse rustc for the most part. (rls does, and is _not_ considered fast enough).</div><div>Apart from error-resilience, one big reason for this is to carefully track its dependencies to allow incremental compilation (using salsa). I don't believe this is something we could bolt onto clang.</div><div><br></div><div>Moreover rust is a smaller language with simpler parsing rules and shorter dependency chains.</div><div>(A _lot_ of normal C++ code can't be parsed according to the spec without executing template metaprograms.)</div><div>So the idea of building a correct parser with incremental parsing is IMO much harder for C++.</div><div><br></div><br></div></div>