Commit graph

67 commits

Author SHA1 Message Date
Simon Hausmann
de81fa1dba CI: Fix build with nightly and -D warnings
Add life-time annotations as recommended by the compiler to clarify
the flow of life times of arguments to the output.
2025-06-06 11:38:50 +02:00
Tasuku Suzuki
83db461f63
Transition: Introduce in-out to allow writing symmetry animation (#8509) 2025-05-26 09:17:22 +02:00
Tobias Hunger
63f7533dc9 compiler: Fix identifier normalization function
`__1` is a valid identifier, which we normalized to
`--1`, which is invalid.

This changes the nromalization function to leave a `_` in the first position.
2025-05-21 12:21:20 +02:00
Yuri Astrakhan
9621cae218 Auto-fixed clippy::needless_lifetimes
`__CARGO_FIX_YOLO=1` is a hack, but it does help a lot with the tedious fixes where the result is fairly clear.

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

```
__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::needless_lifetimes

cargo fmt --all
```
2025-02-07 09:20:49 +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
Tobias Hunger
cfb2324526 lsp: Rename structs and enums
... but only when directly on the name of the struct
when it is declared.
2025-01-07 16:18:46 +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
Olivier Goffart
4718d5b050
Fix invalid node generated while parsing invalid @tr (#6560)
Fixes #6512

The TrPlural must always have an expression otherwise it panics later.
(Also adjust the panic message when nodes are missing)
2024-10-15 10:23:56 +02:00
Olivier Goffart
8ac0c792e8 Update derive_more 2024-09-26 09:14:58 +02:00
Tobias Hunger
bacae03919 compiler: More wrappers around rowan methods
... in SyntaxNode and SyntaxToken.

And do a small code cleanup enabled by this.
2024-08-28 18:02:47 +02:00
Tobias Hunger
d28b13cbe5 lsp: Remove explicit rowan dependency from LSP
... by implementing more helpers on `parser::SyntaxNode` and
`parser::SyntaxToken`.
2024-08-26 14:51:47 +02:00
Tobias Hunger
45c24803f2 compiler: Remove version info from SourceFile again
... and fix the fallout of that change.
2024-08-21 16:55:13 +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
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
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
Olivier Goffart
5dfa8d56dc API review of the slint interpreter Compiler api
Closes #5466
2024-07-05 17:20:08 +02:00
Olivier Goffart
66370b6bda
Add export { ... } from "....slint"; syntax. (#5533) 2024-07-03 12:50:40 +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
d852e42431 compiler: Add ConditionalElement as a possible child of Element
It's not critical, but nice to have this option documnted (and the code
to find all `ConditionalElement`s generated).
2024-05-27 16:53:22 +02:00
Tobias Hunger
2e3b00e38e janitor: Fix some clippy warnings pre-release
Nothing that should be controversial, but the
`internal/compiler/builtin_macros.rs` could point to a thinko in the original
commit.
2024-05-06 16:47:14 +02:00
Olivier Goffart
32bf6608e9 Parse changed callbacks 2024-05-02 22:25:53 +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
28b96ca6f6 janitor: manual cargo clippy fixes
Semi-random selection of clippy topics that were
uncontroversial before:-).

Leaves about 84 deduplicated issues in the code base
according to clippy from nightly.
2024-03-14 13:42:38 +01:00
Tobias Hunger
a8f912900b janitor: Fix warnings in nightly about redandant use 2024-02-19 17:05:21 +01:00
Olivier Goffart
6e2280ece3 Parse 9slice in @image-url 2024-02-13 14:46:27 +01:00
Tobias Hunger
d785f2d5df compiler: Store an optional version number with the document
A None value means the file on disk is the golden version.

We have an editor, the LSP and the preview that all need to at least
notice when they have newer data then their peers. So IMHO it makes
sense to have an optional document version around.

The language server protocol makes use of a version number already. This
patch moves that code into the compiler so that it is stored with the
actual data getting versioned.
2023-12-18 14:21:50 +01:00
Tobias Hunger
b5c433dada janitor: Fix build warning about DefaultParser 2023-11-02 10:17:59 +01:00
Tobias Hunger
0ff8e2cdb6 compiler: Rework path handling
Add some code to do platform-independent path processing.

This is necessary aas WASM does e.g. not have any absolute paths and
such and the compiler tended to produce wrong results in that case.

Side-effect: We no longer need to depend on `dunce`
2023-10-10 20:04:47 +02:00
J-P Nurmi
8284674d4d VSCode: add "Remove element" code action 2023-09-08 16:38:16 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
Olivier Goffart
fdec5960bd Support for @rust-attr on enums 2023-06-19 22:40:49 +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
72de76b71a Documentation for enums 2023-06-12 13:02:14 +02:00
Olivier Goffart
ac6f473a64 WIP: support for enum in slint
Parser and interpreter part
2023-06-12 13:02:14 +02:00
Olivier Goffart
12e6b34e2d Translations: support for plurals 2023-06-07 10:34:34 +02:00
Olivier Goffart
e97a2e8229 Translations: support context 2023-06-06 14:48:48 +02:00
Olivier Goffart
dcd8450dfa WIP: start working on translations: @tr()
This commit just do the parsing of the @tr macro.
2023-06-05 16:34:59 +02:00
Amirhossein Akhlaghpour
3a4f3c61d5
Add @rust-attr on scturct (#2785)
Fixes: #2660
2023-06-05 16:29:55 +02:00
Tobias Hunger
bb67122a50 LSP: Remove offset to position mapper 2023-05-02 15:12:01 +02:00
Tobias Hunger
43aae1de1c Interpreter: Include the id := in Elements
Include the "id :=" part when highlighting an Element. This places the
cursor at the 'i' now.

Done-with: @ogoffart
2023-04-26 20:49:12 +02:00
Tobias Hunger
bbdd6aeab7 compiler: Ignore leading whitespace when parsing
... and update all out test cases accordingly.
2023-04-26 17:22:13 +02:00
Olivier Goffart
7ef9d9b7ec LSP: complete the first import right before the first component
So this doesn't break the slint! macro (add the import at the beginning
of the rust file)
2023-04-19 17:19:55 +02:00
Olivier Goffart
a7b8bafdf9 Ensure completion in the document in case of parse error or empty document
Every token must be part of a document, including the EOF,
otherwise completion don't work at the end of the document.
2023-04-17 07:58:18 +02:00
Tobias Hunger
3ac01c3f07 clippy: Fix clippy warnings 2023-03-09 09:35:29 +01:00
Olivier Goffart
4f00f268a5 Make the old syntax a warning 2023-02-14 12:38:39 +01:00
Olivier Goffart
4cf6690e5a syntax_updater: also parse slint,no-preview code block in md files
This include a fix to make sure the diagnostics has access to the
sources even if there is no path
2023-01-07 14:18:10 +01:00
Olivier Goffart
a0d057b8b8 Enable the new syntax by default 2023-01-07 14:18:10 +01:00
Simon Hausmann
03fe599890 Add support for re-exporting modules
Use `export * from "somewhere.slint"` to avoid having to repeat all the
types of an existing module in order to re-export all of the types.
2022-12-09 11:05:08 +01:00