Cache calculated file state in LSP (#4897)

Add caching of parsed documents, and testing of the textDocument
handlers. This is based on #4896, which splits out some of the
boilerplate to calls.

Note, this caches the entire parse state because we'll want to try to
emit diagnostics when we see the update, without waiting. It may be
helpful to do that asynchronously, but we don't want to wait for another
call (such as documentSymbol). Really, we'll probably want to also add
check for diagnostics, at least.
This commit is contained in:
Jon Ross-Perkins authored and GitHub committed 2025-02-07 01:04:42 +00:00
1 parent 55714dd4ed
commit 9e466b9335
28 files changed
+498 -51

No files matched your search

+9
View File
@@ -51,6 +51,15 @@ auto SourceBuffer::MakeFromFile(llvm::vfs::FileSystem& fs,
filename, is_regular_file, consumer);
}
auto SourceBuffer::MakeFromStringCopy(llvm::StringRef filename,
llvm::StringRef text,
DiagnosticConsumer& consumer)
-> std::optional<SourceBuffer> {
return MakeFromMemoryBuffer(
llvm::MemoryBuffer::getMemBufferCopy(text, filename), filename,
/*is_regular_file=*/true, consumer);
}
auto SourceBuffer::MakeFromMemoryBuffer(
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> buffer,
llvm::StringRef filename, bool is_regular_file,