1# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
2{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument": {"rename": {"dynamicRegistration": true, "prepareSupport": true}}},"trace":"off"}}
3# CHECK:      "renameProvider": {
4# CHECK-NEXT:    "prepareProvider": true
5# CHECK-NEXT: },
6---
7{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.cpp","languageId":"cpp","version":1,"text":"int foo;"}}}
8---
9{"jsonrpc":"2.0","id":1,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":5}}}
10#      CHECK:  "id": 1,
11# CHECK-NEXT:  "jsonrpc": "2.0",
12# CHECK-NEXT:  "result": {
13# CHECK-NEXT:      "end": {
14# CHECK-NEXT:        "character": 7,
15# CHECK-NEXT:        "line": 0
16# CHECK-NEXT:      },
17# CHECK-NEXT:      "start": {
18# CHECK-NEXT:        "character": 4,
19# CHECK-NEXT:        "line": 0
20# CHECK-NEXT:      }
21# CHECK-NEXT:  }
22---
23{"jsonrpc":"2.0","id":2,"method":"textDocument/prepareRename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2}}}
24#      CHECK:  "error": {
25# CHECK-NEXT:    "code": -32001,
26# CHECK-NEXT:    "message": "Cannot rename symbol: there is no symbol at the given location"
27# CHECK-NEXT:  },
28# CHECK-NEXT:  "id": 2,
29# CHECK-NEXT:  "jsonrpc": "2.0"
30---
31{"jsonrpc":"2.0","id":4,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":2},"newName":"bar"}}
32#      CHECK:  "error": {
33# CHECK-NEXT:    "code": -32001,
34# CHECK-NEXT:    "message": "Cannot rename symbol: there is no symbol at the given location"
35# CHECK-NEXT:  },
36# CHECK-NEXT:  "id": 4,
37# CHECK-NEXT:  "jsonrpc": "2.0"
38---
39{"jsonrpc":"2.0","id":3,"method":"textDocument/rename","params":{"textDocument":{"uri":"test:///foo.cpp"},"position":{"line":0,"character":5},"newName":"bar"}}
40#      CHECK:  "id": 3,
41# CHECK-NEXT:  "jsonrpc": "2.0",
42# CHECK-NEXT:  "result": {
43# CHECK-NEXT:    "changes": {
44# CHECK-NEXT:      "file://{{.*}}/foo.cpp": [
45# CHECK-NEXT:        {
46# CHECK-NEXT:          "newText": "bar",
47# CHECK-NEXT:          "range": {
48# CHECK-NEXT:            "end": {
49# CHECK-NEXT:              "character": 7
50# CHECK-NEXT:              "line": 0
51# CHECK-NEXT:            },
52# CHECK-NEXT:            "start": {
53# CHECK-NEXT:              "character": 4
54# CHECK-NEXT:              "line": 0
55# CHECK-NEXT:            }
56# CHECK-NEXT:          }
57# CHECK-NEXT:        }
58# CHECK-NEXT:      ]
59# CHECK-NEXT:    }
60# CHECK-NEXT:  }
61---
62{"jsonrpc":"2.0","id":5,"method":"shutdown"}
63---
64{"jsonrpc":"2.0","method":"exit"}
65