diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2017-02-07 10:28:20 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2017-02-07 10:28:20 +0000 |
| commit | bb1cdb63e5b1dfdb44ccb1f70b9d203138abec9a (patch) | |
| tree | 1c91a61cd4f099499cef0a704e8df9c111c38285 /clang-tools-extra/clangd/DocumentStore.h | |
| parent | b2b70975e03db7644a07df65139c49fa004e2e11 (diff) | |
| download | bcm5719-llvm-bb1cdb63e5b1dfdb44ccb1f70b9d203138abec9a.tar.gz bcm5719-llvm-bb1cdb63e5b1dfdb44ccb1f70b9d203138abec9a.zip | |
Add a prototype for clangd
clangd is a language server protocol implementation based on clang. It's
supposed to provide editor integration while not suffering from the
confined ABI of libclang.
This implementation is limited to the bare minimum functionality of
doing (whole-document) formatting and rangeFormatting. The JSON parsing
is based on LLVM's YAMLParser but yet most of the code of clangd is
currently dealing with JSON serialization and deserialization.
This was only tested with VS Code so far, mileage with other LSP clients
may vary.
Differential Revision: https://reviews.llvm.org/D29451
llvm-svn: 294291
Diffstat (limited to 'clang-tools-extra/clangd/DocumentStore.h')
| -rw-r--r-- | clang-tools-extra/clangd/DocumentStore.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/DocumentStore.h b/clang-tools-extra/clangd/DocumentStore.h new file mode 100644 index 00000000000..dd4555c0131 --- /dev/null +++ b/clang-tools-extra/clangd/DocumentStore.h @@ -0,0 +1,38 @@ +//===--- DocumentStore.h - File contents container --------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_DOCUMENTSTORE_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_DOCUMENTSTORE_H + +#include "clang/Basic/LLVM.h" +#include "llvm/ADT/StringMap.h" +#include <string> + +namespace clang { +namespace clangd { + +/// A container for files opened in a workspace, addressed by URI. The contents +/// are owned by the DocumentStore. +class DocumentStore { +public: + /// Add a document to the store. Overwrites existing contents. + void addDocument(StringRef Uri, StringRef Text) { Docs[Uri] = Text; } + /// Delete a document from the store. + void removeDocument(StringRef Uri) { Docs.erase(Uri); } + /// Retrieve a document from the store. Empty string if it's unknown. + StringRef getDocument(StringRef Uri) const { return Docs.lookup(Uri); } + +private: + llvm::StringMap<std::string> Docs; +}; + +} // namespace clangd +} // namespace clang + +#endif |

