nridge created this revision. nridge added a reviewer: kadircet. Herald added subscribers: cfe-commits, usaxena95, arphaman. Herald added a project: clang. nridge requested review of this revision. Herald added subscribers: MaskRay, ilya-biryukov.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D91123 Files: clang-tools-extra/clangd/ClangdServer.cpp clang-tools-extra/clangd/ClangdServer.h Index: clang-tools-extra/clangd/ClangdServer.h =================================================================== --- clang-tools-extra/clangd/ClangdServer.h +++ clang-tools-extra/clangd/ClangdServer.h @@ -242,6 +242,21 @@ TypeHierarchyDirection Direction, Callback<llvm::Optional<TypeHierarchyItem>> CB); + /// Get information about call hierarchy for a given position. + void prepareCallHierarchy( + PathRef File, Position Pos, + Callback<llvm::Optional<std::vector<CallHierarchyItem>>> CB); + + /// Resolve incoming calls for a given call hierarchy item. + void incomingCalls( + const CallHierarchyItem &Item, + Callback<llvm::Optional<std::vector<CallHierarchyIncomingCall>>>); + + /// Resolve outgoing calls for a given call hierarchy item. + void outgoingCalls( + const CallHierarchyItem &Item, + Callback<llvm::Optional<std::vector<CallHierarchyOutgoingCall>>>); + /// Retrieve the top symbols from the workspace matching a query. void workspaceSymbols(StringRef Query, int Limit, Callback<std::vector<SymbolInformation>> CB); Index: clang-tools-extra/clangd/ClangdServer.cpp =================================================================== --- clang-tools-extra/clangd/ClangdServer.cpp +++ clang-tools-extra/clangd/ClangdServer.cpp @@ -677,6 +677,30 @@ CB(Item); } +void ClangdServer::prepareCallHierarchy( + PathRef File, Position Pos, + Callback<llvm::Optional<std::vector<CallHierarchyItem>>> CB) { + auto Action = [File = File.str(), Pos, CB = std::move(CB), + this](Expected<InputsAndAST> InpAST) mutable { + if (!InpAST) + return CB(InpAST.takeError()); + CB(clangd::prepareCallHierarchy(InpAST->AST, Pos, Index, File)); + }; + WorkScheduler.runWithAST("Call Hierarchy", File, std::move(Action)); +} + +void ClangdServer::incomingCalls( + const CallHierarchyItem &Item, + Callback<llvm::Optional<std::vector<CallHierarchyIncomingCall>>> CB) { + CB(clangd::incomingCalls(Item, Index)); +} + +void ClangdServer::outgoingCalls( + const CallHierarchyItem &Item, + Callback<llvm::Optional<std::vector<CallHierarchyOutgoingCall>>> CB) { + CB(clangd::outgoingCalls(Item, Index)); +} + void ClangdServer::onFileEvent(const DidChangeWatchedFilesParams &Params) { // FIXME: Do nothing for now. This will be used for indexing and potentially // invalidating other caches.
Index: clang-tools-extra/clangd/ClangdServer.h =================================================================== --- clang-tools-extra/clangd/ClangdServer.h +++ clang-tools-extra/clangd/ClangdServer.h @@ -242,6 +242,21 @@ TypeHierarchyDirection Direction, Callback<llvm::Optional<TypeHierarchyItem>> CB); + /// Get information about call hierarchy for a given position. + void prepareCallHierarchy( + PathRef File, Position Pos, + Callback<llvm::Optional<std::vector<CallHierarchyItem>>> CB); + + /// Resolve incoming calls for a given call hierarchy item. + void incomingCalls( + const CallHierarchyItem &Item, + Callback<llvm::Optional<std::vector<CallHierarchyIncomingCall>>>); + + /// Resolve outgoing calls for a given call hierarchy item. + void outgoingCalls( + const CallHierarchyItem &Item, + Callback<llvm::Optional<std::vector<CallHierarchyOutgoingCall>>>); + /// Retrieve the top symbols from the workspace matching a query. void workspaceSymbols(StringRef Query, int Limit, Callback<std::vector<SymbolInformation>> CB); Index: clang-tools-extra/clangd/ClangdServer.cpp =================================================================== --- clang-tools-extra/clangd/ClangdServer.cpp +++ clang-tools-extra/clangd/ClangdServer.cpp @@ -677,6 +677,30 @@ CB(Item); } +void ClangdServer::prepareCallHierarchy( + PathRef File, Position Pos, + Callback<llvm::Optional<std::vector<CallHierarchyItem>>> CB) { + auto Action = [File = File.str(), Pos, CB = std::move(CB), + this](Expected<InputsAndAST> InpAST) mutable { + if (!InpAST) + return CB(InpAST.takeError()); + CB(clangd::prepareCallHierarchy(InpAST->AST, Pos, Index, File)); + }; + WorkScheduler.runWithAST("Call Hierarchy", File, std::move(Action)); +} + +void ClangdServer::incomingCalls( + const CallHierarchyItem &Item, + Callback<llvm::Optional<std::vector<CallHierarchyIncomingCall>>> CB) { + CB(clangd::incomingCalls(Item, Index)); +} + +void ClangdServer::outgoingCalls( + const CallHierarchyItem &Item, + Callback<llvm::Optional<std::vector<CallHierarchyOutgoingCall>>> CB) { + CB(clangd::outgoingCalls(Item, Index)); +} + void ClangdServer::onFileEvent(const DidChangeWatchedFilesParams &Params) { // FIXME: Do nothing for now. This will be used for indexing and potentially // invalidating other caches.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits