Commit graph

63 commits

Author SHA1 Message Date
Olivier Goffart
b23f8ad997
Parse: accept changed callback without brace
For consistency with the normal callbacks
2025-08-29 14:49:47 +02:00
Olivier Goffart
b80d5a2304 Fix compilation error
Some checks are pending
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-embassy (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (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 / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.82) (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 / 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
... after the merge of two PR that conflicted with eachother
2025-06-26 16:13:42 +02:00
Avery Townsend
d2a5ae03dc
Add local variables (#8740)
Fixes: #2752

ChangeLog: Added local variable with `let`
2025-06-26 15:36:49 +02:00
Tobias Hunger
d0b58760d3 chore: A few clippy fixes
Nothing systeamatic, just a bunch of fixes I stumbled over
during unrelated work.

No behavior change is intended in here...
2025-05-09 13:25:38 +02:00
Yuri Astrakhan
bcb2953f00 Auto-fixed clippy::unnecessary_map_or
This is a hacky approach, but does help a lot with the tedious fixes.

See https://rust-lang.github.io/rust-clippy/master/index.html#/unnecessary_map_or

```
__CARGO_FIX_YOLO=1 cargo clippy --fix  --all-targets --workspace --exclude gstreamer-player --exclude i-slint-backend-linuxkms --exclude uefi-demo --exclude ffmpeg -- -A clippy::all -W clippy::unnecessary_map_or

cargo fmt --all
```
2025-02-07 09:02:31 +01:00
Olivier Goffart
10510be232 LSP: Document symbol: make sure the selectionRange is contained in the full range
Otherwise we get a lot of error in vscode such as:

```
Error: selectionRange must be contained in fullRange
	at Gd.validate (file:///snap/code/178/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:109:33728)
	at new Gd (file:///snap/code/178/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:109:33936)
	at Ke (/home/olivier/.vscode/extensions/slint.slint-nightly-2025.1.109/out/extension.js:35:72279)
	at Ke (/home/olivier/.vscode/extensions/slint.slint-nightly-2025.1.109/out/extension.js:35:72456)
	at o (/home/olivier/.vscode/extensions/slint.slint-nightly-2025.1.109/out/extension.js:35:46654)
	at Object.$P [as map] (/home/olivier/.vscode/extensions/slint.slint-nightly-2025.1.109/out/extension.js:35:46740)
	at Object.Se [as asDocumentSymbols] (/home/olivier/.vscode/extensions/slint.slint-nightly-2025.1.109/out/extension.js:35:72246)
	at c (/home/olivier/.vscode/extensions/slint.slint-nightly-2025.1.109/out/extension.js:39:56055)
	at async uI.provideDocumentSymbols (file:///snap/code/178/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:138:126457)
[Error - 11:41:30 AM] Request textDocument/documentSymbol failed.
```

We shouldn't need to trim the whitespace from the node range.
Because the selected range might be the end of the range and it might
end up being trimmed.

In normal cases, whitespace are not part of the Node anyway
2025-01-06 10:47:05 +01:00
Milian Wolff
0f6c3a4fd7 Use SmolStr in more places of the compiler infrastructure
This removes a lot of allocations and speeds up the compiler step
a bit. Sadly, this patch is very invasive as it touches a lot of
files. That said, each individual hunk is pretty trivial.

For a non-trivial real-world example, the impact is significant,
we get rid of ~29% of all allocations and improve the runtime by
about 4.8% (measured until the viewer loop would start).

Before:
```
Benchmark 1: ./target/release/slint-viewer ../slint-perf/app.slint
  Time (mean ± σ):     664.2 ms ±   6.7 ms    [User: 589.2 ms, System: 74.0 ms]
  Range (min … max):   659.0 ms … 682.4 ms    10 runs

        allocations:            4886888
        temporary allocations:  857508
```

After:
```
Benchmark 1: ./target/release/slint-viewer ../slint-perf/app.slint
  Time (mean ± σ):     639.5 ms ±  17.8 ms    [User: 556.9 ms, System: 76.2 ms]
  Range (min … max):   621.4 ms … 666.5 ms    10 runs

        allocations:            3544318
        temporary allocations:  495685
```
2024-10-17 18:04:58 +02:00
Tobias Hunger
af9115919a lsp: Add a test for the TextRange to Range conversions 2024-08-26 14:51:47 +02:00
Tobias Hunger
1a306dd155 live-preview: Use TextRange and TextSize in property information
The Properties are no longer sent out straight to the editor, so
we do not need to convert our internal `TextRange` and `TextSize`
to `lsp_types::Range` and `lsp_types::Position`.

We are noweadys turning that straight back into offsets -- which is
just another name for `TextSize` (or pairs of offsets).
2024-08-23 18:58:44 +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
Tobias Hunger
74a8779e9c live-preview: Add a property editor 2024-06-28 10:58:45 +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
67200c81ff live-preview: Compile-test element moves in can_move function
Compile test the result of an element move in the `can_move` function
to catch all cases where the move would be problematic.

Shuffle some test code around to allow for testing this new
functionality.
2024-06-14 16:59:39 +02:00
Tobias Hunger
6c034372a1 lsp: Encapsulate DocumentCache better
The Document cache is a specialized typeloader now, make it provide the
necessary APIs directly, so that we can be sure nobody will do anything
that breaks the data:-)
2024-06-12 10:15:29 +02:00
Olivier Goffart
8add2e4ebd element_ids: Can't return a SharedString by value from the vtable
also compile the LSP
2024-06-05 01:29:58 -07:00
Olivier Goffart
b80f4552bd LSP auto-completion: suggests unimported globals in expressions
For example, propose to auto-complete Palette and add the import
statements from std-widgets
2024-06-01 10:08:17 +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
Tobias Hunger
fb936179cc lsp: Do not map trailing whitespace tokens then mapping node ranges
This fixes highlighting of e.g. component type names to not include the
trailing WS.
2024-05-08 15:42:11 +02:00
Tobias Hunger
3d34c3be6d live-preview: Move already placed elements
Allow to move already placed elements in Design Mode of the live preview.

Todo: GridLayout is not supported yet.
2024-04-29 22:50:29 +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
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
Olivier Goffart
b9db28bc72 LSP: fix completion in two ways bindings 2024-02-29 11:11:47 +01:00
Tobias Hunger
171c9e215a live preview: Drop elements into layouts (MVP!)
This is the minimum layout support: It drops elements
into a layout right before the layout's closing brace.
2024-02-26 22:19:29 +01:00
Tobias Hunger
50ba317a3c live preview: Drop unused function that got duplicated 2024-02-23 09:12:10 +01:00
Olivier Goffart
fac0921579 Compiler: keep the layout debugging info next to its node 2024-02-21 11:33:37 +01:00
Tobias Hunger
f53a051114 live preview: Fix moving of elements
The positioning needs to happen relative to the position
of the parent element, not using global coordinates.
2024-02-20 14:04:31 +01:00
Tobias Hunger
67c6f1ba48 live preview: Indent inserted elements (better) 2024-02-13 21:19:25 +01:00
Olivier Goffart
09dc25f107 Keep all nodes for a given element (even if it is optimized out) 2024-01-25 14:45:22 +01:00
Olivier Goffart
7b3d96368b LSP: Fix error when going to the definition of builtin items
Instead of returning an "invalid:/" URL for the builtins, we should just
return a None result from the goto definition function.

Also add a test for goto_definition

Fixes #4126
2023-12-19 16:16:19 +01:00
Tobias Hunger
b12c35d877 LSP: Improve automatic insertion of import identifiers on completion
Insert before the last whitespace. Adding Bar into `import { Foo } from
"..."` looks like this:

```slint
import { Foo , Bar} from "..." // old
import { Foo, Bar } from "..." // new
` ``
2023-12-11 08:29:42 +01:00
Tobias Hunger
4dda627d14 LSP: Move code around
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.
2023-08-28 13:34:35 +02:00
Tobias Hunger
89a2e34c9e lsp: Extract some types out into a new common location
These are types I want to use to separate the previewer and the LSP part
more cleanly going forward.
2023-08-24 17:14:54 +02:00
darknight
879438a27a auto complete for animate block 2023-08-24 07:32:37 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
Tobias Hunger
8345c6cd79 Do automatic clippy fixes 2023-06-28 14:22:30 +02:00
Olivier Goffart
11dea135f7 Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
Aurindam Jana
039e54a5de
Add royalty free license to files except examples and docs (#2888) 2023-06-15 11:20:50 +02:00
Olivier Goffart
abbba8cbe8 LSP: fix completion of function arguments 2023-05-03 09:09:01 +02:00
Olivier Goffart
5c4a1746d4 LSP: fix completion of callback arguments 2023-05-03 09:09:01 +02:00
Olivier Goffart
7d78bd2dcd LSP: fix the lookup scope
And add a test for the completion
2023-05-03 09:09:01 +02:00
Tobias Hunger
bb67122a50 LSP: Remove offset to position mapper 2023-05-02 15:12:01 +02:00
Olivier Goffart
208d89c1de LSP: Don't auto-complete reserved properties or sub-elements for globals 2023-04-05 20:05:09 +02:00
Tobias Hunger
3ac01c3f07 clippy: Fix clippy warnings 2023-03-09 09:35:29 +01:00
Tobias Hunger
edd4e81033 lsp: Add setBinding custom command 2022-11-21 15:01:09 +01:00
Olivier Goffart
d02d1bf88f lsp: fix range in properties
The comment says that the LSP protocol needs a +1/-1, but that's not the
case, and the vscode conversion function don't have that.
So remove that -1.

This fixes the property edition in the property view in vscode
2022-11-17 20:02:39 +01:00
Tobias Hunger
5e0f90e325 lsp: Report actual property value text in queryProperties 2022-11-11 19:44:08 +01:00
Olivier Goffart
28ae8f7bc4 Refactoring: split ElementType away from the types used as property type
These are two different concept, and it is confusing to keep them in the
same enum

We want to support component without any base element, and Void is
already used for global component, so do this refactoring before
2022-10-26 14:50:44 +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
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