Debian Codegraph @

clang-tools-extra/clangd/test/path-mappings.test

raw
1 # Copy over the server file into test workspace
2 # RUN: rm -rf %t
3 # RUN: cp -r %S/Inputs/path-mappings %t
4 #
5 # RUN: clangd --path-mappings 'C:\client=%t/server' -lit-test < %s | FileCheck -strict-whitespace %s
6 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
7 ---
8 {
9 "jsonrpc": "2.0",
10 "method": "textDocument/didOpen",
11 "params": {
12 "textDocument": {
13 "uri": "file:///C:/client/bar.cpp",
14 "languageId": "cpp",
15 "text": "#include \"foo.h\"\nint main(){\nreturn foo();\n}"
16 }
17 }
18 }
19 # Ensure that the client gets back the same client path (clangd thinks it edited %t/server/bar.cpp)
20 # CHECK: "method": "textDocument/publishDiagnostics",
21 # CHECK-NEXT: "params": {
22 # CHECK-NEXT: "diagnostics": [],
23 # CHECK-NEXT: "uri": "file:///C:/client/bar.cpp",
24 # CHECK-NEXT: "version": 0
25 # CHECK-NEXT: }
26 ---
27 # We're editing bar.cpp, which includes foo.h, where foo.h "exists" at a server location
28 # With path mappings, when we go to definition on foo(), we get back a client file uri
29 {
30 "jsonrpc": "2.0",
31 "id": 1,
32 "method": "textDocument/definition",
33 "params": {
34 "textDocument": {
35 "uri": "file:///C:/client/bar.cpp"
36 },
37 "position": {
38 "line": 2,
39 "character": 8
40 }
41 }
42 }
43 # CHECK: "id": 1,
44 # CHECK-NEXT: "jsonrpc": "2.0",
45 # CHECK-NEXT: "result": [
46 # CHECK-NEXT: {
47 # CHECK-NEXT: "range": {
48 # CHECK-NEXT: "end": {
49 # CHECK-NEXT: "character": {{[0-9]+}},
50 # CHECK-NEXT: "line": {{[0-9]+}}
51 # CHECK-NEXT: },
52 # CHECK-NEXT: "start": {
53 # CHECK-NEXT: "character": {{[0-9]+}},
54 # CHECK-NEXT: "line": {{[0-9]+}}
55 # CHECK-NEXT: }
56 # CHECK-NEXT: },
57 # CHECK-NEXT: "uri": "file:///C:/client/foo.h"
58 # CHECK-NEXT: }
59 # CHECK-NEXT: ]
60 #
61 ---
62 {"jsonrpc":"2.0","id":2,"method":"shutdown"}
63 ---
64 {"jsonrpc":"2.0","method":"exit"}