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:///main.cpp","languageId":"cpp","version":1,"text":"extern int x;\nint x = 0;\nint y = x;"}}} 5--- 6{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":2,"character":8}}} 7# CHECK: "id": 1, 8# CHECK-NEXT: "jsonrpc": "2.0", 9# CHECK-NEXT: "result": [ 10# CHECK-NEXT: { 11# CHECK-NEXT: "range": { 12# CHECK-NEXT: "end": { 13# CHECK-NEXT: "character": 5, 14# CHECK-NEXT: "line": 1 15# CHECK-NEXT: }, 16# CHECK-NEXT: "start": { 17# CHECK-NEXT: "character": 4, 18# CHECK-NEXT: "line": 1 19# CHECK-NEXT: } 20# CHECK-NEXT: }, 21# CHECK-NEXT: "uri": "file://{{.*}}/{{([A-Z]:/)?}}main.cpp" 22# CHECK-NEXT: } 23# CHECK-NEXT: ] 24--- 25# Toggle: we're on the definition, so jump to the declaration. 26{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":1,"character":4}}} 27# CHECK: "id": 1, 28# CHECK-NEXT: "jsonrpc": "2.0", 29# CHECK-NEXT: "result": [ 30# CHECK-NEXT: { 31# CHECK-NEXT: "range": { 32# CHECK-NEXT: "end": { 33# CHECK-NEXT: "character": 12, 34# CHECK-NEXT: "line": 0 35# CHECK-NEXT: }, 36# CHECK-NEXT: "start": { 37# CHECK-NEXT: "character": 11, 38# CHECK-NEXT: "line": 0 39# CHECK-NEXT: } 40# CHECK-NEXT: }, 41# CHECK-NEXT: "uri": "file://{{.*}}/{{([A-Z]:/)?}}main.cpp" 42# CHECK-NEXT: } 43# CHECK-NEXT: ] 44--- 45{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":2,"character":8}}} 46# CHECK: "id": 1 47# CHECK-NEXT: "jsonrpc": "2.0", 48# CHECK-NEXT: "result": [ 49# CHECK-NEXT: { 50# CHECK-NEXT: "kind": 1, 51# CHECK-NEXT: "range": { 52# CHECK-NEXT: "end": { 53# CHECK-NEXT: "character": 12, 54# CHECK-NEXT: "line": 0 55# CHECK-NEXT: }, 56# CHECK-NEXT: "start": { 57# CHECK-NEXT: "character": 11, 58# CHECK-NEXT: "line": 0 59# CHECK-NEXT: } 60# CHECK-NEXT: } 61# CHECK-NEXT: }, 62# CHECK-NEXT: { 63# CHECK-NEXT: "kind": 1, 64# CHECK-NEXT: "range": { 65# CHECK-NEXT: "end": { 66# CHECK-NEXT: "character": 5, 67# CHECK-NEXT: "line": 1 68# CHECK-NEXT: }, 69# CHECK-NEXT: "start": { 70# CHECK-NEXT: "character": 4, 71# CHECK-NEXT: "line": 1 72# CHECK-NEXT: } 73# CHECK-NEXT: } 74# CHECK-NEXT: }, 75# CHECK-NEXT: { 76# CHECK-NEXT: "kind": 2, 77# CHECK-NEXT: "range": { 78# CHECK-NEXT: "end": { 79# CHECK-NEXT: "character": 9, 80# CHECK-NEXT: "line": 2 81# CHECK-NEXT: }, 82# CHECK-NEXT: "start": { 83# CHECK-NEXT: "character": 8, 84# CHECK-NEXT: "line": 2 85# CHECK-NEXT: } 86# CHECK-NEXT: } 87# CHECK-NEXT: } 88# CHECK-NEXT: ] 89--- 90{"jsonrpc":"2.0","id":10000,"method":"shutdown"} 91--- 92{"jsonrpc":"2.0","method":"exit"} 93