summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/ClangdLSPServer.cpp
diff options
context:
space:
mode:
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>2018-07-05 19:35:01 +0000
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>2018-07-05 19:35:01 +0000
commit1be69701c3e238d12a53c5b487291c893286025c (patch)
treefa01a576a4e6dd41ec4af2521611fa16dedd3cc0 /clang-tools-extra/clangd/ClangdLSPServer.cpp
parent7bd8970743f45a006b8f12c97aac92999f41b2c0 (diff)
downloadbcm5719-llvm-1be69701c3e238d12a53c5b487291c893286025c.tar.gz
bcm5719-llvm-1be69701c3e238d12a53c5b487291c893286025c.zip
[clangd] Implementation of textDocument/documentSymbol
Summary: An AST-based approach is used to retrieve the document symbols rather than an in-memory index query. The index is not an ideal fit to achieve this because of the file-centric query being done here whereas the index is suited for project-wide queries. Document symbols also includes more symbols and need to keep the order as seen in the file. Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Subscribers: tomgr, ilya-biryukov, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47846 llvm-svn: 336386
Diffstat (limited to 'clang-tools-extra/clangd/ClangdLSPServer.cpp')
-rw-r--r--clang-tools-extra/clangd/ClangdLSPServer.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 77a0bb1c01d..385768a14b0 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -112,6 +112,7 @@ void ClangdLSPServer::onInitialize(InitializeParams &Params) {
{"documentHighlightProvider", true},
{"hoverProvider", true},
{"renameProvider", true},
+ {"documentSymbolProvider", true},
{"workspaceSymbolProvider", true},
{"executeCommandProvider",
json::obj{
@@ -294,6 +295,19 @@ void ClangdLSPServer::onDocumentFormatting(DocumentFormattingParams &Params) {
llvm::toString(ReplacementsOrError.takeError()));
}
+void ClangdLSPServer::onDocumentSymbol(DocumentSymbolParams &Params) {
+ Server.documentSymbols(
+ Params.textDocument.uri.file(),
+ [this](llvm::Expected<std::vector<SymbolInformation>> Items) {
+ if (!Items)
+ return replyError(ErrorCode::InvalidParams,
+ llvm::toString(Items.takeError()));
+ for (auto &Sym : *Items)
+ Sym.kind = adjustKindToCapability(Sym.kind, SupportedSymbolKinds);
+ reply(json::ary(*Items));
+ });
+}
+
void ClangdLSPServer::onCodeAction(CodeActionParams &Params) {
// We provide a code action for each diagnostic at the requested location
// which has FixIts available.
OpenPOWER on IntegriCloud