Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arity0 hovering issues #440

Merged
merged 5 commits into from
May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion analysis/tests/src/Hover.res
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,22 @@ let typeDuplicate = AA.fnnxx
// ^hov

@live let dd = 34
// ^hov
// ^hov

let arity0a = (. ()) => {
//^hov
let f = () => 3
f
}

let arity0b = (. (), . ()) => 3
// ^hov

let arity0c = (. (), ()) => 3
// ^hov

let arity0d = (. ()) => {
// ^hov
let f = () => 3
f
}
12 changes: 12 additions & 0 deletions analysis/tests/src/expected/Hover.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,15 @@ Attribute id:live:[112:0->112:5] label:live
Completable: Cdecorator(live)
{"contents": "The `@live` decorator is for reanalyze, a static analysis tool for ReScript that can do dead code analysis.\n\n`@live` tells the dead code analysis that the value should be considered live, even though it might appear to be dead. This is typically used in case of FFI where there are indirect ways to access values. It can be added to everything that could otherwise be considered unused by the dead code analysis - values, functions, arguments, records, individual record fields, and so on.\n\n[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#live-decorator).\n\nHint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!"}

Hover tests/src/Hover.res 115:4
{"contents": "```rescript\n(.) => unit => int\n```"}

Hover tests/src/Hover.res 121:4
{"contents": "```rescript\n(.) => (.) => int\n```"}

Hover tests/src/Hover.res 124:4
{"contents": "```rescript\n(. unit, unit) => int\n```"}

Hover tests/src/Hover.res 127:5
{"contents": "```rescript\n(.) => unit => int\n```"}

14 changes: 6 additions & 8 deletions analysis/vendor/res_outcome_printer/res_outcome_printer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,18 @@ let printPolyVarIdent txt =
)
| Otyp_alias (typ, aliasTxt) ->
Doc.concat [
Doc.lparen;
printOutTypeDoc typ;
Doc.text " as '";
Doc.text aliasTxt;
Doc.rparen
Doc.text aliasTxt
]
| Otyp_constr (
Oide_dot (Oide_dot (Oide_ident "Js", "Fn") , "arity0"), (* Js.Fn.arity0 *)
[Otyp_constr (Oide_ident ident, [])] (* int or unit or string *)
[typ]
) ->
(* Js.Fn.arity0<int> -> (.) => int*)
(* Js.Fn.arity0<t> -> (.) => t *)
Doc.concat [
Doc.text "(. ()) => ";
Doc.text ident;
Doc.text "(.) => ";
printOutTypeDoc typ;
]
| Otyp_constr (
Oide_dot (Oide_dot (Oide_ident "Js", "Fn") , ident), (* Js.Fn.arity2 *)
Expand Down Expand Up @@ -352,7 +350,7 @@ let printPolyVarIdent txt =
let i = ref 0 in
let package = Doc.join ~sep:Doc.line ((List.map2 [@doesNotRaise]) (fun lbl typ ->
Doc.concat [
Doc.text (if i.contents > 0 then "and type " else "with type ");
Doc.text (if i.contents > 0 then "and " else "with ");
Doc.text lbl;
Doc.text " = ";
printOutTypeDoc typ;
Expand Down