Hover on fields, and on locals of record types
A field read shows the field's type and its declaration; a local of a record, struct or union type shows the type. Structs and opaque types get their symbols, and the file's own types drop their module qualifier.
This commit is contained in:
parent
29977ca301
commit
78d18c9854
6 changed files with 166 additions and 11 deletions
|
|
@ -68,7 +68,10 @@ let private binderName (s: SExpr) : (string * Range) option =
|
|||
/// fields.
|
||||
let private typeDef (s: SExpr) : Symbol option =
|
||||
match s with
|
||||
| SList([ SAtom { Token = Colon }; head; body ], r) ->
|
||||
// The body is last: `#:opaque` may come before it.
|
||||
| SList(SAtom { Token = Colon } :: head :: (_ :: _ as rest), r) ->
|
||||
let body = List.last rest
|
||||
|
||||
binderName head
|
||||
|> Option.map (fun (name, nr) ->
|
||||
let members, kind, detail =
|
||||
|
|
@ -80,13 +83,13 @@ let private typeDef (s: SExpr) : Symbol option =
|
|||
|> Option.map (fun (n, cr) -> symbol n name Kind.EnumMember (getRange c) cr (getRange c) [])),
|
||||
Kind.Class,
|
||||
"union"
|
||||
| SList(SAtom { Token = Symbol "Record" } :: fields, _) ->
|
||||
| SList(SAtom { Token = Symbol("Record" | "Struct" as shape) } :: fields, _) ->
|
||||
fields
|
||||
|> List.choose (fun f ->
|
||||
binderName f
|
||||
|> Option.map (fun (n, fr) -> symbol n name Kind.Field (getRange f) fr (getRange f) [])),
|
||||
Kind.Struct,
|
||||
"record"
|
||||
(if shape = "Record" then "record" else "struct")
|
||||
| other -> [], Kind.Class, show other
|
||||
|
||||
symbol name detail kind r nr r members)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue