Diagnostics at the compiler's ranges, and a link to one in another file

- A diagnostic is marked from where the compiler's range of it starts to
  where it ends (Diagnostics.rangeOf, in the compiler). A quoted list, an
  array literal and an interpolated string were marked as one character.
  A location with no range behind it is read from the message, as before.
- A diagnostic in an included or an imported file has its place there as
  related information.
- The README and the smoke test name bin/Release/net11.0, where the build
  is since the compiler's target changed.
- smoke: the prelude's definitions are in prelude/core.bjo.

Needs the compiler at its commit "Diagnostics.rangeOf".

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Linus Björnstam 2026-11-25 07:30:13 +01:00
parent ceb6f1b93a
commit d421ec9363
4 changed files with 175 additions and 32 deletions

View file

@ -9,9 +9,15 @@ their own below; besides those, it does these:
It checks the editor's text, saved or not: when a file is opened or
saved, and 400 ms after typing pauses. Every open file is read from its
buffer, so an unsaved include or `.bjodoc` counts too. A diagnostic marks
the form at the line and column the compiler names: an atom or a string
whole, a bracketed form to its closing bracket, and one over several lines
as far as its head, `(defun` or `(match`.
the range the compiler gives for it, from its start to its end
(`Diagnostics.rangeOf`): a quoted list, an array literal or an
interpolated string whole. A range over several lines is marked as far as
its head, `(defun` or `(match`, so that an error does not mark a whole
definition. Where the compiler has a line and a column only, as for an
error of the tokenizer, the form that starts there is marked. A
diagnostic in another file, an included or an imported one, is on the
first line of the file that was checked, with its place in the other file
as related information, which an editor shows as a link.
- An outline (`textDocument/documentSymbol`): the file's top-level
definitions, with a type's constructors or fields, a trait's methods and an
`impl`'s functions under them. A `def` or `def*` of a pattern gives the
@ -178,8 +184,8 @@ dotnet build -c Release
test/smoke.py
```
The server is `bin/Release/net10.0/BjolangLsp.dll`, started as
`dotnet bin/Release/net10.0/BjolangLsp.dll`. It talks LSP on stdin and
The server is `bin/Release/net11.0/BjolangLsp.dll`, started as
`dotnet bin/Release/net11.0/BjolangLsp.dll`. It talks LSP on stdin and
stdout, and logs to stderr.
## Projects
@ -224,7 +230,7 @@ would:
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection
'("dotnet" "/home/linis/Programmering/BjolangLsp/bin/Release/net10.0/BjolangLsp.dll"))
'("dotnet" "/home/linis/Programmering/BjolangLsp/bin/Release/net11.0/BjolangLsp.dll"))
:activation-fn (lsp-activate-on "bjolang")
:server-id 'bjolang-lsp)))
@ -254,14 +260,12 @@ With eglot instead:
```elisp
(add-to-list 'eglot-server-programs
'(bjo-mode . ("dotnet" "/home/linis/Programmering/BjolangLsp/bin/Release/net10.0/BjolangLsp.dll")))
'(bjo-mode . ("dotnet" "/home/linis/Programmering/BjolangLsp/bin/Release/net11.0/BjolangLsp.dll")))
```
## What it does not do yet
- Exact ends. The compiler says where a diagnostic starts, and the form that
starts there is marked, as far as its head when it spans several lines.
That is the form the message is about in most cases, not in all.
- A range over several lines is marked as far as its head only.
- A check of a large file waits for the requests before it, and they for it:
everything that touches the compiler runs on one thread, because the
compiler's state is global.
@ -270,9 +274,10 @@ With eglot instead:
- Which definition. A name defined in two imported modules goes to the
nearer one, which is not always the one the compiler would pick, and a
module the file does not export from is searched like one it does.
- Errors in another file. A diagnostic located in an imported or included
file is shown on the first line of the file being checked, with its
location in the message.
- Diagnostics on another file. A diagnostic located in an imported or
included file is on the first line of the file being checked, and links to
its place. It is not published for the other file itself: that file's own
check, when it is open, would replace it.
- Hover for a special form (`record-ref`, `loop`, `match`), which has no
definition to find and no doc.
- The type of an expression that is not a name.