1# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
2{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
3---
4{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"int foo ( int x ) {\n    x = x+1;\n    return x;\n    }"}}}
5---
6{"jsonrpc":"2.0","id":1,"method":"textDocument/rangeFormatting","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":1,"character":4},"end":{"line":1,"character":12}}}}
7#      CHECK:   "id": 1,
8# CHECK-NEXT:  "jsonrpc": "2.0",
9# CHECK-NEXT:  "result": [
10# CHECK-NEXT:    {
11# CHECK-NEXT:      "newText": "\n  ",
12# CHECK-NEXT:      "range": {
13# CHECK-NEXT:        "end": {
14# CHECK-NEXT:          "character": 4,
15# CHECK-NEXT:          "line": 1
16# CHECK-NEXT:        },
17# CHECK-NEXT:        "start": {
18# CHECK-NEXT:          "character": 19,
19# CHECK-NEXT:          "line": 0
20# CHECK-NEXT:        }
21# CHECK-NEXT:      }
22# CHECK-NEXT:    },
23# CHECK-NEXT:    {
24# CHECK-NEXT:      "newText": " ",
25# CHECK-NEXT:      "range": {
26# CHECK-NEXT:        "end": {
27# CHECK-NEXT:          "character": 9,
28# CHECK-NEXT:          "line": 1
29# CHECK-NEXT:        },
30# CHECK-NEXT:        "start": {
31# CHECK-NEXT:          "character": 9,
32# CHECK-NEXT:          "line": 1
33# CHECK-NEXT:        }
34# CHECK-NEXT:      }
35# CHECK-NEXT:    },
36# CHECK-NEXT:    {
37# CHECK-NEXT:      "newText": " ",
38# CHECK-NEXT:      "range": {
39# CHECK-NEXT:        "end": {
40# CHECK-NEXT:          "character": 10,
41# CHECK-NEXT:          "line": 1
42# CHECK-NEXT:        },
43# CHECK-NEXT:        "start": {
44# CHECK-NEXT:          "character": 10,
45# CHECK-NEXT:          "line": 1
46# CHECK-NEXT:        }
47# CHECK-NEXT:      }
48# CHECK-NEXT:    },
49# CHECK-NEXT:    {
50# CHECK-NEXT:      "newText": "\n  ",
51# CHECK-NEXT:      "range": {
52# CHECK-NEXT:        "end": {
53# CHECK-NEXT:          "character": 4,
54# CHECK-NEXT:          "line": 2
55# CHECK-NEXT:        },
56# CHECK-NEXT:        "start": {
57# CHECK-NEXT:          "character": 12,
58# CHECK-NEXT:          "line": 1
59# CHECK-NEXT:        }
60# CHECK-NEXT:      }
61# CHECK-NEXT:    }
62# CHECK-NEXT:  ]
63---
64{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///foo.c","version":5},"contentChanges":[{"text":"int foo ( int x ) {\n  x = x + 1;\n  return x;\n    }"}]}}
65#
66#
67---
68{"jsonrpc":"2.0","id":2,"method":"textDocument/rangeFormatting","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":1,"character":2},"end":{"line":1,"character":12}}}}
69#      CHECK:  "id": 2,
70# CHECK-NEXT:  "jsonrpc": "2.0",
71# CHECK-NEXT:  "result": []
72---
73{"jsonrpc":"2.0","id":3,"method":"textDocument/formatting","params":{"textDocument":{"uri":"test:///foo.c"}}}
74#      CHECK:  "id": 3,
75# CHECK-NEXT:  "jsonrpc": "2.0",
76# CHECK-NEXT:  "result": [
77# CHECK-NEXT:    {
78# CHECK-NEXT:      "newText": "",
79# CHECK-NEXT:      "range": {
80# CHECK-NEXT:        "end": {
81# CHECK-NEXT:          "character": 8,
82# CHECK-NEXT:          "line": 0
83# CHECK-NEXT:        },
84# CHECK-NEXT:        "start": {
85# CHECK-NEXT:          "character": 7,
86# CHECK-NEXT:          "line": 0
87# CHECK-NEXT:        }
88# CHECK-NEXT:      }
89# CHECK-NEXT:    },
90# CHECK-NEXT:    {
91# CHECK-NEXT:      "newText": "",
92# CHECK-NEXT:      "range": {
93# CHECK-NEXT:        "end": {
94# CHECK-NEXT:          "character": 10,
95# CHECK-NEXT:          "line": 0
96# CHECK-NEXT:        },
97# CHECK-NEXT:        "start": {
98# CHECK-NEXT:          "character": 9,
99# CHECK-NEXT:          "line": 0
100# CHECK-NEXT:        }
101# CHECK-NEXT:      }
102# CHECK-NEXT:    },
103# CHECK-NEXT:    {
104# CHECK-NEXT:      "newText": "",
105# CHECK-NEXT:      "range": {
106# CHECK-NEXT:        "end": {
107# CHECK-NEXT:          "character": 16,
108# CHECK-NEXT:          "line": 0
109# CHECK-NEXT:        },
110# CHECK-NEXT:        "start": {
111# CHECK-NEXT:          "character": 15,
112# CHECK-NEXT:          "line": 0
113# CHECK-NEXT:        }
114# CHECK-NEXT:      }
115# CHECK-NEXT:    },
116# CHECK-NEXT:    {
117# CHECK-NEXT:      "newText": "\n",
118# CHECK-NEXT:      "range": {
119# CHECK-NEXT:        "end": {
120# CHECK-NEXT:          "character": 4,
121# CHECK-NEXT:          "line": 3
122# CHECK-NEXT:        },
123# CHECK-NEXT:        "start": {
124# CHECK-NEXT:          "character": 11,
125# CHECK-NEXT:          "line": 2
126# CHECK-NEXT:        }
127# CHECK-NEXT:      }
128# CHECK-NEXT:    }
129# CHECK-NEXT:  ]
130---
131{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///foo.c","version":9},"contentChanges":[{"text":"int foo(int x) {\n  x = x + 1;\n  return x;\n}"}]}}
132---
133{"jsonrpc":"2.0","id":4,"method":"textDocument/formatting","params":{"textDocument":{"uri":"test:///foo.c"}}}
134#      CHECK:  "id": 4,
135# CHECK-NEXT:  "jsonrpc": "2.0",
136# CHECK-NEXT:  "result": []
137---
138{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///foo.c","version":5},"contentChanges":[{"text":"int x=\n"}]}}
139---
140{"jsonrpc":"2.0","id":5,"method":"textDocument/onTypeFormatting","params":{"textDocument":{"uri":"test:///foo.c"},"position":{"line":1,"character":0},"ch":"\n"}}
141#      CHECK:  "id": 5,
142# CHECK-NEXT:  "jsonrpc": "2.0",
143# CHECK-NEXT:  "result": [
144# CHECK-NEXT:    {
145# CHECK-NEXT:      "newText": " ",
146# CHECK-NEXT:      "range": {
147# CHECK-NEXT:        "end": {
148# CHECK-NEXT:          "character": 5,
149# CHECK-NEXT:          "line": 0
150# CHECK-NEXT:        },
151# CHECK-NEXT:        "start": {
152# CHECK-NEXT:          "character": 5,
153# CHECK-NEXT:          "line": 0
154# CHECK-NEXT:        }
155# CHECK-NEXT:      }
156# CHECK-NEXT:    },
157# CHECK-NEXT:    {
158# CHECK-NEXT:      "newText": "\n    ",
159# CHECK-NEXT:      "range": {
160# CHECK-NEXT:        "end": {
161# CHECK-NEXT:          "character": 0,
162# CHECK-NEXT:          "line": 1
163# CHECK-NEXT:        },
164# CHECK-NEXT:        "start": {
165# CHECK-NEXT:          "character": 6,
166# CHECK-NEXT:          "line": 0
167# CHECK-NEXT:        }
168# CHECK-NEXT:      }
169# CHECK-NEXT:    }
170# CHECK-NEXT:  ]
171---
172{"jsonrpc":"2.0","id":6,"method":"shutdown"}
173---
174{"jsonrpc":"2.0","method":"exit"}
175