diff options
| author | Krasimir Georgiev <krasimir@google.com> | 2017-04-10 13:31:39 +0000 |
|---|---|---|
| committer | Krasimir Georgiev <krasimir@google.com> | 2017-04-10 13:31:39 +0000 |
| commit | 63ccdec952cbbaeb58833065f091d2a81a07b7d2 (patch) | |
| tree | 5fe13f902c776b3bda3d801679408547db68ddad /clangd/ProtocolHandlers.cpp | |
| parent | 8f75b247568116300dff3b2d3546e2f1bf0e25e9 (diff) | |
[clangd] Remove ASTUnits for closed documents and cache CompilationDatabase per directory.
Contributed by ilya-biryukov!
Differential Revision: https://reviews.llvm.org/D31746
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@299843 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clangd/ProtocolHandlers.cpp')
| -rw-r--r-- | clangd/ProtocolHandlers.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/clangd/ProtocolHandlers.cpp b/clangd/ProtocolHandlers.cpp index 274a601d..4c81692b 100644 --- a/clangd/ProtocolHandlers.cpp +++ b/clangd/ProtocolHandlers.cpp @@ -24,6 +24,17 @@ void TextDocumentDidOpenHandler::handleNotification( Store.addDocument(DOTDP->textDocument.uri.file, DOTDP->textDocument.text); } +void TextDocumentDidCloseHandler::handleNotification( + llvm::yaml::MappingNode *Params) { + auto DCTDP = DidCloseTextDocumentParams::parse(Params); + if (!DCTDP) { + Output.log("Failed to decode DidCloseTextDocumentParams!\n"); + return; + } + + Store.removeDocument(DCTDP->textDocument.uri.file); +} + void TextDocumentDidChangeHandler::handleNotification( llvm::yaml::MappingNode *Params) { auto DCTDP = DidChangeTextDocumentParams::parse(Params); @@ -156,7 +167,7 @@ void CodeActionHandler::handleMethod(llvm::yaml::MappingNode *Params, std::string Code = AST.getStore().getDocument(CAP->textDocument.uri.file); std::string Commands; for (Diagnostic &D : CAP->context.diagnostics) { - std::vector<clang::tooling::Replacement> Fixes = AST.getFixIts(D); + std::vector<clang::tooling::Replacement> Fixes = AST.getFixIts(CAP->textDocument.uri.file, D); std::string Edits = replacementsToEdits(Code, Fixes); if (!Edits.empty()) |
