diff options
| author | Marc-Andre Laperle <marc-andre.laperle@ericsson.com> | 2018-02-16 21:38:15 +0000 |
|---|---|---|
| committer | Marc-Andre Laperle <marc-andre.laperle@ericsson.com> | 2018-02-16 21:38:15 +0000 |
| commit | 3e618ed8f0cead7afa8f5d48e2fd2f707b5740d2 (patch) | |
| tree | 50e907d80bfb82faf362c44165af34e254ebadb8 /clang-tools-extra/clangd/Protocol.h | |
| parent | 27b9ac2372e5340fe92196f47cb31ed72d367aa4 (diff) | |
| download | bcm5719-llvm-3e618ed8f0cead7afa8f5d48e2fd2f707b5740d2.tar.gz bcm5719-llvm-3e618ed8f0cead7afa8f5d48e2fd2f707b5740d2.zip | |
[clangd] Implement textDocument/hover
Summary: Implemention of textDocument/hover as described in LSP definition.
This patch adds a basic Hover implementation. When hovering a variable,
function, method or namespace, clangd will return a text containing the
declaration's scope, as well as the declaration of the hovered entity.
For example, for a variable:
Declared in class Foo::Bar
int hello = 2
For macros, the macro definition is returned.
This patch doesn't include:
- markdown support (the client I use doesn't support it yet)
- range support (optional in the Hover response)
- comments associated to variables/functions/classes
They are kept as future work to keep this patch simpler.
I added tests in XRefsTests.cpp. hover.test contains one simple
smoketest to make sure the feature works from a black box perspective.
Reviewers: malaperle, krasimir, bkramer, ilya-biryukov
Subscribers: sammccall, mgrang, klimek, rwols, ilya-biryukov, arphaman, cfe-commits
Differential Revision: https://reviews.llvm.org/D35894
Signed-off-by: Simon Marchi <simon.marchi@ericsson.com>
Signed-off-by: William Enright <william.enright@polymtl.ca>
llvm-svn: 325395
Diffstat (limited to 'clang-tools-extra/clangd/Protocol.h')
| -rw-r--r-- | clang-tools-extra/clangd/Protocol.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h index 3007dc368a4..bdbbf62f7ab 100644 --- a/clang-tools-extra/clangd/Protocol.h +++ b/clang-tools-extra/clangd/Protocol.h @@ -480,6 +480,27 @@ struct TextDocumentPositionParams { }; bool fromJSON(const json::Expr &, TextDocumentPositionParams &); +enum class MarkupKind { + PlainText, + Markdown, +}; + +struct MarkupContent { + MarkupKind Kind = MarkupKind::PlainText; + std::string Value; +}; +json::Expr toJSON(const MarkupContent &MC); + +struct Hover { + /// The hover's content + MarkupContent Contents; + + /// An optional range is a range inside a text document + /// that is used to visualize a hover, e.g. by changing the background color. + llvm::Optional<Range> Range; +}; +json::Expr toJSON(const Hover &H); + /// The kind of a completion entry. enum class CompletionItemKind { Missing = 0, |

