Commit graph

209 commits

Author SHA1 Message Date
Tobias Hunger
d7372a0b37 lsp: Telemetry for panics
Make the extension set SLINT_LSP_PANIC_LOG_DIR (instead of setting a file).
Have the Lsp/live preview create panic logs in that folder as panics happen.
Make the extension watch that folder and upload any file it sees getting created there
Delete the file after upload
2025-07-28 17:13:15 +02:00
Tobias Hunger
5dc9ce5204 LSP: Start external process for live preview
Start the live preview in a separate process. This simplifies
a couple of things:

* Starting the UI
* UI state handling
* Threading setup
* "Quitting" the preview on Mac

... and many more :-)
2025-07-28 17:13:15 +02:00
Tobias Hunger
f6a4d5c0a7 live-preview: Move the LSP/live preview communitation out or preview
... and into preview/connector.

This is just a intermediary step to separate them even more strongly from
each other.
2025-07-28 17:13:15 +02:00
Olivier Goffart
1b6b608d41 LSP: add a comment explaining the meaning of the SLINT_LSP_PANIC_LOG env variable
Some checks are pending
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (macos-13) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.85) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
2025-07-01 17:01:21 +02:00
Tobias Hunger
24e24df737 live-preview: Send telemetry to VSCode
Send telemetry data from the live-preview to vscode.

