Skip to content

Commit 3422d2b

Browse files
committed
Add test, add astSearchProvider to capabilities
1 parent 288bf22 commit 3422d2b

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,9 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
639639
{"workspaceSymbolProvider", true},
640640
{"referencesProvider", true},
641641
{"astProvider", true}, // clangd extension
642+
{"astSearchProvider",
643+
llvm::json::Object{{"search", true},
644+
{"replace", false}}}, // clangd extension
642645
{"typeHierarchyProvider", true},
643646
// Unfortunately our extension made use of the same capability name as the
644647
// standard. Advertise this capability to tell clients that implement our
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace --dump-input always %s
2+
void bob();
3+
void f() {
4+
bob();
5+
}
6+
---
7+
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument": {"foldingRange": {"lineFoldingOnly": true}}},"trace":"off"}}
8+
---
9+
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"cpp","text":"void bob();\nvoid f() {\n bob();\n}\n","uri":"test:///foo.cpp","version":1}}}
10+
---
11+
{"id":1,"jsonrpc":"2.0","method":"textDocument/searchAST","params":{"textDocument":{"uri":"test:///foo.cpp"},"query":"declRefExpr(to(namedDecl(hasName(\"bob\"))))"}}
12+
# CHECK: "id": 1,
13+
# CHECK-NEXT: "jsonrpc": "2.0",
14+
# CHECK-NEXT: "result": [
15+
# CHECK-NEXT: {
16+
# CHECK-NEXT: "root": {
17+
# CHECK-NEXT: "arcana": "DeclRefExpr {{.*}} 'void ()' lvalue Function {{.*}} 'bob' 'void ()'",
18+
# CHECK-NEXT: "detail": "bob",
19+
# CHECK-NEXT: "kind": "DeclRef",
20+
# CHECK-NEXT: "range": {
21+
# CHECK-NEXT: "end": {
22+
# CHECK-NEXT: "character": 5,
23+
# CHECK-NEXT: "line": 2
24+
# CHECK-NEXT: },
25+
# CHECK-NEXT: "start": {
26+
# CHECK-NEXT: "character": 2,
27+
# CHECK-NEXT: "line": 2
28+
# CHECK-NEXT: }
29+
# CHECK-NEXT: },
30+
# CHECK-NEXT: "role": "expression"
31+
# CHECK-NEXT: }
32+
# CHECK-NEXT: }
33+
# CHECK-NEXT: ]
34+
---
35+
{"jsonrpc":"2.0","id":5,"method":"shutdown"}
36+
---
37+
{"jsonrpc":"2.0","method":"exit"}

clang-tools-extra/clangd/test/initialize-params.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
# CHECK-NEXT: "result": {
77
# CHECK-NEXT: "capabilities": {
88
# CHECK-NEXT: "astProvider": true,
9+
# CHECK-NEXT: "astSearchProvider": {
10+
# CHECK-NEXT: "replace": false,
11+
# CHECK-NEXT: "search": true
12+
# CHECK-NEXT: },
913
# CHECK-NEXT: "callHierarchyProvider": true,
1014
# CHECK-NEXT: "clangdInlayHintsProvider": true,
1115
# CHECK-NEXT: "codeActionProvider": true,

0 commit comments

Comments
 (0)