References, and code actions that add a match's clauses and fill holes
textDocument/references and documentHighlight give the uses of the name
at point in its module, found as go to definition finds a binding: a
local, a top-level definition, a type or a constructor, or an imported
name where the module uses it. Uses.fs holds the search, which Rename
now shares.
textDocument/codeAction offers what the compiler worked out while it
checked (Exhaustiveness.observe, Holes.observe, kept by Fixes.fs): at an
incomplete match, the clauses it lacks, lined up after its last clause
with holes as bodies; at a typed hole, a binding in scope that fits, a
constructor of its type with holes for what it takes, or a fun.
Version 0.7.0.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-22 20:34:41 +02:00
|
|
|
/// What the compiler offers to write, from a file's last check: the clauses a
|
2026-11-25 08:01:34 +01:00
|
|
|
/// match lacks, what could fill a hole, and the signature of a function that
|
|
|
|
|
/// has none. The compiler hands them to `Exhaustiveness.observe`,
|
|
|
|
|
/// `Holes.observe` and `CheckDecl.observeMissingSignature` as it refuses the
|
|
|
|
|
/// code. The first two cost nothing beyond the check. For the third, the
|
|
|
|
|
/// compiler checks the body of each function that has no signature, which it
|
|
|
|
|
/// does not do with no observer.
|
References, and code actions that add a match's clauses and fill holes
textDocument/references and documentHighlight give the uses of the name
at point in its module, found as go to definition finds a binding: a
local, a top-level definition, a type or a constructor, or an imported
name where the module uses it. Uses.fs holds the search, which Rename
now shares.
textDocument/codeAction offers what the compiler worked out while it
checked (Exhaustiveness.observe, Holes.observe, kept by Fixes.fs): at an
incomplete match, the clauses it lacks, lined up after its last clause
with holes as bodies; at a typed hole, a binding in scope that fits, a
constructor of its type with holes for what it takes, or a fun.
Version 0.7.0.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-22 20:34:41 +02:00
|
|
|
module BjolangLsp.Fixes
|
|
|
|
|
|
|
|
|
|
open System.IO
|
|
|
|
|
open Bjolang
|
|
|
|
|
open Bjolang.Lexer
|
|
|
|
|
|
|
|
|
|
type Facts =
|
|
|
|
|
{ Missing: Exhaustiveness.MissingClauses list
|
2026-11-25 08:01:34 +01:00
|
|
|
Holes: Holes.Fillers list
|
|
|
|
|
Signatures: CheckDecl.MissingSignature list }
|
References, and code actions that add a match's clauses and fill holes
textDocument/references and documentHighlight give the uses of the name
at point in its module, found as go to definition finds a binding: a
local, a top-level definition, a type or a constructor, or an imported
name where the module uses it. Uses.fs holds the search, which Rename
now shares.
textDocument/codeAction offers what the compiler worked out while it
checked (Exhaustiveness.observe, Holes.observe, kept by Fixes.fs): at an
incomplete match, the clauses it lacks, lined up after its last clause
with holes as bodies; at a typed hole, a binding in scope that fits, a
constructor of its type with holes for what it takes, or a fun.
Version 0.7.0.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-22 20:34:41 +02:00
|
|
|
|
2026-11-25 08:01:34 +01:00
|
|
|
let private none = { Missing = []; Holes = []; Signatures = [] }
|
References, and code actions that add a match's clauses and fill holes
textDocument/references and documentHighlight give the uses of the name
at point in its module, found as go to definition finds a binding: a
local, a top-level definition, a type or a constructor, or an imported
name where the module uses it. Uses.fs holds the search, which Rename
now shares.
textDocument/codeAction offers what the compiler worked out while it
checked (Exhaustiveness.observe, Holes.observe, kept by Fixes.fs): at an
incomplete match, the clauses it lacks, lined up after its last clause
with holes as bodies; at a typed hole, a binding in scope that fits, a
constructor of its type with holes for what it takes, or a fun.
Version 0.7.0.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-22 20:34:41 +02:00
|
|
|
|
|
|
|
|
let private byFile = System.Collections.Generic.Dictionary<string, Facts>()
|
|
|
|
|
|
|
|
|
|
/// Runs `check` of `path` with the compiler handing over what it refused, and
|
|
|
|
|
/// keeps what is in `path` as the file's.
|
|
|
|
|
let recording (path: string) (check: unit -> 'a) : 'a =
|
|
|
|
|
let full = Path.GetFullPath path
|
|
|
|
|
let inFile (r: Range) = r.File <> "" && Path.GetFullPath r.File = full
|
|
|
|
|
let missing = ResizeArray<Exhaustiveness.MissingClauses>()
|
|
|
|
|
let holes = ResizeArray<Holes.Fillers>()
|
2026-11-25 08:01:34 +01:00
|
|
|
let signatures = ResizeArray<CheckDecl.MissingSignature>()
|
2026-11-25 08:39:42 +01:00
|
|
|
Exhaustiveness.observe.Value <- Some(fun m -> if inFile m.Range then missing.Add m)
|
|
|
|
|
Holes.observe.Value <- Some(fun h -> if inFile h.Range then holes.Add h)
|
|
|
|
|
CheckDecl.observeMissingSignature.Value <- Some(fun s -> if inFile s.Range then signatures.Add s)
|
References, and code actions that add a match's clauses and fill holes
textDocument/references and documentHighlight give the uses of the name
at point in its module, found as go to definition finds a binding: a
local, a top-level definition, a type or a constructor, or an imported
name where the module uses it. Uses.fs holds the search, which Rename
now shares.
textDocument/codeAction offers what the compiler worked out while it
checked (Exhaustiveness.observe, Holes.observe, kept by Fixes.fs): at an
incomplete match, the clauses it lacks, lined up after its last clause
with holes as bodies; at a typed hole, a binding in scope that fits, a
constructor of its type with holes for what it takes, or a fun.
Version 0.7.0.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-22 20:34:41 +02:00
|
|
|
|
|
|
|
|
try
|
|
|
|
|
check ()
|
|
|
|
|
finally
|
2026-11-25 08:39:42 +01:00
|
|
|
Exhaustiveness.observe.Value <- None
|
|
|
|
|
Holes.observe.Value <- None
|
|
|
|
|
CheckDecl.observeMissingSignature.Value <- None
|
References, and code actions that add a match's clauses and fill holes
textDocument/references and documentHighlight give the uses of the name
at point in its module, found as go to definition finds a binding: a
local, a top-level definition, a type or a constructor, or an imported
name where the module uses it. Uses.fs holds the search, which Rename
now shares.
textDocument/codeAction offers what the compiler worked out while it
checked (Exhaustiveness.observe, Holes.observe, kept by Fixes.fs): at an
incomplete match, the clauses it lacks, lined up after its last clause
with holes as bodies; at a typed hole, a binding in scope that fits, a
constructor of its type with holes for what it takes, or a fun.
Version 0.7.0.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-22 20:34:41 +02:00
|
|
|
|
|
|
|
|
byFile[full] <-
|
|
|
|
|
{ Missing = missing |> Seq.distinctBy (fun m -> m.Range) |> List.ofSeq
|
2026-11-25 08:01:34 +01:00
|
|
|
Holes = holes |> Seq.distinctBy (fun h -> h.Range) |> List.ofSeq
|
|
|
|
|
Signatures = signatures |> Seq.distinctBy (fun s -> s.Range) |> List.ofSeq }
|
References, and code actions that add a match's clauses and fill holes
textDocument/references and documentHighlight give the uses of the name
at point in its module, found as go to definition finds a binding: a
local, a top-level definition, a type or a constructor, or an imported
name where the module uses it. Uses.fs holds the search, which Rename
now shares.
textDocument/codeAction offers what the compiler worked out while it
checked (Exhaustiveness.observe, Holes.observe, kept by Fixes.fs): at an
incomplete match, the clauses it lacks, lined up after its last clause
with holes as bodies; at a typed hole, a binding in scope that fits, a
constructor of its type with holes for what it takes, or a fun.
Version 0.7.0.
🤖 Generated with [ECA](https://eca.dev)
Co-Authored-By: eca-agent <git@eca.dev>
2026-10-22 20:34:41 +02:00
|
|
|
|
|
|
|
|
/// The facts of `path`'s last check.
|
|
|
|
|
let ofFile (path: string) : Facts =
|
|
|
|
|
match byFile.TryGetValue(Path.GetFullPath path) with
|
|
|
|
|
| true, facts -> facts
|
|
|
|
|
| _ -> none
|