[clangd] Publish diagnostics with stale preambles
This patch achieves this by building an AST and invoking main file callbacks on each update, in addition to preamble updates. It means we might have some extra AST builds now (e.g. if an update was with a stale preamble and there were no reads on it, we would only build an AST once we had the fresh preamble. Now we'll build 2, once with the stale preamble and another with the fresh one, but we'll have one more diagnostics cycle in between.). This patch preserves forward progress of diagnostics by always using the latest main file contents when emitting diagnostics after preamble builds. It also guarantees eventual consistency: - if an update doesn't invalidate preamble, we'll emit diagnostics with fresh preamble already. - if an update invalidates preamble, we'll first emit diagnostics with stale contents, and then once the preamble build finishes it'll emit diagnostics (as preamble has changed) with newest version. This has implications on parsing callbacks, as previously onMainAST callback was called at most once, now it can be called up to 2 times. All of the existing clients can already deal with callback firing multiple times. Differential Revision: https://reviews.llvm.org/D144456
Loading
Please sign in to comment