Commit graph

1614 commits

Author SHA1 Message Date
Tobias Hunger
1c447db8ca lsp: Build without SourceFileInner::version()
... in preparation to removing that functionality.
2024-08-21 16:55:13 +02:00
Tobias Hunger
00c9c3eda6 lsp: Remove useless version check with WorkspaceEdits
The DocumentCache is used to generate a WorkspaceEdit from.
Then we validate that the WorkspaceEdit is referencing
the source file versions in the DocumentCache, without
any chance to update the DocumentCache in between.

That is useless, so get rid of this comparision again.
2024-08-21 16:55:13 +02:00
Tobias Hunger
0713a91b87 lsp: Make DocumentCache constructible from a TypeLoader
... while making sure we have all the extra information around that
we need to keep the DocumentCache snap-shottable.
2024-08-21 16:55:13 +02:00
Tobias Hunger
c9b4c8d665 lsp: Make DocumentCache source file version aware 2024-08-21 16:55:13 +02:00
Tobias Hunger
08f92bbe88 lsp: Use a custom CompilerConfiguration in DocumentCache
This is so that we have all the information necessary to
have a snop-shottable DocumentCache later.
2024-08-21 16:55:13 +02:00
Tobias Hunger
74338fcee5 lsp: Move DocumentCache into extra file
It gets too big :-)
2024-08-21 16:55:13 +02:00
Tobias Hunger
cc9d9af7a7 lsp: Use a LSP-specific SourceFileVersion 2024-08-21 16:55:13 +02:00
Tobias Hunger
0bb3ad14e2 live-preview: Collect data on the file version diagnostics apply for
Collect that data in the fallback callback function.
2024-08-21 16:55:13 +02:00
Tobias Hunger
c8952cc20f live-preview: Report document version number with diagnostics
... in the hope that VSCode will invalidate the diagnostics when they
apply to outdated versions:-)
2024-08-21 16:55:13 +02:00
Olivier Goffart
43c7f57b0f spawn_local: initialize the platform if not initialized before the call
Take the opportunity to refactor a bit the way the global platform or
context is accessed

Fixes: #5871
2024-08-21 13:26:04 +02:00
Olivier Goffart
686f5e43e2 Widget style: simplify -light/-dark handling
Instead of having all style duplicated and re-using a base, we just hack
into the funciton that queries the dark/light theme based on the style
suffix known at compile time.

This removes one of the problem that happens when trying to work on the
widget style with the extension, as it relies on include path hacks
2024-08-20 16:55:15 +02:00
Simon Hausmann
c25a03d6f7 C++: Make it possible to split up the C++ code generated for a .slint file
Add a COMPILATION_UNITS argument to slint_target_sources that defines into how many .cpp files to split up a .slint file. The new default is now one.
2024-08-20 15:53:24 +02:00
Olivier Goffart
3a59950751 Experimental support for named callback parameters
And use that in the lsp/ui implementation instead of comments.

This is only a parser support for now, the name is otherwise unused.
Hence I rather keep that experimental.
2024-08-19 14:10:01 +02:00
Olivier Goffart
9b71cf1a36 Math postfix member functions on numbers
Closes #5328
2024-08-15 14:52:13 +02:00
ogoffart
4dd7d96a28 Bump version number to 1.8.0 2024-08-15 12:44:46 +00:00
Tobias Hunger
0b99a3d023 live-preview: Use preferred size when requesting preview
Force the preview to preferred size when explicitly asking to
preview something.
2024-08-15 13:47:25 +02:00
Tobias Hunger
092ca597bb live-preview: Remove history navigation
We apparently do not want history-based navigation,
so remove the code supporting that again.
2024-08-14 16:05:24 +02:00
Simon Hausmann
a727d87796 CMake: Make it possible to override the scale factor
Co-Authored-By: Olivier Goffart <olivier.goffart@slint.dev>
2024-08-14 11:00:50 +02:00
Tobias Hunger
013c687296 lsp: Replace common::UrlVersion with SourceFileVersion
The compiler defines `SourceFileVersion`, let's use that consistently.
2024-08-14 10:49:37 +02:00
Tobias Hunger
1639274486 slintpad/vscode: Get rid of the shared files
Theyre are no more shared files, so move the files
into vscode and set up a syntax check over there.

That was not possible before as the typescript
compiler would error out on the shared files being
outside its root directory.
2024-08-12 12:45:59 +02:00
Tobias Hunger
a394921479 lsp: Treat EoF as whitespace when looking for non-ws
... tokens.

Fixes: #5695
2024-08-09 12:19:03 +02:00
ogoffart
bbf7edc5a3 Bump version number to 1.7.2 2024-08-09 09:52:17 +00:00
Tobias Hunger
eb1c1b9829 live-preview: Compile-test all edits before sending them out
This fixes #4872 and probably more similar issues.

Fixes: #4872
2024-08-09 10:44:59 +02:00
Tobias Hunger
8c8719e79d live-preview: Simplify code setting properties
Now that the properties are only used in the live preview,
we can simplify the code a bit.

This gets rid of some sanity checks in the code path as well,
which in turn should fix #5696.

Fixes: #5696
2024-08-09 10:44:44 +02:00
Tobias Hunger
b62eb85dd6 live-preview: Do not make property data serializable
It's not going to be sent to editors anymore, so no
need for that.
2024-08-08 17:58:59 +02:00
Tobias Hunger
2ab6a10cbb live-preview: Take note that the UI was opened
This makes the entire thing so much more responsive
as most events are just ignored when the window is closed.
2024-08-08 17:11:20 +02:00
Olivier Goffart
944af60c35 LSP: goto definition for re-exports
drive by fix goto definition of properties with underscores noticed
while writing the test.
2024-08-08 16:57:31 +02:00
Tobias Hunger
4e68aa1510 lsp: Remove custom commands for property handling
These commands are not needed anymore since we integrated
the property editor into the live preview.

