[clang-tools-extra] Fix a link in ReleaseNotes.rst
[llvm-project.git] / clang-tools-extra / clangd / test / symbols.test
blobaf5d74123630e2612f949bad984f38ce5d1722eb
1 # RUN: clangd --index-file=%S/Inputs/symbols.test.yaml -lit-test < %s | FileCheck %s
2 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument":{"documentSymbol":{"hierarchicalDocumentSymbolSupport":true}},"workspace":{"symbol":{"symbolKind":{"valueSet": [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}}}},"trace":"off"}}
3 ---
4 {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"void foo(); int main() { foo(); }\n"}}}
5 ---
6 {"jsonrpc":"2.0","id":1,"method":"workspace/symbol","params":{"query":"vector"}}
7 #      CHECK:  "id": 1,
8 # CHECK-NEXT:  "jsonrpc": "2.0",
9 # CHECK-NEXT:    "result": [
10 # CHECK-NEXT:      {
11 # CHECK-NEXT:        "containerName": "std",
12 # CHECK-NEXT:        "kind": 5,
13 # CHECK-NEXT:        "location": {
14 # CHECK-NEXT:          "range": {
15 # CHECK-NEXT:            "end": {
16 # CHECK-NEXT:              "character": {{.*}},
17 # CHECK-NEXT:              "line": {{.*}}
18 # CHECK-NEXT:            },
19 # CHECK-NEXT:            "start": {
20 # CHECK-NEXT:              "character": {{.*}},
21 # CHECK-NEXT:              "line": {{.*}}
22 # CHECK-NEXT:            }
23 # CHECK-NEXT:          },
24 # CHECK-NEXT:          "uri": "file://{{.*}}/vector.h"
25 # CHECK-NEXT:        },
26 # CHECK-NEXT:        "name": "vector",
27 # CHECK-NEXT:        "score": {{.*}}
28 # CHECK-NEXT:      }
29 # CHECK-NEXT:    ]
30 # CHECK-NEXT:}
31 ---
32 {"jsonrpc":"2.0","id":2,"method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"test:///main.cpp"}}}
33 #      CHECK:  "id": 2,
34 # CHECK-NEXT:  "jsonrpc": "2.0",
35 # CHECK-NEXT:    "result": [
36 # CHECK-NEXT:      {
37 # CHECK-NEXT:        "detail": "void ()",
38 # CHECK-NEXT:        "kind": 12,
39 # CHECK-NEXT:        "name": "foo",
40 # CHECK-NEXT:        "range": {
41 # CHECK-NEXT:          "end": {
42 # CHECK-NEXT:            "character": {{.*}},
43 # CHECK-NEXT:            "line": {{.*}}
44 # CHECK-NEXT:          },
45 # CHECK-NEXT:          "start": {
46 # CHECK-NEXT:            "character": {{.*}},
47 # CHECK-NEXT:            "line": {{.*}}
48 # CHECK-NEXT:          }
49 # CHECK-NEXT:        },
50 # CHECK-NEXT:        "selectionRange": {
51 # CHECK-NEXT:          "end": {
52 # CHECK-NEXT:            "character": {{.*}},
53 # CHECK-NEXT:            "line": {{.*}}
54 # CHECK-NEXT:          },
55 # CHECK-NEXT:          "start": {
56 # CHECK-NEXT:            "character": {{.*}},
57 # CHECK-NEXT:            "line": {{.*}}
58 # CHECK-NEXT:          }
59 # CHECK-NEXT:        }
60 # CHECK-NEXT:      },
61 # CHECK-NEXT:      {
62 # CHECK-NEXT:        "detail": "int ()",
63 # CHECK-NEXT:        "kind": 12,
64 # CHECK-NEXT:        "name": "main",
65 # CHECK-NEXT:        "range": {
66 # CHECK-NEXT:          "end": {
67 # CHECK-NEXT:            "character": {{.*}},
68 # CHECK-NEXT:            "line": {{.*}}
69 # CHECK-NEXT:          },
70 # CHECK-NEXT:          "start": {
71 # CHECK-NEXT:            "character": {{.*}},
72 # CHECK-NEXT:            "line": {{.*}}
73 # CHECK-NEXT:          }
74 # CHECK-NEXT:        },
75 # CHECK-NEXT:        "selectionRange": {
76 # CHECK-NEXT:          "end": {
77 # CHECK-NEXT:            "character": {{.*}},
78 # CHECK-NEXT:            "line": {{.*}}
79 # CHECK-NEXT:          },
80 # CHECK-NEXT:          "start": {
81 # CHECK-NEXT:            "character": {{.*}},
82 # CHECK-NEXT:            "line": {{.*}}
83 # CHECK-NEXT:          }
84 # CHECK-NEXT:        }
85 # CHECK-NEXT:      }
86 # CHECK-NEXT:    ]
87 # CHECK-NEXT:}
88 ---
89 {"jsonrpc":"2.0","id":3,"method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"test:///foo.cpp"}}}
90 #      CHECK:  "error": {
91 # CHECK-NEXT:    "code": -32602,
92 # CHECK-NEXT:    "message": "trying to get AST for non-added document"
93 # CHECK-NEXT:  },
94 # CHECK-NEXT:  "id": 3,
95 # CHECK-NEXT:  "jsonrpc": "2.0"
96 ---
97 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
98 ---
99 {"jsonrpc":"2.0","method":"exit"}