It will process that data according to telemetry settings in VScode
2025-05-09 19:18:27 +02:00
Simon Hausmann
44a1bec608
Disable jemalloc for slint-lsp/slint-viewer/slint-compiler on aarch64… (#8136)
With jemalloc the page size is a compile time constant that results in
the process aborting on memory allocation if the compile time determined
page size does not match the kernel reported page size at run-time.

When we, or our users, compile the above programs for aarch64-linux,
there is a fair expectation that the resulting binary works on any
aarch64-linux system. As we can't determine the target page size
reliably, disable jemalloc.

Fixes #8134
2025-04-14 15:03:36 +02:00
Simon Hausmann
b625ad9722 Disable jemalloc on Windows
Upstream isn't even compile-testing on Windows ( https://github.com/tikv/jemallocator/blob/main/.github/workflows/main.yml ), so we should disable it as well.

This should fix the build failing with mingw.
2025-03-05 14:24:27 +01:00
Tobias Hunger
33928e4958 lsp: Do not send status nmessages
Nigel says those are annoying as they tend to overstay
their welcome.
2025-02-11 11:29:01 +01:00
Yuri Astrakhan
5356fdcf89 Fix clippy issues, plus a few manual cleanups
* Run `cargo clippy --fix`
*  `BackendSelector` is easier to instantiate with auto `Default`
2025-02-06 17:28:51 +01:00
Yuri Astrakhan
61de4d56b0 Fix all format arg inlining
Ran this command:

```shell
cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2025-02-06 10:16:20 +01:00
Milian Wolff
18300429c1
Use jemalloc for slint-viewer, slint-compiler, and slint-lsp
* optimize: use jemalloc for slint-viewer

The lots of allocations are slowing down slint-viewer.
By using the faster jemalloc, we get a significant time boost
on Linux at least,  where I can observe a 15% time reduction:

Before:
```
  Time (mean ± σ):     936.6 ms ±  13.5 ms    [User: 688.8 ms, System: 191.1 ms]
  Range (min … max):   918.9 ms … 955.6 ms    10 runs
```

After:
```
  Time (mean ± σ):     794.8 ms ±  16.2 ms    [User: 645.4 ms, System: 99.2 ms]
  Range (min … max):   755.0 ms … 810.7 ms    10 runs
```

* optimize: also use jemalloc for slint-compiler

As with the slint-viewer, we can observe a drastic time improvement
of around 13% when using jemalloc for slint-compiler:

Before:
```
  Time (mean ± σ):     772.8 ms ±   9.2 ms    [User: 633.5 ms, System: 136.5 ms]
  Range (min … max):   763.3 ms … 787.8 ms    10 runs
```

After:
```
  Time (mean ± σ):     672.5 ms ±  13.5 ms    [User: 610.4 ms, System: 60.1 ms]
  Range (min … max):   655.1 ms … 700.7 ms    10 runs
```

* optimize: also use jemalloc for slint-lsp

The impact here was not measured, but it should be in a similar
ballpark to the slint-compiler and slint-viewer, and thus quite
noticeable in practice.
2025-01-25 17:40:33 +01:00
Olivier Goffart
57f42c0870 LSP: Submit the full backtrace to the crash reporter 2025-01-10 23:23:43 +01:00
Tobias Hunger
b7e1fb9d18
lsp: Offer to populate empty documents (#4767) 2024-12-11 19:33:24 +01:00
Tobias Hunger
b0fe8d6cfb live-preview: Handle document deletion better 2024-11-27 18:04:54 +01:00
Olivier Goffart
e44f7d7a4c LSP: fix reloading loaded dependencies
The change in https://github.com/slint-ui/slint/pull/6747
invalidated the cache, but it was only reloaded when one of the dependent was reloaded.
We need to reload the cache for all open file so that LSP feature continue to work on
open document even if they get no changes
2024-11-26 14:27:56 +01:00
Tobias Hunger
041d2ae73e lsp: Remove some unnecessay lines 2024-10-15 16:55:30 +02:00
Tobias Hunger
5519efcd5a lsp: Use constant instead of repeating a slint/showPreview 2024-10-15 16:27:41 +02:00
Tobias Hunger
3d3bf9f01b lsp: Pass invalidation of files on to live-preview 2024-10-10 09:31:11 +02:00
Tobias Hunger
e62d9e0695 lsp: Remember which files are open in the editor
... and ignore them on file change notifications: The
Editor manages the file content, so we do not need to
care for the on-disk content for these files.
2024-10-10 09:31:11 +02:00
Tobias Hunger
d87833a6bd lsp: Add a filesystem watch request to our LS
Get a notification of any file change/deleteion. This feels like
overdoing it a bit, but we need to reload when resources change
and those can be anything.
2024-10-10 09:31:11 +02:00
Tobias Hunger
41bdadd960 live-preview: Add a CodeButton component
... and use it in places
2024-09-17 18:39:37 +02:00
Simon Hausmann
66df25443b live-preview on macOS: Fix ever bouncing icon and re-add a quit item
We need to do the platform init only when we intend to soon thereafter show a window.

Re-added a Quit item that merely hides the UI, so CMD+Q kind of works for convenience.

Fixes #5994
2024-08-29 11:51:59 +02:00
Simon Hausmann
6472ab8416 Re-add standard macOS app menu but without quit item
... so cmd+q won't terminate the preview, but there's still the usual system menu bar.
2024-08-28 21:24:42 +02:00
Simon Hausmann
16f47eac7d Disable the macOS system menu bar for the Slint Live-Preview
Fixes #5962
2024-08-28 21:24:42 +02:00
Olivier Goffart
45a9c7235a vscode: report LSP panic as telemetry error
We write the panic message in a file to communicate with the vscode
extension
2024-08-27 11:10:09 +02:00
Tobias Hunger
0f0b76e952 lsp: Clippy fixes 2024-08-23 18:58:44 +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
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
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
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
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
Tobias Hunger
bc35d49328 lsp: Remove UpdateElement Preview-to-LS-message
We can do that inside the Live preview now and just return the
WorkspaceEdit.
2024-06-25 19:51:59 +02:00
Tobias Hunger
9afb3812bf lsp: Move properties.rs into common 2024-06-25 19:51:59 +02:00
Tobias Hunger
3e117c1910 lsp: Modernize properties.rs
... to prepare moving it into common.
2024-06-25 19:51:59 +02:00
Tobias Hunger
c335ac9202 janitor: Allow "clippy::await_holding_refcell_ref" in tools/lsp
There is no way we can avoid that RefCell being held, so quieten
the wrrning.
2024-06-24 14:59:47 +02:00
Tobias Hunger
d657ee65af live-preview: Handle known components using our local DocumentCache 2024-06-12 10:15:29 +02:00
Tobias Hunger
fccb4de8a0 lsp: Move PreviewConfig out of DocumentCache 2024-06-12 10:15:29 +02:00
Tobias Hunger
a759fa72d2 lsp: Move DocumentCache into common 2024-06-12 10:15:29 +02:00
Aurindam Jana
3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00
Aurindam Jana
9a3aa265d5
Update Royalty-free license (#5257)
Add clarification that Application may not expose Slint APIs.
2024-05-31 10:53:19 +02:00
tmpod
6e7353cf11 Implement -L flag for the LSP tool, similar to the viewer
You can pass `-L foo=/path/to/foo` to add `@foo` as a library when
starting the LSP server.

Closes #5144
2024-04-29 14:59:51 +02:00
Aurindam Jana
0cfeec1a31
Update Slint Community License (#4994)
Updated the version from 1.1 to 1.2 
Renamed the header to "Slint Royalty-free Desktop, Mobile, and Web Applications License"
Added definition of "Mobile Application" and grant of right
Moved "Limitations" to 3rd section and "License Conditions - Attributions" to 2nd section
Added flexibility to choose between showing "MadeWithSlint" as a dialog/splash screen or on a public webpage
Moved the para on copyright notices to section under "Limitations"
2024-04-15 15:18:55 +02:00
Tobias Hunger
7ec5f783f5 live preview: Fix WASM preview talking to native LSP
We created a `ServerNotifier`, cloned that and passed one copy
on to the `CompilerConfiguration` so that imports would notify the
preview.

Unfortunately that does not work: That clone never gets told to
switch over to the WASM preview and will always try to update the native
preview instead.

So make sure the information which preview is used gets
synchrnoized to all clones using an atomic bool and an Arc...

Fixes: #4764
2024-03-18 19:36:17 +01:00
Tobias Hunger
3ba59dad46 lsp: Use ElementRcNode when handling properties
We recently got better support for inlined elements. Use
The `ElementRcNode` when accessing properties, so that
we can actually have a better idea which SyntaxNode we
need to work on.

This is actually not too critical as the LSP does little
inlining, but I wanted to reuse this on the preview side
as well, which does inlining much more aggressively.

Do NOT access properties in the live preview though:
It is heavily optiomized, so most properties are just
gone there;-)
2024-03-05 13:10:41 +01:00
Tobias Hunger
3ad3a42656 live preview: Do import handling in drop_location
Remove the AddComponent and the AdjustSelection messages
from the communication between LSP and preview.

Also remove the code to delete an element.
2024-03-01 18:54:40 +01:00
Tobias Hunger
a0b862b096 live preview: Delete an element again
* Refactor the code a bit: Move element edit functions
  into the `element_edit` module below `language`
2024-02-28 15:53:49 +01:00
Olivier Goffart
a3c99555a0 LSP: fix compilation without the preview features
Use the format test to test this compilation
2024-02-26 11:14:02 +01:00
Tobias Hunger
08372e5a07 live preview: Implement resizing and moving of selected eleement
Much polish needed, but it is a basis to build upon.
2024-02-19 22:27:32 +01:00
Tobias Hunger
5d13878e68 lsp: Simplify sending messages from preview to lsp
... in native mode,

Have the channel between the two transport
`PreviewToLspMessages` directly instead of wrapping
those into `Notifications` of the language server
protocol.

Unformtunately the notification code eneds to stay in
place, as that is what the WASM preview uses to talk
to a native LSP.

I did nto unify wasm and native handling of the
`PreviewToLspMessage`s: The different async runtimes
we need to integrate with got into the way.
2024-02-13 17:03:58 +01:00