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/test/clangd | |
| 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/test/clangd')
| -rw-r--r-- | clang-tools-extra/test/clangd/hover.test | 19 | ||||
| -rw-r--r-- | clang-tools-extra/test/clangd/initialize-params-invalid.test | 1 | ||||
| -rw-r--r-- | clang-tools-extra/test/clangd/initialize-params.test | 1 | 
3 files changed, 21 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clangd/hover.test b/clang-tools-extra/test/clangd/hover.test new file mode 100644 index 00000000000..8ac7a9c2798 --- /dev/null +++ b/clang-tools-extra/test/clangd/hover.test @@ -0,0 +1,19 @@ +# RUN: clangd -lit-test < %s | FileCheck %s
 +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 +---
 +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"void foo(); int main() { foo(); }\n"}}}
 +---
 +{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":0,"character":27}}}
 +#      CHECK:  "id": 1,
 +# CHECK-NEXT:  "jsonrpc": "2.0",
 +# CHECK-NEXT:  "result": {
 +# CHECK-NEXT:    "contents": {
 +# CHECK-NEXT:      "kind": "plaintext",
 +# CHECK-NEXT:      "value": "Declared in global namespace\n\nvoid foo()"
 +# CHECK-NEXT:    }
 +# CHECK-NEXT:  }
 +# CHECK-NEXT:}
 +---
 +{"jsonrpc":"2.0","id":3,"method":"shutdown"}
 +---
 +{"jsonrpc":"2.0","method":"exit"}
 diff --git a/clang-tools-extra/test/clangd/initialize-params-invalid.test b/clang-tools-extra/test/clangd/initialize-params-invalid.test index 1c8d4f0a015..069f3efbd98 100644 --- a/clang-tools-extra/test/clangd/initialize-params-invalid.test +++ b/clang-tools-extra/test/clangd/initialize-params-invalid.test @@ -28,6 +28,7 @@  # CHECK-NEXT:          "clangd.insertInclude"  # CHECK-NEXT:        ]  # CHECK-NEXT:      }, +# CHECK-NEXT:      "hoverProvider": true,  # CHECK-NEXT:      "renameProvider": true,  # CHECK-NEXT:      "signatureHelpProvider": {  # CHECK-NEXT:        "triggerCharacters": [ diff --git a/clang-tools-extra/test/clangd/initialize-params.test b/clang-tools-extra/test/clangd/initialize-params.test index 03eadae871a..cce00ac52ad 100644 --- a/clang-tools-extra/test/clangd/initialize-params.test +++ b/clang-tools-extra/test/clangd/initialize-params.test @@ -28,6 +28,7 @@  # CHECK-NEXT:          "clangd.insertInclude"  # CHECK-NEXT:        ]  # CHECK-NEXT:      }, +# CHECK-NEXT:      "hoverProvider": true,  # CHECK-NEXT:      "renameProvider": true,  # CHECK-NEXT:      "signatureHelpProvider": {  # CHECK-NEXT:        "triggerCharacters": [  | 

