@@ -91,6 +91,8 @@ type codeAction = {
91
91
edit : codeActionEdit ;
92
92
}
93
93
94
+ let wrapInQuotes s = " \" " ^ Json. escape s ^ " \" "
95
+
94
96
let null = " null"
95
97
let array l = " [" ^ String. concat " , " l ^ " ]"
96
98
@@ -103,7 +105,8 @@ let stringifyRange r =
103
105
(stringifyPosition r.end_)
104
106
105
107
let stringifyMarkupContent (m : markupContent ) =
106
- Printf. sprintf {| {" kind" : " %s" , " value" : " %s" }| } m.kind (Json. escape m.value)
108
+ Printf. sprintf {| {" kind" : % s, " value" : % s}| } (wrapInQuotes m.kind)
109
+ (wrapInQuotes m.value)
107
110
108
111
(* * None values are not emitted in the output. *)
109
112
let stringifyObject ?(startOnNewline = false ) ?(indentation = 1 ) properties =
@@ -120,8 +123,6 @@ let stringifyObject ?(startOnNewline = false) ?(indentation = 1) properties =
120
123
|> String. concat " ,\n " )
121
124
^ " \n " ^ indentationStr ^ " }"
122
125
123
- let wrapInQuotes s = " \" " ^ Json. escape s ^ " \" "
124
-
125
126
let optWrapInQuotes s =
126
127
match s with
127
128
| None -> None
@@ -162,7 +163,7 @@ let stringifyHover value =
162
163
(stringifyMarkupContent {kind = " markdown" ; value})
163
164
164
165
let stringifyLocation (h : location ) =
165
- Printf. sprintf {| {" uri" : " %s " , " range" : % s}| } (Json. escape h.uri)
166
+ Printf. sprintf {| {" uri" : % s , " range" : % s}| } (wrapInQuotes h.uri)
166
167
(stringifyRange h.range)
167
168
168
169
let stringifyDocumentSymbolItems items =
@@ -209,27 +210,27 @@ let stringifyDocumentSymbolItems items =
209
210
let stringifyRenameFile {oldUri; newUri} =
210
211
Printf. sprintf {| {
211
212
" kind" : " rename" ,
212
- " oldUri" : " %s " ,
213
- " newUri" : " %s "
213
+ " oldUri" : % s ,
214
+ " newUri" : % s
214
215
}| }
215
- (Json. escape oldUri) (Json. escape newUri)
216
+ (wrapInQuotes oldUri) (wrapInQuotes newUri)
216
217
217
218
let stringifyTextEdit (te : textEdit ) =
218
219
Printf. sprintf {| {
219
220
" range" : % s,
220
- " newText" : " %s "
221
+ " newText" : % s
221
222
}| }
222
- (stringifyRange te.range) (Json. escape te.newText)
223
+ (stringifyRange te.range) (wrapInQuotes te.newText)
223
224
224
225
let stringifyoptionalVersionedTextDocumentIdentifier td =
225
226
Printf. sprintf {| {
226
227
" version" : % s,
227
- " uri" : " %s "
228
+ " uri" : % s
228
229
}| }
229
230
(match td.version with
230
231
| None -> null
231
232
| Some v -> string_of_int v)
232
- (Json. escape td.uri)
233
+ (wrapInQuotes td.uri)
233
234
234
235
let stringifyTextDocumentEdit tde =
235
236
Printf. sprintf {| {
@@ -276,26 +277,27 @@ let stringifyCodeActionEdit cae =
276
277
(cae.documentChanges |> List. map stringifyDocumentChange |> array )
277
278
278
279
let stringifyCodeAction ca =
279
- Printf. sprintf {| {" title" : " %s" , " kind" : " %s" , " edit" : % s}| } ca.title
280
- (codeActionKindToString ca.codeActionKind)
280
+ Printf. sprintf {| {" title" : % s, " kind" : % s, " edit" : % s}| }
281
+ (wrapInQuotes ca.title)
282
+ (wrapInQuotes (codeActionKindToString ca.codeActionKind))
281
283
(ca.edit |> stringifyCodeActionEdit)
282
284
283
285
let stringifyHint hint =
284
286
Printf. sprintf
285
287
{| {
286
288
" position" : % s,
287
- " label" : " %s " ,
289
+ " label" : % s ,
288
290
" kind" : % i,
289
291
" paddingLeft" : % b,
290
292
" paddingRight" : % b
291
293
}| }
292
294
(stringifyPosition hint.position)
293
- (Json. escape hint.label) hint.kind hint.paddingLeft hint.paddingRight
295
+ (wrapInQuotes hint.label) hint.kind hint.paddingLeft hint.paddingRight
294
296
295
297
let stringifyCommand (command : command ) =
296
- Printf. sprintf {| {" title" : " %s " , " command" : " %s " }| }
297
- (Json. escape command.title)
298
- (Json. escape command.command)
298
+ Printf. sprintf {| {" title" : % s , " command" : % s }| }
299
+ (wrapInQuotes command.title)
300
+ (wrapInQuotes command.command)
299
301
300
302
let stringifyCodeLens (codeLens : codeLens ) =
301
303
Printf. sprintf
@@ -319,10 +321,10 @@ let stringifySignatureInformation (signatureInformation : signatureInformation)
319
321
=
320
322
Printf. sprintf
321
323
{| {
322
- " label" : " %s " ,
324
+ " label" : % s ,
323
325
" parameters" : % s% s
324
326
}| }
325
- (Json. escape signatureInformation.label)
327
+ (wrapInQuotes signatureInformation.label)
326
328
(signatureInformation.parameters
327
329
|> List. map stringifyParameterInformation
328
330
|> array )
@@ -352,8 +354,8 @@ let stringifyDiagnostic d =
352
354
Printf. sprintf
353
355
{| {
354
356
" range" : % s,
355
- " message" : " %s " ,
357
+ " message" : % s ,
356
358
" severity" : % d,
357
359
" source" : " ReScript"
358
360
}| }
359
- (stringifyRange d.range) (Json. escape d.message) d.severity
361
+ (stringifyRange d.range) (wrapInQuotes d.message) d.severity
0 commit comments