Signature help, formatting, and a fix that writes a missing signature
- textDocument/signatureHelp: the function whose call the cursor is in, with the parameter that is being written marked. A definition shows its head as written; an import, a trait's method and a builtin show their type. It reads tokens as far as the cursor, so a call that is not closed has help. - textDocument/formatting: the whole text as bjo fmt lays it out. The server runs bjo -q fmt - on the buffer's text. - A quick fix at a function with no signature writes the one its body gives it, on a line above the definition (CheckDecl.observeMissingSignature, in the compiler). - The server says version 0.8.0. Needs the compiler at its commit "CheckDecl.observeMissingSignature". Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
d421ec9363
commit
ce426b94df
8 changed files with 695 additions and 11 deletions
17
Actions.fs
17
Actions.fs
|
|
@ -7,6 +7,8 @@
|
|||
/// - Fill a hole with a binding in scope that fits it, a constructor of its
|
||||
/// type with holes for what it takes, or, for a function type, a `fun`
|
||||
/// with a hole for its body.
|
||||
/// - Write the signature of a function that has none, on a line of its own
|
||||
/// above the definition: the type that its body gives it.
|
||||
///
|
||||
/// What is offered is from the file's last check (`Fixes`), and only for text
|
||||
/// that is still what was checked.
|
||||
|
|
@ -95,4 +97,17 @@ let at (path: string) (text: string) (first: Position) (last: Position) : Action
|
|||
|> List.distinct
|
||||
|> List.map (fun filler -> { Title = $"Fill with %s{filler}"; Range = h.Range; NewText = filler }))
|
||||
|
||||
clauses @ fills
|
||||
// Offered on the definition's first line, where the diagnostic is, and
|
||||
// not in its body.
|
||||
let signatures =
|
||||
facts.Signatures
|
||||
|> List.filter (fun s ->
|
||||
touches s.Range first last
|
||||
&& first.Line = s.Range.Start.Line
|
||||
&& (Symbols.sliceOf text s.Range).StartsWith "(")
|
||||
|> List.map (fun s ->
|
||||
{ Title = $"Write the signature %s{s.Signature}"
|
||||
Range = { s.Range with End = s.Range.Start }
|
||||
NewText = s.Signature + "\n" + String.replicate s.Range.Start.Column " " })
|
||||
|
||||
clauses @ fills @ signatures
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue