Inferred types: in hovers, and as inlay hints
A check keeps what the compiler inferred, through Inference.observe, as each use of a name with its type there and each binding with the type it binds. A hover shows (: name type) for a local, and a generic function's type at the use hovered. Inlay hints show the type after each local name where it is bound and no type is written. Hints before the first change since the last check are sent; the ones after it wait for the check, which then asks the client to ask again. A hover runs a check that is due first. 🤖 Generated with [ECA](https://eca.dev) Co-Authored-By: eca-agent <git@eca.dev>
This commit is contained in:
parent
cc62a8a360
commit
471b49d9e4
9 changed files with 571 additions and 20 deletions
13
Hover.fs
13
Hover.fs
|
|
@ -225,14 +225,21 @@ let private doc (found: Found) : string option =
|
|||
|> Option.map (fun entry -> docText entry (Some found.Symbol.Name))
|
||||
| _ -> None
|
||||
|
||||
/// The hover for a local name: its binding as written, and what binds it.
|
||||
let local (b: Scope.Binder) (shown: string) : string =
|
||||
/// The hover for a local name: its type, if the last check inferred one, its
|
||||
/// binding as written, and what binds it.
|
||||
let local (b: Scope.Binder) (inferred: string option) (shown: string) : string =
|
||||
let what = b.Description
|
||||
|
||||
let sentence = string (Char.ToUpperInvariant what[0]) + what.Substring 1
|
||||
[ fence (clip shown); $"*%s{sentence}.*" ]
|
||||
let declared = inferred |> Option.map (fun t -> $"(: %s{b.Name} %s{t})") |> Option.toList
|
||||
|
||||
[ fence (String.concat "\n" (declared @ [ clip shown ])); $"*%s{sentence}.*" ]
|
||||
|> String.concat "\n\n"
|
||||
|
||||
/// What a hover over a use of a generic binding adds: the type it has there.
|
||||
let instantiated (name: string) (t: string) : string =
|
||||
"*At this use:*\n\n" + fence $"(: %s{name} %s{t})"
|
||||
|
||||
/// The type of a builtin, one the compiler defines rather than a module, as a
|
||||
/// declaration: `(: seq-unfold (-> ...))`. `None` for a name that is not one.
|
||||
let builtinDeclaration (name: string) : string option =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue