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"}}
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 }"}}}
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}}}}
8 # CHECK-NEXT: "jsonrpc": "2.0",
9 # CHECK-NEXT: "result": [
11 # CHECK-NEXT: "newText": "\n ",
12 # CHECK-NEXT: "range": {
13 # CHECK-NEXT: "end": {
14 # CHECK-NEXT: "character": 4,
15 # CHECK-NEXT: "line": 1
17 # CHECK-NEXT: "start": {
18 # CHECK-NEXT: "character": 19,
19 # CHECK-NEXT: "line": 0
24 # CHECK-NEXT: "newText": " ",
25 # CHECK-NEXT: "range": {
26 # CHECK-NEXT: "end": {
27 # CHECK-NEXT: "character": 9,
28 # CHECK-NEXT: "line": 1
30 # CHECK-NEXT: "start": {
31 # CHECK-NEXT: "character": 9,
32 # CHECK-NEXT: "line": 1
37 # CHECK-NEXT: "newText": " ",
38 # CHECK-NEXT: "range": {
39 # CHECK-NEXT: "end": {
40 # CHECK-NEXT: "character": 10,
41 # CHECK-NEXT: "line": 1
43 # CHECK-NEXT: "start": {
44 # CHECK-NEXT: "character": 10,
45 # CHECK-NEXT: "line": 1
50 # CHECK-NEXT: "newText": "\n ",
51 # CHECK-NEXT: "range": {
52 # CHECK-NEXT: "end": {
53 # CHECK-NEXT: "character": 4,
54 # CHECK-NEXT: "line": 2
56 # CHECK-NEXT: "start": {
57 # CHECK-NEXT: "character": 12,
58 # CHECK-NEXT: "line": 1
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 }"}]}}
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}}}}
70 # CHECK-NEXT: "jsonrpc": "2.0",
71 # CHECK-NEXT: "result": []
73 {"jsonrpc":"2.0","id":3,"method":"textDocument/formatting","params":{"textDocument":{"uri":"test:///foo.c"}}}
75 # CHECK-NEXT: "jsonrpc": "2.0",
76 # CHECK-NEXT: "result": [
78 # CHECK-NEXT: "newText": "",
79 # CHECK-NEXT: "range": {
80 # CHECK-NEXT: "end": {
81 # CHECK-NEXT: "character": 8,
82 # CHECK-NEXT: "line": 0
84 # CHECK-NEXT: "start": {
85 # CHECK-NEXT: "character": 7,
86 # CHECK-NEXT: "line": 0
91 # CHECK-NEXT: "newText": "",
92 # CHECK-NEXT: "range": {
93 # CHECK-NEXT: "end": {
94 # CHECK-NEXT: "character": 10,
95 # CHECK-NEXT: "line": 0
97 # CHECK-NEXT: "start": {
98 # CHECK-NEXT: "character": 9,
99 # CHECK-NEXT: "line": 0
104 # CHECK-NEXT: "newText": "",
105 # CHECK-NEXT: "range": {
106 # CHECK-NEXT: "end": {
107 # CHECK-NEXT: "character": 16,
108 # CHECK-NEXT: "line": 0
110 # CHECK-NEXT: "start": {
111 # CHECK-NEXT: "character": 15,
112 # CHECK-NEXT: "line": 0
117 # CHECK-NEXT: "newText": "\n",
118 # CHECK-NEXT: "range": {
119 # CHECK-NEXT: "end": {
120 # CHECK-NEXT: "character": 4,
121 # CHECK-NEXT: "line": 3
123 # CHECK-NEXT: "start": {
124 # CHECK-NEXT: "character": 11,
125 # CHECK-NEXT: "line": 2
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}"}]}}
133 {"jsonrpc":"2.0","id":4,"method":"textDocument/formatting","params":{"textDocument":{"uri":"test:///foo.c"}}}
135 # CHECK-NEXT: "jsonrpc": "2.0",
136 # CHECK-NEXT: "result": []
138 {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"test:///foo.c","version":5},"contentChanges":[{"text":"int x=\n"}]}}
140 {"jsonrpc":"2.0","id":5,"method":"textDocument/onTypeFormatting","params":{"textDocument":{"uri":"test:///foo.c"},"position":{"line":1,"character":0},"ch":"\n"}}
142 # CHECK-NEXT: "jsonrpc": "2.0",
143 # CHECK-NEXT: "result": [
145 # CHECK-NEXT: "newText": " ",
146 # CHECK-NEXT: "range": {
147 # CHECK-NEXT: "end": {
148 # CHECK-NEXT: "character": 5,
149 # CHECK-NEXT: "line": 0
151 # CHECK-NEXT: "start": {
152 # CHECK-NEXT: "character": 5,
153 # CHECK-NEXT: "line": 0
158 # CHECK-NEXT: "newText": "\n ",
159 # CHECK-NEXT: "range": {
160 # CHECK-NEXT: "end": {
161 # CHECK-NEXT: "character": 0,
162 # CHECK-NEXT: "line": 1
164 # CHECK-NEXT: "start": {
165 # CHECK-NEXT: "character": 6,
166 # CHECK-NEXT: "line": 0
172 {"jsonrpc":"2.0","id":6,"method":"shutdown"}
174 {"jsonrpc":"2.0","method":"exit"}