Rename, and a hover that leads with the type
textDocument/rename and prepareRename rename a local binding, or a top-level def or defun the module does not export, with its signature, doc and the files the module includes; a parameter's (arg ...) in its function's doc goes with it. A rename that could change what the program means is refused with the reason: a capture, a keyword parameter, an exported or foreign name, a name that is not one. The renamed text is checked first, and one with an error the text before did not have is refused with it. A hover's first line, which is what the status bar shows, is the type: a nameless (: Type) above a definition is found and shown with the name, and a definition with no signature in the file being edited shows the type the compiler inferred. 🤖 Generated with [ECA](https://eca.dev) Co-Authored-By: eca-agent <git@eca.dev>
This commit is contained in:
parent
6a92386761
commit
853b7c3163
6 changed files with 632 additions and 17 deletions
40
README.md
40
README.md
|
|
@ -1,7 +1,8 @@
|
|||
# BjolangLsp
|
||||
|
||||
A language server for Bjolang. It checks a file against its project's
|
||||
packages (see "Projects"), and it does five things:
|
||||
packages (see "Projects"). Inferred types and renaming have sections of
|
||||
their own below; besides those, it does these:
|
||||
|
||||
- Diagnostics: it checks a file with the compiler's frontend, as
|
||||
`bjolang --check` does, and sends the errors and warnings to the editor.
|
||||
|
|
@ -84,6 +85,40 @@ Local names are the ones the parser's own forms bind: parameters of a
|
|||
patterns, the clauses of `loop`, `seql` and a comprehension, and `def` or
|
||||
`defun` inside a body, for the forms after it.
|
||||
|
||||
## Rename
|
||||
|
||||
`textDocument/rename`, with `textDocument/prepareRename` so that the editor
|
||||
says why a name cannot be renamed before a new one is typed. It renames
|
||||
|
||||
- a local binding: a parameter, a `let`, a `def` or `defun` in a body, a
|
||||
pattern's variable, a loop variable or accumulator. A parameter of a
|
||||
top-level function is renamed in its `(:doc ...)` too, in `(arg ...)` and
|
||||
`(rest ...)`;
|
||||
- a top-level `def` or `defun` the module does not export, with its
|
||||
signature, its `(:doc ...)` and its other mentions, in the files the module
|
||||
includes as well.
|
||||
|
||||
The places are the ones go to definition would take to the binding: every
|
||||
symbol of that name that means it, in an interpolated string's `${...}`
|
||||
too. Quoted data, the names of a `#'` template that are not unquoted, and a
|
||||
type's declaration are left.
|
||||
|
||||
It is refused, with what the editor shows as the reason, where it could
|
||||
change what the program means:
|
||||
|
||||
- the new name would take a use from another binding: a binding of it
|
||||
inside the renamed one's scope, or a use of it there;
|
||||
- a keyword parameter, as callers write its name as `#:name`;
|
||||
- an exported name, a macro, `main`, and a name defined elsewhere;
|
||||
- a new name that is not one symbol, starts with an upper case letter, or
|
||||
has a `.`;
|
||||
- a new name the module already sees, for a top-level definition.
|
||||
|
||||
Before it answers, the server checks the renamed text. A renamed program
|
||||
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.
|
||||
|
||||
## Building
|
||||
|
||||
It expects the Bjolang checkout beside this one, at `../Bjolang`, and runs
|
||||
|
|
@ -196,7 +231,8 @@ With eglot instead:
|
|||
- Completion of record fields after `record-ref`, of module paths in an
|
||||
`import`, or of keyword arguments. A string that began on an earlier line
|
||||
is not seen as one, so a multi-line string gets completions.
|
||||
- Find references, rename.
|
||||
- Find references, and renaming an exported name, a keyword parameter, a
|
||||
type, a constructor, a field or a trait method (see "Rename").
|
||||
- More than one project. A server serves the project of the first file it is
|
||||
asked about; see "Projects" above.
|
||||
- Stale imports are built by the installed compiler, which was tested only
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue