diff options
Diffstat (limited to 'clang-tools-extra/clangd/ClangdServer.cpp')
-rw-r--r-- | clang-tools-extra/clangd/ClangdServer.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp index 5b850e6ab47..71a1a99a330 100644 --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -17,6 +17,7 @@ #include "Preamble.h" #include "Protocol.h" #include "SemanticHighlighting.h" +#include "SemanticSelection.h" #include "SourceCode.h" #include "TUScheduler.h" #include "Trace.h" @@ -125,8 +126,8 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB, // critical paths. WorkScheduler( CDB, Opts.AsyncThreadsCount, Opts.StorePreamblesInMemory, - std::make_unique<UpdateIndexCallbacks>( - DynamicIdx.get(), DiagConsumer, Opts.SemanticHighlighting), + std::make_unique<UpdateIndexCallbacks>(DynamicIdx.get(), DiagConsumer, + Opts.SemanticHighlighting), Opts.UpdateDebounce, Opts.RetentionPolicy) { // Adds an index to the stack, at higher priority than existing indexes. auto AddIndex = [&](SymbolIndex *Idx) { @@ -620,6 +621,17 @@ void ClangdServer::symbolInfo(PathRef File, Position Pos, WorkScheduler.runWithAST("SymbolInfo", File, std::move(Action)); } +void ClangdServer::semanticRanges(PathRef File, Position Pos, + Callback<std::vector<Range>> CB) { + auto Action = + [Pos, CB = std::move(CB)](llvm::Expected<InputsAndAST> InpAST) mutable { + if (!InpAST) + return CB(InpAST.takeError()); + CB(clangd::getSemanticRanges(InpAST->AST, Pos)); + }; + WorkScheduler.runWithAST("SemanticRanges", File, std::move(Action)); +} + std::vector<std::pair<Path, std::size_t>> ClangdServer::getUsedBytesPerFile() const { return WorkScheduler.getUsedBytesPerFile(); |