diff options
| author | Kadir Cetinkaya <kadircet@google.com> | 2019-03-19 09:27:04 +0000 |
|---|---|---|
| committer | Kadir Cetinkaya <kadircet@google.com> | 2019-03-19 09:27:04 +0000 |
| commit | 8665802202689b4014bde7f5aa64f0a3c1a045f7 (patch) | |
| tree | 4d71078bd62a9c906c00b6b182c410fd2d4de8f7 /clang-tools-extra/clangd/ClangdServer.cpp | |
| parent | ad78768d5933bfa50009e8b6f84150291a8aba8f (diff) | |
| download | bcm5719-llvm-8665802202689b4014bde7f5aa64f0a3c1a045f7.tar.gz bcm5719-llvm-8665802202689b4014bde7f5aa64f0a3c1a045f7.zip | |
[clangd] Add support for type hierarchy (super types only for now)
Summary:
Patch by Nathan Ridge(@nridge)!
This is an LSP extension proposed here:
https://github.com/Microsoft/vscode-languageserver-node/pull/426
An example client implementation can be found here:
https://github.com/theia-ide/theia/pull/3802
Reviewers: kadircet, sammccall
Reviewed By: kadircet
Subscribers: jdoerfert, sammccall, cfe-commits, mgorny, dschaefer, simark, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet
Tags: #clang
Differential Revision: https://reviews.llvm.org/D56370
llvm-svn: 356445
Diffstat (limited to 'clang-tools-extra/clangd/ClangdServer.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/ClangdServer.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp index 9dc332806de..a265f3722ec 100644 --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -362,9 +362,8 @@ void ClangdServer::enumerateTweaks(PathRef File, Range Sel, void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID, Callback<tooling::Replacements> CB) { - auto Action = [Sel](decltype(CB) CB, std::string File, - std::string TweakID, - Expected<InputsAndAST> InpAST) { + auto Action = [Sel](decltype(CB) CB, std::string File, std::string TweakID, + Expected<InputsAndAST> InpAST) { if (!InpAST) return CB(InpAST.takeError()); auto Selection = tweakSelection(Sel, *InpAST); @@ -523,6 +522,19 @@ void ClangdServer::findHover(PathRef File, Position Pos, WorkScheduler.runWithAST("Hover", File, Bind(Action, std::move(CB))); } +void ClangdServer::typeHierarchy(PathRef File, Position Pos, int Resolve, + TypeHierarchyDirection Direction, + Callback<Optional<TypeHierarchyItem>> CB) { + auto Action = [Pos, Resolve, Direction](decltype(CB) CB, + Expected<InputsAndAST> InpAST) { + if (!InpAST) + return CB(InpAST.takeError()); + CB(clangd::getTypeHierarchy(InpAST->AST, Pos, Resolve, Direction)); + }; + + WorkScheduler.runWithAST("Type Hierarchy", File, Bind(Action, std::move(CB))); +} + tooling::CompileCommand ClangdServer::getCompileCommand(PathRef File) { trace::Span Span("GetCompileCommand"); llvm::Optional<tooling::CompileCommand> C = CDB.getCompileCommand(File); |

