Skip to content

Commit dadc18d

Browse files
committed
fix signature help in uncurried mode
1 parent 29b377b commit dadc18d

File tree

3 files changed

+494
-6
lines changed

3 files changed

+494
-6
lines changed

analysis/src/SignatureHelp.ml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,23 @@ let findFunctionType ~currentFile ~debug ~path ~pos =
3939
let extractParameters ~signature ~typeStrForParser ~labelPrefixLen =
4040
match signature with
4141
| [
42-
{
43-
Parsetree.psig_desc =
44-
Psig_value {pval_type = {ptyp_desc = Ptyp_arrow _} as expr};
45-
};
42+
( {
43+
Parsetree.psig_desc =
44+
Psig_value {pval_type = {ptyp_desc = Ptyp_arrow _} as expr};
45+
}
46+
| {
47+
psig_desc =
48+
Psig_value
49+
{
50+
pval_type =
51+
{
52+
ptyp_desc =
53+
Ptyp_constr
54+
( {txt = Lident "function$"},
55+
[({ptyp_desc = Ptyp_arrow _} as expr); _] );
56+
};
57+
};
58+
} );
4659
] ->
4760
let rec extractParams expr params =
4861
match expr with
@@ -257,12 +270,13 @@ let signatureHelp ~path ~pos ~currentFile ~debug =
257270
in
258271
let expr (iterator : Ast_iterator.iterator) (expr : Parsetree.expression)
259272
=
273+
(*DumpAst.printExprItem ~pos ~indentation:0 expr |> print_endline;*)
260274
(match expr with
261275
(* Handle pipes, like someVar->someFunc(... *)
262276
| {
263277
pexp_desc =
264278
Pexp_apply
265-
( {pexp_desc = Pexp_ident {txt = Lident "|."}},
279+
( {pexp_desc = Pexp_ident {txt = Lident ("|." | "|.u")}},
266280
[
267281
_;
268282
( _,
@@ -280,7 +294,7 @@ let signatureHelp ~path ~pos ~currentFile ~debug =
280294
searchForArgWithCursor ~isPipeExpr:true ~args
281295
in
282296
setFound (argAtCursor, exp, extractedArgs)
283-
(* Look for applying idents, like someIdent(...) *)
297+
(* Look for applying idents, like someIdent(...) *)
284298
| {
285299
pexp_desc = Pexp_apply (({pexp_desc = Pexp_ident _} as exp), args);
286300
pexp_loc;
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
@@uncurried
2+
3+
type someVariant = One | Two | Three
4+
5+
/** Does stuff. */
6+
let someFunc = (one: int, ~two: option<string>=?, ~three: unit => unit, ~four: someVariant, ()) => {
7+
ignore(one)
8+
ignore(two)
9+
ignore(three())
10+
ignore(four)
11+
}
12+
13+
let otherFunc = (first: string, second: int, third: float) => {
14+
ignore(first)
15+
ignore(second)
16+
ignore(third)
17+
}
18+
19+
// let _ = someFunc(
20+
// ^she
21+
22+
// let _ = someFunc(1
23+
// ^she
24+
25+
// let _ = someFunc(123, ~two
26+
// ^she
27+
28+
// let _ = someFunc(123, ~two="123"
29+
// ^she
30+
31+
// let _ = someFunc(123, ~two="123", ~four
32+
// ^she
33+
34+
// let _ = someFunc(123, ~two="123", ~four=O
35+
// ^she
36+
37+
// let _ = otherFunc(
38+
// ^she
39+
40+
// let _ = otherFunc("123"
41+
// ^she
42+
43+
// let _ = otherFunc("123", 123, 123.0)
44+
// ^she
45+
46+
// let _ = Completion.Lib.foo(~age
47+
// ^she
48+
49+
let iAmSoSpecial = (iJustHaveOneArg: string) => {
50+
ignore(iJustHaveOneArg)
51+
}
52+
53+
// let _ = iAmSoSpecial(
54+
// ^she
55+
56+
// let _ = "hello"->otherFunc(1
57+
// ^she
58+
59+
let fn = (age: int, name: string, year: int) => {
60+
ignore(age)
61+
ignore(name)
62+
ignore(year)
63+
}
64+
65+
// let _ = fn(22, )
66+
// ^she
67+
68+
// let _ = fn(22, , 2023)
69+
// ^she
70+
71+
// let _ = fn(12, "hello", )
72+
// ^she
73+
74+
// let _ = fn({ iAmSoSpecial() })
75+
// ^she
76+
77+
// let _ = fn({ iAmSoSpecial({ someFunc() }) })
78+
// ^she

0 commit comments

Comments
 (0)