Removes some duplication and lends itself for resue in the previewer :-)
Side-effect: We now consitently use versioned text documents, so the
editor will notice when the LSP refactored outdated data.
- Make sure that the element id is part of the element range.
So that when selecting element in the preview, the right item
in the outline is selected
- fixup the selection_range for enum and struct
We want the previewer to become interactive, so we need to pass on the
document versions so we can detect the editor, lsp and previewer going
out of sync.
Add helper functions into a new `element_catalog` module that extract
information on components used in a piece of Slint code on the LSP side
of the LSP.
Eventually this information will be passed on to the Preview side and
can then be used there to show available components.
A None value means the file on disk is the golden version.
We have an editor, the LSP and the preview that all need to at least
notice when they have newer data then their peers. So IMHO it makes
sense to have an optional document version around.
The language server protocol makes use of a version number already. This
patch moves that code into the compiler so that it is stored with the
actual data getting versioned.
- Put the config in a struct so its easier to pass around
- respect the command line args as default for the style
- fix compilation without the preview feature
Add some code to do platform-independent path processing.
This is necessary aas WASM does e.g. not have any absolute paths and
such and the compiler tended to produce wrong results in that case.
Side-effect: We no longer need to depend on `dunce`
Somehow the vscode extension started to send an empty string for the showPreview
command instead of nothing. Resulting in the showPreview command from the command
palette not working anymore.
Fix#3412
This makes sure paths match up with each other. Highlighting broke for
me since the paths in the DocumentCache were canonicalized while the path
the LSP wanted the preview to highlight was not.
No behavior should change in this patch!
Move all the code directly related to the LSP into a `language` module,
with `server_loop.rs` becoming `language.rs`, managing that module.
All the preview related code is moved into `preview`, with `preview.rs`
basically forwarding to `native.rs` and `wasm.rs`.
Code accessed from both `language` and `preview` stayed where it was.