I'm trying to understand how rust-analyzer updates the AST after an edit, and re-run or update analyses. I'm guessing it takes an incremental approach and doesn't re-run everything from scratch, but I'm not sure where to look for how this is implemented. Given an edit (say I turn a normal function into an async function by adding the keyword "async") how does rust-analyzer updates the AST, analysis results etc.? Which files/modules should I be looking at?
The entry point here is
Though, that method is rather boring -- mostly is says "ok, now this file has this content"
Figuring out which caches need to be invalidates is the job of salsa: https://github.com/salsa-rs/salsa
Thanks! I'm trying to find where does re-parsing happen (after a
set_file_text_with_durability). Presumely salsa calls rust-analyzer at some point, right? Which rust-analyzer function does it call with the new file contents?
That would be
SourceDatabase::parse function, defined in
Thanks! Where do I look for generation of red tree from a green tree?
That would to
green is green, cursor is red, violets are blue, naming is hard
What is the reason for InternId to have type NonZeroU32 instead of u32 ? Optimizations?
Yup, so that
Option<InternId> takes 32 bits