Skip to content

Commit 564f905

Browse files
committed
Add needed LSP protocol types for code lenses.
1 parent 005388a commit 564f905

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

analysis/src/Protocol.ml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
type position = {line: int; character: int}
22
type range = {start: position; end_: position}
33
type markupContent = {kind: string; value: string}
4+
type command = {title: string; command: string}
5+
type codeLens = {range: range; command: command option}
46
type inlayHint = {
57
position: position;
68
label: string;
@@ -147,6 +149,26 @@ let stringifyHint hint =
147149
(stringifyPosition hint.position)
148150
(Json.escape hint.label) hint.kind hint.paddingLeft hint.paddingRight
149151

152+
let stringifyCommand (command : command) =
153+
Printf.sprintf
154+
{|{
155+
"title": "%s",
156+
"command": "%s"
157+
}|}
158+
(Json.escape command.title)
159+
(Json.escape command.command)
160+
161+
let stringifyCodeLens (codeLens : codeLens) =
162+
Printf.sprintf
163+
{|{
164+
"range": %s,
165+
"command": %s
166+
}|}
167+
(stringifyRange codeLens.range)
168+
(match codeLens.command with
169+
| None -> ""
170+
| Some command -> stringifyCommand command)
171+
150172
(* https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#diagnostic *)
151173
let stringifyDiagnostic d =
152174
Printf.sprintf

0 commit comments

Comments
 (0)