You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|Some (Unlabelled index) -> "unlabelled<"^ string_of_int index ^">");
248
-
249
-
(* The LS protocol wants us to send both the full type signature (label) that the end user sees as the signature help, and all parameters in that label
250
-
in the form of a list of start/end character offsets. We leverage the parser to figure the offsets out by parsing the label, and extract the
251
-
offsets from the parser. *)
155
+
let textOpt =Files.readFile currentFile in
156
+
match textOpt with
157
+
|None|Some"" -> None
158
+
|Sometext -> (
159
+
matchPos.positionToOffset text pos with
160
+
|None -> None
161
+
|Someoffset -> (
162
+
let posBeforeCursor =Pos.posBeforeCursor pos in
163
+
let offsetNoWhite =Utils.skipWhite text (offset -1) in
164
+
let firstCharBeforeCursorNoWhite =
165
+
if offsetNoWhite <String.length text && offsetNoWhite >=0then
166
+
Some text.[offsetNoWhite]
167
+
elseNone
168
+
in
169
+
let supportsMarkdownLinks =truein
170
+
let foundFunctionApplicationExpr =refNonein
171
+
letsetFoundr=
172
+
if!foundFunctionApplicationExpr =Nonethen
173
+
foundFunctionApplicationExpr :=Some r
174
+
in
175
+
letsearchForArgWithCursor~isPipeExpr~args~exp=
176
+
let extractedArgs = extractExpApplyArgs ~argsin
177
+
let argAtCursor =
178
+
let firstArgIndex =if isPipeExpr then1else0in
179
+
let unlabelledArgCount =ref firstArgIndex in
180
+
let lastUnlabelledArgBeforeCursor =ref firstArgIndex in
181
+
let argAtCursor_ =
182
+
extractedArgs
183
+
|>List.find_map (funarg ->
184
+
match arg.label with
185
+
|None ->
186
+
let currentUnlabelledArgCount =!unlabelledArgCount in
let parameters = extractParameters ~signature~labelin
261
-
if debug then
262
-
Printf.printf "extracted params: \n%s\n"
263
-
(parameters
264
-
|>List.map (fun (_, start, end_) ->
265
-
String.sub label start (end_ - start))
266
-
|>list);
295
+
(* The LS protocol wants us to send both the full type signature (label) that the end user sees as the signature help, and all parameters in that label
296
+
in the form of a list of start/end character offsets. We leverage the parser to figure the offsets out by parsing the label, and extract the
297
+
offsets from the parser. *)
267
298
268
-
(* Figure out the active parameter *)
269
-
let activeParameter = findActiveParameter ~argAtCursor ~argsin
270
-
Some
271
-
{
272
-
Protocol.signatures =
273
-
[
274
-
{
275
-
label;
276
-
parameters =
277
-
parameters
278
-
|>List.map (fun (argLabel, start, end_) ->
279
-
{
280
-
Protocol.label = (start, end_);
281
-
documentation =
282
-
(match
283
-
args
284
-
|>List.find_opt (fun (lbl, _) ->
285
-
lbl = argLabel)
286
-
with
287
-
|None ->
288
-
{Protocol.kind ="markdown"; value ="Nope"}
289
-
|Some (_, labelTypExpr) ->
290
-
{
291
-
Protocol.kind ="markdown";
292
-
value =
293
-
docsForLabel ~supportsMarkdownLinks ~file
294
-
~package labelTypExpr;
295
-
});
296
-
});
297
-
documentation =
298
-
(matchList.nth_opt docstring 0with
299
-
|None -> None
300
-
|Somedocs -> Some {Protocol.kind ="markdown"; value = docs});
301
-
};
302
-
];
303
-
activeSignature =Some0;
304
-
activeParameter =
305
-
(match activeParameter with
306
-
|None -> Some (-1)
307
-
|activeParameter -> activeParameter);
308
-
}
309
-
|_ -> None)
310
-
|_ -> None
299
+
(* Put together a label here that both makes sense to show to the end user in the signature help, but also can be passed to the parser. *)
300
+
let label ="let "^ name ^": "^Shared.typeToString type_expr in
0 commit comments