|
4 | 4 | racket/list |
5 | 5 | racket/bool |
6 | 6 | racket/contract |
7 | | - "error-codes.rkt" |
8 | 7 | "../common/interfaces.rkt" |
9 | 8 | "../common/json-util.rkt" |
10 | 9 | "responses.rkt" |
|
80 | 79 | (doc-hover doc pos)))) |
81 | 80 | (success/enc id result)] |
82 | 81 | [_ |
83 | | - (error-response id INVALID-PARAMS "textDocument/hover failed")])) |
| 82 | + (error-response id ErrorCode-InvalidParams "textDocument/hover failed")])) |
84 | 83 |
|
85 | 84 | ;; Code Action request |
86 | 85 | (define (code-action id params) |
|
100 | 99 | (doc-code-action doc range)))) |
101 | 100 | (success/enc id actions)] |
102 | 101 | [(hash-table ['textDocument (DocIdentifier-js #:uri uri)]) |
103 | | - (error-response id INVALID-PARAMS |
| 102 | + (error-response id ErrorCode-InvalidParams |
104 | 103 | (format "textDocument/codeAction failed uri is not a path ~a" uri))] |
105 | | - [_ (error-response id INVALID-PARAMS "textDocument/codeAction failed")])) |
| 104 | + [_ (error-response id ErrorCode-InvalidParams "textDocument/codeAction failed")])) |
106 | 105 |
|
107 | 106 | ;; Signature Help request |
108 | 107 | (define (signatureHelp id params) |
|
116 | 115 | (doc-signature-help doc pos)))) |
117 | 116 | (success/enc id result)] |
118 | 117 | [_ |
119 | | - (error-response id INVALID-PARAMS "textDocument/signatureHelp failed")])) |
| 118 | + (error-response id ErrorCode-InvalidParams "textDocument/signatureHelp failed")])) |
120 | 119 |
|
121 | 120 | ;; Completion Request |
122 | 121 | (define (completion id params) |
|
129 | 128 | (λ (doc) (doc-completion doc pos)))) |
130 | 129 | (success/enc id result)] |
131 | 130 | [_ |
132 | | - (error-response id INVALID-PARAMS "textDocument/completion failed")])) |
| 131 | + (error-response id ErrorCode-InvalidParams "textDocument/completion failed")])) |
133 | 132 |
|
134 | 133 | ;; Definition request |
135 | 134 |
|
|
143 | 142 | (λ (doc) (doc-definition doc uri pos)))) |
144 | 143 | (success/enc id result)] |
145 | 144 | [_ |
146 | | - (error-response id INVALID-PARAMS "textDocument/definition failed")])) |
| 145 | + (error-response id ErrorCode-InvalidParams "textDocument/definition failed")])) |
147 | 146 |
|
148 | 147 | ;; Reference request |
149 | 148 | (define (references id params) |
|
157 | 156 | (λ (doc) (doc-references doc uri pos include-decl?)))) |
158 | 157 | (success/enc id result)] |
159 | 158 | [_ |
160 | | - (error-response id INVALID-PARAMS "textDocument/references failed")])) |
| 159 | + (error-response id ErrorCode-InvalidParams "textDocument/references failed")])) |
161 | 160 |
|
162 | 161 | ;; Document Highlight request |
163 | 162 | (define (document-highlight id params) |
|
170 | 169 | (λ (doc) (doc-highlights doc pos)))) |
171 | 170 | (success/enc id result)] |
172 | 171 | [_ |
173 | | - (error-response id INVALID-PARAMS "textDocument/documentHighlight failed")])) |
| 172 | + (error-response id ErrorCode-InvalidParams "textDocument/documentHighlight failed")])) |
174 | 173 |
|
175 | 174 | ;; Rename request |
176 | 175 | (define (_rename id params) |
|
184 | 183 | (λ (doc) (doc-rename doc uri pos new-name)))) |
185 | 184 | (success/enc id result)] |
186 | 185 | [_ |
187 | | - (error-response id INVALID-PARAMS "textDocument/rename failed")])) |
| 186 | + (error-response id ErrorCode-InvalidParams "textDocument/rename failed")])) |
188 | 187 |
|
189 | 188 | ;; Prepare rename |
190 | 189 | (define (prepareRename id params) |
|
197 | 196 | (λ (doc) (doc-prepare-rename doc pos)))) |
198 | 197 | (success/enc id result)] |
199 | 198 | [_ |
200 | | - (error-response id INVALID-PARAMS "textDocument/prepareRename failed")])) |
| 199 | + (error-response id ErrorCode-InvalidParams "textDocument/prepareRename failed")])) |
201 | 200 |
|
202 | 201 | ;; Document Symbol request |
203 | 202 | (define (document-symbol id params) |
|
209 | 208 | (λ (doc) (doc-symbols doc uri)))) |
210 | 209 | (success/enc id results)] |
211 | 210 | [_ |
212 | | - (error-response id INVALID-PARAMS "textDocument/documentSymbol failed")])) |
| 211 | + (error-response id ErrorCode-InvalidParams "textDocument/documentSymbol failed")])) |
213 | 212 |
|
214 | 213 | ;; Inlay Hint |
215 | 214 | (define (inlay-hint id params) |
216 | 215 | (match params |
217 | 216 | [(hash-table ['textDocument (DocIdentifier-js #:uri uri)] |
218 | 217 | ['range (^Range _ _)]) |
219 | 218 | (success/enc id '())] |
220 | | - [_ (error-response id INVALID-PARAMS "textDocument/inlayHint failed")])) |
| 219 | + [_ (error-response id ErrorCode-InvalidParams "textDocument/inlayHint failed")])) |
221 | 220 |
|
222 | 221 | ;; Full document formatting request |
223 | 222 | (define (formatting! id params) |
|
236 | 235 | (Range start end) |
237 | 236 | #:formatting-options opts))))] |
238 | 237 | [_ |
239 | | - (error-response id INVALID-PARAMS "textDocument/formatting failed")])) |
| 238 | + (error-response id ErrorCode-InvalidParams "textDocument/formatting failed")])) |
240 | 239 |
|
241 | 240 | ;; Range Formatting request |
242 | 241 | (define (range-formatting! id params) |
|
251 | 250 | id |
252 | 251 | (doc-format-edits doc range #:formatting-options opts))))] |
253 | 252 | [_ |
254 | | - (error-response id INVALID-PARAMS "textDocument/rangeFormatting failed")])) |
| 253 | + (error-response id ErrorCode-InvalidParams "textDocument/rangeFormatting failed")])) |
255 | 254 |
|
256 | 255 | ;; On-type formatting request |
257 | 256 | (define (on-type-formatting! id params) |
|
287 | 286 | #:on-type? #t |
288 | 287 | #:formatting-options opts))))] |
289 | 288 | [_ |
290 | | - (error-response id INVALID-PARAMS "textDocument/onTypeFormatting failed")])) |
| 289 | + (error-response id ErrorCode-InvalidParams "textDocument/onTypeFormatting failed")])) |
291 | 290 |
|
292 | 291 | (define (full-semantic-tokens id params) |
293 | 292 | (match params |
|
299 | 298 | (Range (doc-abs-pos->pos doc 0) |
300 | 299 | (doc-abs-pos->pos doc (doc-end-abs-pos doc)))))) |
301 | 300 | (semantic-tokens uri id safe-doc full-range)] |
302 | | - [_ (error-response id INVALID-PARAMS "textDocument/semanticTokens/full failed")])) |
| 301 | + [_ (error-response id ErrorCode-InvalidParams "textDocument/semanticTokens/full failed")])) |
303 | 302 |
|
304 | 303 | (define (range-semantic-tokens id params) |
305 | 304 | (match params |
306 | 305 | [(hash-table ['textDocument (DocIdentifier-js #:uri uri)] |
307 | 306 | ['range (as-Range range)]) |
308 | 307 | (define safe-doc (lsp-get-doc uri)) |
309 | 308 | (semantic-tokens uri id safe-doc range)] |
310 | | - [_ (error-response id INVALID-PARAMS "textDocument/semanticTokens/range failed")])) |
| 309 | + [_ (error-response id ErrorCode-InvalidParams "textDocument/semanticTokens/range failed")])) |
311 | 310 |
|
312 | 311 | (define (semantic-tokens uri id safe-doc range) |
313 | 312 | (define tokens |
|
0 commit comments