Move the properties code out of `common` and into `preview`
for good measure.
2024-08-08 16:39:37 +02:00
Olivier Goffart
21e67e27a7 LSP: Report error through the LSP when the preview can't open
Instead of panicking the whole server

Issue #204
2024-08-08 12:05:52 +02:00
Olivier Goffart
3c08a71d21 LSP: refactor error reporting of request
So we have accurate error code reported to the LSP when a request fails
2024-08-08 12:05:52 +02:00
Olivier Goffart
6f51c975f5 LSP: don't answer "Empty" for component that do not inherit
... instead of chekcing for "Empty" in the Slint code

Do the suggestion from https://github.com/slint-ui/slint/pull/5625#issuecomment-2228976684
2024-08-08 12:05:29 +02:00
Olivier Goffart
8b38825734 LSP completion: don't auto-complete function or private properties for bindings 2024-07-25 22:40:30 +02:00
Olivier Goffart
cf88676a18 LSP: fix renning the tests without the preview feature 2024-07-25 22:40:30 +02:00
Olivier Goffart
4c0bfa269d LSP: refactor send_notification to use the Notification trait
This ensure there is no typo in the method name
2024-07-23 14:18:39 +02:00
ogoffart
aa25e3cd44 Bump version number to 1.7.1 2024-07-23 12:05:34 +00:00
Olivier Goffart
ebc5193647 LSP: properties: filter accessible-action-* callbacks from the property list
Callbacks can't be in the property list anyway, and setting their values assert
later in the checking code.

Fix #5652
2024-07-22 15:24:01 +02:00
Tobias Hunger
dacc57648b live-preview: Unbreak layout detection
Return the element's "layoutness" when no child insertion point was found in
the element. This fixes droping elements into normal layouts.
2024-07-22 13:07:12 +02:00
Olivier Goffart
5acc7dd42a Live-preview: Prospective fix for panic when moving a component
We were trying to convert a node to a wrong kind of node.
Then of course it didn't have the expected children

In debug mode you'd have
```
assertion `left == right` failed
  left: SubElement
 right: Component
```
from the debug_assert! in `$Node::from`

I changed the call to `.into` to a call to `$Node::new` that return an
option.

Also made the debug_assert into an assert and added track_caller so such
problem are easier to debug in the future. (Retrospectively, we probably
shouldn't have derived From for $Node)

Fix #5642

The change contains no tests because the is_recursive_inclusion function
is currently not tested and would need some effort to create a test
2024-07-20 01:17:53 +02:00
Tobias Hunger
daae440da7 live-preview: Prettify showing of library components in library view 2024-07-19 12:25:10 +02:00
Tobias Hunger
63e0a9cc2a live-preview: Allow for dropping library components 2024-07-19 12:25:10 +02:00
Tobias Hunger
ce1ff534ba live-preview: Improve how libraries are shown in the component list 2024-07-19 12:25:10 +02:00
Tobias Hunger
7bbe2a949a live-preview: Recognize GridLayouts as layouts and find layouts in components
... when deciding whether or not we are dropping into a layout or not.
Components that take @children (like a GroupBox) were misrecognized before.

This is a bit tricky as the optimized Elements do not allow to find out whether
something had a child insertion point. So I need to convert over to the
unoptimized Element found in my `document_cache`.

Unfortunately there the lowering pass for the layouts has not been done yet,
so my "normal" approach to figuring out whether something is a layout or not
does not work anymore:-/

I ended up duplicating the logic of the layout lowering step: Match specific
type names for Builtin types. That's not nice and should be cleaned up at
some point.
2024-07-19 11:48:28 +02:00
Tobias Hunger
2c4d4e89b7 lsp: Remove Popups, Dialogs and PopupWindow from list of components
I do not expect those to be dragged onto the canvas with meaningful results.
2024-07-19 10:23:58 +02:00
Tobias Hunger
3f41b6f69d live-preview: Make component selection more robust
... by not relying on the component name, which could be used in several
files.
2024-07-17 17:52:12 +02:00
Tobias Hunger
11b0b75e71 live-preview: Fix drops being off by several (hundred!) pixels at times
We did not take the scroll view being scrolled into account, so the drop
location was off by a bit, especially for elements shown far down the list.
2024-07-17 17:16:50 +02:00
Tobias Hunger
f9320b4aff live-preview: Low-hanging fruit in the Property editor
* Resizing the key field works again (using an invisible hand-crafted splitter)
* The color of the active/inactive `f(x)` icon was inversed as suggested by
  Daniel.
2024-07-16 18:27:47 +02:00
Tobias Hunger
3733070c33 live-preview: Remove the functionality to add components 2024-07-16 14:20:46 +02:00
Tobias Hunger
a85a1cdca1 live-preview: Disable switching between Components
Disable switching components by clicking on the component name in the
library.
2024-07-16 14:20:27 +02:00
Tobias Hunger
a384d957b4 live-preview: Disable the Component Label
It is too ugly and since we can no longer add components, it is not absolutely
necessary to rename comoponents either.
2024-07-16 14:20:13 +02:00
Tobias Hunger
ab4ba0f164 live-preview: Only allow one workspace edit to be active at a time
Stop several changes to a version of a text file to be bunched up, ending
in several contradictory edits to the same file.
2024-07-16 13:04:06 +02:00