mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user