Commit graph

38 commits

Author SHA1 Message Date
Tobias Hunger
f54c2d188b LSP: Cleanup error handling 2022-11-23 13:19:07 +01:00
Tobias Hunger
86f6636815 LSP: Drop document_cache handle before sending more requests
This works around the setBinding calling back into the client, which
would cause the LSP to panic as there already was a mutable reference to
the document cahce held.
2022-11-23 13:19:07 +01:00
Tobias Hunger
edd4e81033 lsp: Add setBinding custom command 2022-11-21 15:01:09 +01:00
Olivier Goffart
2523a6b74c lsp: Make the LSP async 2022-11-21 09:13:21 +01:00
Olivier Goffart
ab4c6bd0e9 Janitor: fix araning when building the vscode extension 2022-11-17 20:02:39 +01:00
Olivier Goffart
baf1e6ef0f Polish the highlight of the preview in the LSP 2022-11-17 12:23:23 +01:00
Olivier Goffart
1884750960 WIP: LSP: highlight selected element in the preview 2022-11-17 12:23:23 +01:00
Olivier Goffart
cbe2d6d631 LSP: add a setting to change the style
... and the include paths
2022-11-13 14:22:27 +01:00
Tobias Hunger
8f29f22c6c lsp: Use proper LSP types for queryProperties 2022-11-11 20:19:35 +01:00
Tobias Hunger
56750e0287 lsp: Report source version in queryPropertyresponse
Also make `source_uri` non-optional: We get an Uri with the request, so
we always have one.
2022-11-11 19:44:08 +01:00
Tobias Hunger
0b97c04c17
lsp: Define a helper struct to map offsets to positions (#1839)
Update the code to use this.
2022-11-11 15:35:29 +01:00
Tobias Hunger
67712d2b46 LSP: Keep current document version around
This will become helpful when actually updating the documents as it can
help to detect races.
2022-11-11 10:34:18 +01:00
Tobias Hunger
4c8b9856b5 lsp: Borrow Position and Url
No need to transfer ownership!

Also use `Url` directly instead of wrapping that into a
`TextDocumentIdentifier`. That way we can burrow the URL and do not need
to clone a `Url` into a `TextDocumentIdentifier` just so we can borrow
that.
2022-11-03 14:54:45 +01:00
Tobias Hunger
268edcf07d LSP: Unify LSP server initialize result
Report the same LSP server `InitializeResult` to all users. This
improves on what was reported from the WASM LSP flavor to its users
before.
2022-11-03 11:41:54 +01:00
Olivier Goffart
d84516b843 lsp: janitor: return None instead of Some with an empty vec when the operation is not supported
https://github.com/slint-ui/slint/pull/1809#pullrequestreview-1165414494
2022-11-03 08:29:29 +01:00
Tobias Hunger
217fa9a337 LSP: features overhaul
* Do not use wasm build in conjunction with `preview` to keep code lense
  support on. Add `preview-lense` feature instead.
* Improve which parts of the LSP are kept based on these features.

With this patch a LSP built for the online-editor is about 10KB smaller
than before.
2022-11-02 15:48:26 +01:00
Olivier Goffart
9fea518ee8 lsp: fix compiler warning when the preview is disabled
Warnings about unused parameters.
Just disable the whole function instead
2022-10-28 11:47:05 +02:00
Olivier Goffart
659cb3a06c LSP: fix property call on invalid base or non-main component
- We should not panic if the base type is invalid
 - We should try to keep bindings in the Element even if the base type
   is invalid
 - Fix querying the element at a position in case it is not in the last
   component of a file
2022-10-21 12:50:42 +02:00
Simon Hausmann
bd412623ab
Online editor: Fix binding expression text shown in the properties view (#1753)
Use the zero-line based lsp range/position types for the QueryProperties
lsp command results and convert them to monaco editor ranges for correct
text extraction.
2022-10-20 15:49:23 +02:00
Tobias Hunger
c994502ce9 LSP: Improve data reported by queryProperties
Report more and better ranges for the expression in an property.
2022-09-22 10:51:26 +02:00
Tobias Hunger
04420b9e65 lsp: Polish the queryProperties command
Make it not error out when no element is selected.
2022-09-22 10:51:26 +02:00
Tobias Hunger
deee971b76 Implement suggestions from @ogoffart 2022-09-02 17:48:31 +02:00
Tobias Hunger
75b02530a9 LSP: Add tests for element_at_position and get_properties 2022-09-02 17:48:31 +02:00
Tobias Hunger
521a4001dc Fix some clippy warnings 2022-09-02 17:48:31 +02:00
Tobias Hunger
7eab597b48 Update tools/lsp/server_loop.rs
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
2022-09-02 17:48:31 +02:00
Tobias Hunger
163f85a6f7 LSP: Implement a queryProperties command
Implment a command in the LSP that can be used to query all known
properties, where those are declared and defined.

With this information we should be able to provide an property editor in
IDEs.
2022-09-02 17:48:31 +02:00
Tobias Hunger
ad33c257cf lsp: Use InitializeResult from lsp-types
Make the previous patch typesafe by enabling the "proposed" feature in
the `lsp-types` crate, so that the `InitializeResult` has the
`offsetEncoding` field.

Fix the fallout of this change.
2022-09-01 15:57:28 +02:00
Tobias Hunger
11c5fc29aa lsp: Add some basic tests 2022-08-31 17:10:51 +02:00
Olivier Goffart
09c2249219 LSP: display the Element tree in the Outline 2022-08-25 22:46:55 +02:00
Tobias Hunger
597e6fbaa1 Move LSP command list into a separate function 2022-08-04 15:37:47 +02:00
Tobias Hunger
a68eb876eb Make LSP command creation a bit DRYer 2022-08-04 15:37:47 +02:00
Olivier Goffart
4979cc65ba vscode web extension: enable the code lense and code action for the preview
And reload the preview when any of the accessed files is changed
2022-06-24 17:23:46 +02:00
Olivier Goffart
474a2ba331 LSP: make the preview feature optional
So it can be disabled when building the web extension, and remove lots of dependencies.

This reduce the wasm size from 6M to 2M
2022-06-03 19:18:03 +02:00
Olivier Goffart
81b53e2ae0 LSP: fetch the file content from cache instead of from disk to compute the line number
Otherwise it doesn't work with the web extension. And the file must anyway be in the cache
2022-06-02 21:45:50 +02:00
Olivier Goffart
31502d5918 VSCode web extension: load files from the vscode API
We can't use file system call to load files with wasm, we need to go through the vscode API

Note that this is all async, so i had to prevent re-entry within the compiler using a rentry trick.

I removed the lifetime in the TypeLoader because I thought this was going to be necessary
to get 'static futures. But it turned out not to be necessary. Anyway, I kept it htis way because
it is actually nicer IMHO, even if the CompilationConfiguration is now copied
2022-06-02 16:21:07 +02:00
Olivier Goffart
b1c11eb19b Fix error reporting: wasm always uses url which are always "relative" path 2022-05-31 17:44:56 +02:00
Olivier Goffart
c969eaf59c vscode web extension: make send_notification work 2022-05-31 17:44:56 +02:00
Olivier Goffart
8f03e2cff1 WIP: make the vscode extension work as web extension
This refactor the LSP to be possible to compile for wasm.
When using wasm we can't use the lsp-server crate because that one use the
stdin/stdout to communicate.
Instead, we need will do the communication in TypeScript using the vscode
language server protocol library, and serialize the types to wasm. Fortunately
that's easy because the lsp-types crate contains all the serialized types.

This also "duplicate" the extension as a web extension that do not use process
to start the LSP, but use a web worker. Some of the extension code could
be refactored to avoid some duplication (like the status bar handling and such).
And add a "browser" entry point in the package.json

Finally, add a browserServerMain.ts entry point for our worker, it will try to load
the wasm code.

Currently this doesn't wirk: the browserServerMain.ts can't load the wasm.

Also todo is to write the code so that the wasm code can send the response and
notifications.

To debug, I type these commands in editor/vscode directory

    npm run compile-web
    code --extensionDevelopmentKind=web --extensionDevelopmentPath=$PWD   ../..
2022-05-31 17:44:56 +02:00