Commit graph

356 commits

Author SHA1 Message Date
Olivier Goffart
143ad8ab75 LSP: use the new syntax to create the previewed component
Avoid warnings when previewing
2023-02-21 19:47:08 +01:00
Olivier Goffart
8450e01a3f
Change the name of the compat feature (#2230)
And remove the compat-0-2-0 and compat-0-3-0 features
2023-02-16 09:40:44 +01:00
Olivier Goffart
5b3cde87ab Update dependencies 2023-02-15 10:28:02 +01:00
Olivier Goffart
6889dfa5f5 Rust: Make new(), run() and show() report errors from the backend
Fixes #2198
2023-02-10 05:00:03 +01:00
Olivier Goffart
f6e4f16a14 LSP: Dont detect slint::slint! as slint macro in comments or stings
We already detected that `slint!` in a comment should not be interpreted
as a slint macro, but that detection failed for `slint::slint!` or if
`slint` was twice in the same line.
2023-02-09 08:52:51 +01:00
ogoffart
e7f48512ee Bump version number to 1.0.0 2023-02-03 11:07:15 +01:00
Olivier Goffart
f2c680ac28 Update description in Cargo.toml 2023-01-27 08:54:13 +01:00
Olivier Goffart
3a1c515200 LSP: Fix calculation of element position
Basically same as e88b07997f but in the
set_binding_command function.
(made the code more similar to remove_binding_command, I think the two
function should be merged in the future)

This fix editing binding within the root component when it inherits from
something.
2023-01-25 10:27:40 +01:00
Tobias Hunger
e88b07997f LSP: Fix calculation of element position
Use map_node as that trimms out stray whitespaces.
2023-01-24 21:02:17 +01:00
Tobias Hunger
b718c9c043 tools: Remove progress reporting for file loading
Stop the LSP from reporting progress information on file loading. This
caused problems with VSCode: First it triggered popups in the UI and
secondly it caused problems for the LSP that was asked to process
requests while calling back into the client.

Adapt the online editor and the two VSCode plugins to work with the
updated code.

Note: I did leave in the progress reporting code that can be used to
handle progress initiated by the _client_ side. That is just
notifications which will not block the LSP in any way and we might need
to support that at some point.

I did remove the Middleware code from the client side though that acted
on the progress information.
2023-01-23 19:51:55 +01:00
Olivier Goffart
32c99177b8 LSP: fix document outline with vscode
Currently, the reported range is the range of the root element, which
doesn't include the name of the component itself.
While the Name of the component itself is used as the selection range.
Vscode assrts that the selection range is within the range:

```
ERR selectionRange must be contained in fullRange: Error: selectionRange must be contained in fullRange
```

So use the full component range for the range instead
2023-01-23 15:51:01 +01:00
Simon Hausmann
24dcef5fed
First stage of cleaning up the export handling of the slint root component (#2095)
We implicitly export the last component of a .slint file to the generator.
Issue a warning when that happens and suggest to export it explicitly.
2023-01-23 15:19:49 +01:00
Tobias Hunger
d6e5a3ea54 online editor: Treat failure to load files gracefully
Pretend the file was empty when it failed to load. This stops the LSP
from blocking in some error cases, e.g. in the Printerdemo when reading
fonts.
2023-01-20 18:27:11 +01:00
Tobias Hunger
afdd450d86 vscode: Fix some lints 2023-01-20 18:27:11 +01:00
Tobias Hunger
c79cd21baf LSP: Support highlighting via call-out into javascript
This adds a new "preview-api" feature so that this can be turned on in
WASM without dragging in lots of extra dependencies:-/
2023-01-20 18:27:11 +01:00
Tobias Hunger
f0b4bce3d6 janitor: Make LSP clippy clean 2023-01-16 14:42:36 +01:00
Tobias Hunger
e456008c8e lsp: Fix document symbols not working
This changes how the selection range is picked: Instead of using the
`QualifiedName` of the root element, look at the Component's
`DeclaredIdentifier`.

This fixes component declarations without `inherits` clause and is also
nicer than the old approach: We would use the Component id as a name of
the DocumentSymbol and set the inherited type name as selection range.
2023-01-12 17:01:11 +01:00
Tobias Hunger
303b8f7c9d lsp: Update unit tests to new slint syntax 2023-01-12 17:01:11 +01:00
Tobias Hunger
06657eb79a lsp: Improve text range selection on binding removal
Try to delete entire lines if possible. This way we do not keep empty
lines around anymore.
2023-01-11 17:38:15 +01:00
Tobias Hunger
81d605e5d6 lsp: Simplify (left|right)_extend
This is simpler than the previous version and will be easier to
reuse for line-wise deletion, too.

It does sacrifice indention level based (line-) comment splitting, but I
think that will not be missed...

Any comments up to a blank line _before_ a property will be considered to
belong to that property and any comment _after_ the property that starts
without a line break are part of a property now.

There is some extra magic to work when several properties are in the
same line: Basically all comments then refer to the following property.

Update tests accordingly...
2023-01-11 17:38:15 +01:00
Tobias Hunger
47dbfb5327 lsp: Extract code to find the property binding 2023-01-11 17:38:15 +01:00
Tobias Hunger
a9aea470fd lsp: Rename delete_range to selection_range
I want to eventually use that to highlight the text the property editor
will work on. That is not done yet though.
2023-01-11 17:38:15 +01:00
Tobias Hunger
f8f8373b54 lsp: Extract code deciding whether to list a property as editable
I plan to reuse this when removing a property binding.
2023-01-11 17:38:15 +01:00
Tobias Hunger
8760262b60
lsp: Be smarter when inserting bindings (#1990)
Find the elements indentation level and make sure the following property
is indented.

This is a simplistic though as it indents 4 spaces more than the
Element's indentation level.
2023-01-11 10:31:46 +01:00
Olivier Goffart
1cbd61145e WIP: pure qualifier for callback and functions 2022-12-22 00:26:27 -08:00
Olivier Goffart
8c70c6c906 LSP: heuristics to avoid matching the slint macro in comments or strings 2022-12-21 11:49:09 +01:00
Olivier Goffart
a55ed47fed vscode extension: polish the slint! macro integration
- Make the browser extention preview work
 - Enable the properties tab on rust files
 - Only call `offset_to_position_mapper` if the token is valid,
   otherwise we might get an error visible in the UI.
2022-12-20 06:40:33 -08:00
Olivier Goffart
3d171320e9 LSP: support the slint! macro within slint files 2022-12-19 09:13:58 -08:00
ogoffart
ce07d078ce Bump version number to 0.3.4 2022-12-16 09:36:15 +00:00
Tobias Hunger
cf9594483e
lsp: Do not panic on invalid property definitions
Minimal example to reproduce:

```
export Demo := Rectangle { Text { text: } }
```
2022-12-15 14:32:52 +01:00
Tobias Hunger
689e42b60c LSP: Sort document symbols based on text ranges
Otherwise the symbols might get shown in the wrong order in the outline
view.
2022-12-13 20:49:55 +01:00
Olivier Goffart
94bba83446 LSP: reply to the textDocument/prepareRename request 2022-12-13 16:23:26 +01:00
Olivier Goffart
4430b36623 LSP: Highlight and renaming of element id 2022-12-13 16:23:26 +01:00
Olivier Goffart
ed306acb12 LSP: don't panic when quiting when there is no preview
Ignore the error that quitting don't work if the preview event loop
hasn't been started.

We're quitting anyway
2022-12-13 16:23:26 +01:00
Tobias Hunger
27eaa50129 LSP: Make the OffsetMapper hold on to newline map
This allows the OffsetToPositionMapper to not have a lifetime and
prevents it from holding a reference to the DocumentCache.

This makes things a lot as the OffsetToPositionMapper does not block
other uses of the DocumentCache anymore!
2022-12-13 15:17:30 +01:00
Tobias Hunger
5d654a8e32 Revert "lsp: Report that we send progress information"
The LSP spec gave this as an example, I misread that to mean it is
required. Sorry for that.

This reverts commit 3c05dfe029.
2022-12-13 15:17:03 +01:00
Tobias Hunger
98378d891b LSP: Fail silently when a file is not known to the LSP
I would prefer to raise an error in that case, but VSCode will raise
havok when I do that!

Fixes: #1970
2022-12-12 13:01:04 +01:00
Tobias Hunger
4e3c8f52e7 tools: Prefix our custom LSP commands with "slint/"
Keep the global namespace clean!
2022-12-12 13:01:04 +01:00
Tobias Hunger
36ae662a64 lsp: Extend setBinding command to handle undefined properties
Extend the setBinding command of the LSP to also handle properties that
were declared but not defined yet.

This will enable us to add new properties (that were already declared
before).
2022-12-12 11:34:16 +01:00
Simon Hausmann
b38fe7c5f0 Clean up internal Exports struct
- Use deref instead of `.0` tuple access (looks neater)
- Provide a convenience find() function that also makes use of the sorting
2022-12-09 11:05:08 +01:00
Olivier Goffart
c05e63f9da Auto-completion of the new property keywords and functions 2022-12-08 10:14:54 +01:00
Olivier Goffart
c2895a44af Update syntax highlight for Functions and in-out things 2022-12-08 10:14:54 +01:00
Tobias Hunger
8fe09ca17a lsp: Fix LSP blocking when run from VSCode
GDB claims ther lsp is blocked on the mutex on stdout. So remove the
println! statement that caused this -- it should not be there in the
first place!
2022-12-07 16:42:33 +01:00
Olivier Goffart
dfdbc942f6 Split Expression::CallbackReference and Expresison::FunctionReference 2022-12-06 14:56:25 +01:00
Olivier Goffart
851a910e41 Parser: Parse functions 2022-12-06 14:56:25 +01:00
Tobias Hunger
ea24548ee2 lsp: Report progress on file load in WASM, too 2022-12-05 15:13:14 +01:00
Tobias Hunger
59380e8a25 lsp: Improve ProgressReporter API
Make finish() consume self.
2022-12-05 15:13:14 +01:00
Tobias Hunger
2c472a34ab lsp: Reset token on call to finish in ProgressReporter
We would send the end token twice otherwise as the Drop trait will send
an end report if none was sent before.
2022-12-05 15:13:14 +01:00
Tobias Hunger
3c05dfe029 lsp: Report that we send progress information 2022-12-05 15:13:14 +01:00
Simon Hausmann
11f46906a2 Centralize rust-version in Cargo.toml
Require 1.64 in the workspace and inherit the setting in package
Cargo.toml files.
2022-12-05 12:39:14 +01:00