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>
This commit is contained in:
parent
853b7c3163
commit
23b6a0e55c
9 changed files with 634 additions and 60 deletions
32
README.md
32
README.md
|
|
@ -19,6 +19,15 @@ their own below; besides those, it does these:
|
|||
it is bound, the innermost binding of it; a top-level name to the file's
|
||||
own definition, else one in a module it imports or includes, searched
|
||||
nearest first, and then the prelude.
|
||||
- References (`textDocument/references`) and highlights
|
||||
(`textDocument/documentHighlight`): the uses of the name at point in its
|
||||
module, its own file and what that includes. A use is a symbol the name
|
||||
means there, found as go to definition finds a binding, so a shadowing
|
||||
local of the same name, quoted data and a `#'` template's own names are
|
||||
not uses. Any name has them: a local, a top-level definition, a type or a
|
||||
constructor, and an imported name or a builtin, where this module uses it.
|
||||
Uses in other modules are not looked for. A highlight marks the binding
|
||||
or definition as a write and the rest as reads.
|
||||
- Hover (`textDocument/hover`) for the same names. A top-level name shows
|
||||
the `(: name Type)` declaration and the definition's head as written, then
|
||||
its doc from the module's `(:doc ...)` forms and `.bjodoc` files, with the
|
||||
|
|
@ -119,6 +128,29 @@ with an error the program before it did not have is refused, with the
|
|||
error: `(defun (twice s) ...)` renamed to `when` makes `(twice v)` the
|
||||
special form.
|
||||
|
||||
## Code actions
|
||||
|
||||
`textDocument/codeAction` offers two kinds of quick fix, both worked out by
|
||||
the compiler while it checks and handed over through
|
||||
`Exhaustiveness.observe` and `Holes.observe` (`Fixes.fs`):
|
||||
|
||||
- At a match that does not cover every value: add the clauses it lacks,
|
||||
after its last clause and lined up with it, each with a hole for its
|
||||
body: `((Square _) _)`. They are found one missing value at a time, so
|
||||
that together they cover what the match does not, nested cases spelled
|
||||
out, `((Some (Square _)) _)`. A value of an integer or a char, or a vec of
|
||||
one length, is widened to all of them; past 20 clauses a `_` takes the
|
||||
rest.
|
||||
- At a typed hole: fill it with a binding in scope that fits it, as the
|
||||
hole's message ranks them (the first twelve); with a constructor of its
|
||||
type, with holes for what it takes, `(Circle _)`, or a record with each of
|
||||
its fields; or, for a function type, with `(fun (x y) _)`.
|
||||
|
||||
A hole in what was written is a new hole for the next check, so a fix is a
|
||||
step: the clauses' bodies are holes, and each says what it has to be. The
|
||||
actions are of the file's last check, which a check that is due replaces
|
||||
first, as for a hover, and only of text that is still what it checked.
|
||||
|
||||
## Building
|
||||
|
||||
It expects the Bjolang checkout beside this one, at `../Bjolang`, and runs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue