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.
This commit is contained in:
Simon Hausmann 2023-01-23 15:19:49 +01:00 committed by GitHub
parent 33d68687c2
commit 24dcef5fed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
130 changed files with 175 additions and 143 deletions

View file

@ -5,7 +5,7 @@ import { Carousel } from "carousel.slint";
import { Card } from "card.slint"; import { Card } from "card.slint";
import { Theme } from "theme.slint"; import { Theme } from "theme.slint";
component MainWindow inherits Window { export component MainWindow inherits Window {
private property<[{ title: string, image: image}]> navigation-items: [ private property<[{ title: string, image: image}]> navigation-items: [
{ title: "Settings", image: @image-url("svg/settings_black.svg") }, { title: "Settings", image: @image-url("svg/settings_black.svg") },
{ title: "Home", image: @image-url("svg/home_black.svg") }, { title: "Home", image: @image-url("svg/home_black.svg") },
@ -38,4 +38,4 @@ component MainWindow inherits Window {
clicked => { root.selected-index = index; } clicked => { root.selected-index = index; }
} }
} }
} }

View file

@ -1,6 +1,6 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
global GallerySettings { export global GallerySettings {
in property<bool> widgets-disabled: false; in property<bool> widgets-disabled: false;
} }

View file

@ -4,7 +4,7 @@
import { ScrollView, Button, CheckBox, SpinBox, Slider, GroupBox, LineEdit, StandardListView, import { ScrollView, Button, CheckBox, SpinBox, Slider, GroupBox, LineEdit, StandardListView,
ComboBox, HorizontalBox, VerticalBox, GridBox, TabWidget, TextEdit, AboutSixtyFPS } from "std-widgets.slint"; ComboBox, HorizontalBox, VerticalBox, GridBox, TabWidget, TextEdit, AboutSixtyFPS } from "std-widgets.slint";
component App inherits Window { export component App inherits Window {
preferred-width: 500px; preferred-width: 500px;
preferred-height: 600px; preferred-height: 600px;
title: "Slint OpenGL Underlay Example"; title: "Slint OpenGL Underlay Example";

View file

@ -4,7 +4,7 @@
import { SpinBox, Button, CheckBox, Slider, GroupBox, StandardListView, GridBox } from "std-widgets.slint"; import { SpinBox, Button, CheckBox, Slider, GroupBox, StandardListView, GridBox } from "std-widgets.slint";
import { Label, Page, Preview } from "common.slint"; import { Label, Page, Preview } from "common.slint";
component PrintPage inherits Page { export component PrintPage inherits Page {
layout := GridLayout { layout := GridLayout {
padding-left: 40px; padding-left: 40px;

View file

@ -54,7 +54,7 @@ struct InkLevel {
level: float, level: float,
} }
component MainWindow inherits Window { export component MainWindow inherits Window {
callback quit(); callback quit();
width: 800px; width: 800px;

View file

@ -200,7 +200,7 @@ pub struct UsedSubTypes {
/// Or is materialized for repeated expression. /// Or is materialized for repeated expression.
#[derive(Default, Debug)] #[derive(Default, Debug)]
pub struct Component { pub struct Component {
// node: SyntaxNode, pub node: Option<SyntaxNode>,
pub id: String, pub id: String,
pub root_element: ElementRc, pub root_element: ElementRc,
@ -254,6 +254,7 @@ impl Component {
let mut child_insertion_point = None; let mut child_insertion_point = None;
let is_legacy_syntax = node.child_token(SyntaxKind::ColonEqual).is_some(); let is_legacy_syntax = node.child_token(SyntaxKind::ColonEqual).is_some();
let c = Component { let c = Component {
node: Some(node.clone().into()),
id: parser::identifier_text(&node.DeclaredIdentifier()).unwrap_or_default(), id: parser::identifier_text(&node.DeclaredIdentifier()).unwrap_or_default(),
root_element: Element::from_node( root_element: Element::from_node(
node.Element(), node.Element(),
@ -2215,6 +2216,15 @@ impl Exports {
if sorted_deduped_exports.is_empty() { if sorted_deduped_exports.is_empty() {
if let Some(last_compo) = inner_components.last() { if let Some(last_compo) = inner_components.last() {
if last_compo.is_global() {
diag.push_warning(
"Global singleton is implicitly marked for export. This is deprecated and it should be explicitly exported"
.into(),
&last_compo.node,
);
} else {
diag.push_warning("Component is implicitly marked for export. This is deprecated and it should be explicitly exported".into(), &last_compo.node)
}
let name = last_compo.id.clone(); let name = last_compo.id.clone();
sorted_deduped_exports.push(( sorted_deduped_exports.push((
ExportedName { name, name_ident: doc.clone().into() }, ExportedName { name, name_ident: doc.clone().into() },

View file

@ -268,6 +268,7 @@ fn duplicate_sub_component(
) -> Rc<Component> { ) -> Rc<Component> {
debug_assert!(component_to_duplicate.parent_element.upgrade().is_some()); debug_assert!(component_to_duplicate.parent_element.upgrade().is_some());
let new_component = Component { let new_component = Component {
node: component_to_duplicate.node.clone(),
id: component_to_duplicate.id.clone(), id: component_to_duplicate.id.clone(),
root_element: duplicate_element_with_mapping( root_element: duplicate_element_with_mapping(
&component_to_duplicate.root_element, &component_to_duplicate.root_element,

View file

@ -19,7 +19,7 @@ Button3 := Rectangle {
} }
} }
Test := Window { export Test := Window {
Button1 { } Button1 { }
Button1 { accessible-description: "ok"; } // ok because Button1 has a role Button1 { accessible-description: "ok"; } // ok because Button1 has a role

View file

@ -14,7 +14,7 @@ WithStates := Rectangle {
] ]
} }
Test := Rectangle { export Test := Rectangle {
property <int> a: 45 + root.b; property <int> a: 45 + root.b;
// ^error{The binding for the property 'a' is part of a binding loop} // ^error{The binding for the property 'a' is part of a binding loop}

View file

@ -35,7 +35,7 @@ T4 := Rectangle {
property <length> my_property <=> x; property <length> my_property <=> x;
} }
App := Rectangle { export App := Rectangle {
VerticalLayout { VerticalLayout {

View file

@ -18,7 +18,7 @@ Compo1 := Rectangle {
// ^error{The binding for the property 'bb' is part of a binding loop} // ^error{The binding for the property 'bb' is part of a binding loop}
} }
App := Rectangle { export App := Rectangle {
cc := Compo1 { cc := Compo1 {
aa() => { return self.a; } aa() => { return self.a; }
// ^error{The binding for the property 'aa' is part of a binding loop} // ^error{The binding for the property 'aa' is part of a binding loop}
@ -29,4 +29,4 @@ App := Rectangle {
} }

View file

@ -6,7 +6,7 @@ Alias := Rectangle {
property <int> ps_width <=> viewport_width; property <int> ps_width <=> viewport_width;
} }
Foo := Rectangle { export Foo := Rectangle {
property <int> base-prop: alias.viewport_width; property <int> base-prop: alias.viewport_width;
// ^error{The binding for the property 'base-prop' is part of a binding loop} // ^error{The binding for the property 'base-prop' is part of a binding loop}

View file

@ -19,7 +19,7 @@ TC := Rectangle {
} }
Test := Rectangle { export Test := Rectangle {
VerticalLayout { VerticalLayout {
// ^error{The binding for the property 'layoutinfo-h' is part of a binding loop} // FIXME: That's an internal property, but people might understand // ^error{The binding for the property 'layoutinfo-h' is part of a binding loop} // FIXME: That's an internal property, but people might understand
// ^^error{The binding for the property 'min-width' is part of a binding loop} // ^^error{The binding for the property 'min-width' is part of a binding loop}

View file

@ -26,7 +26,7 @@ Wrap := Rectangle {
property <bool> test: square.width == square.height; property <bool> test: square.width == square.height;
} }
Test := Rectangle { export Test := Rectangle {
property <image> source; property <image> source;
GridLayout { GridLayout {
// ^error{The binding for the property 'layout-cache-h' is part of a binding loop} // ^error{The binding for the property 'layout-cache-h' is part of a binding loop}

View file

@ -22,7 +22,7 @@ Compo := Rectangle {
} }
Foo := Rectangle { export Foo := Rectangle {
Compo { Compo {
// ^error{The binding for the property 'preferred-width' is part of a binding loop} // ^error{The binding for the property 'preferred-width' is part of a binding loop}
the_text: self.preferred-width / 1px; the_text: self.preferred-width / 1px;

View file

@ -5,7 +5,7 @@
Key := Rectangle { property <int> pos; property <int> num_elements; } Key := Rectangle { property <int> pos; property <int> num_elements; }
Test := Rectangle { export Test := Rectangle {
Rectangle { Rectangle {
property <int> num_elements; property <int> num_elements;
num-elements: 4; num-elements: 4;

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
SuperSimple := Rectangle { export SuperSimple := Rectangle {
animate x { animate x {
duration: 1000ms; duration: 1000ms;

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
SuperSimple := Rectangle { export SuperSimple := Rectangle {
property<duration> p1: 3s + 1ms; property<duration> p1: 3s + 1ms;
property<int> p2: 3s + 1; property<int> p2: 3s + 1;
// ^error{Cannot convert float to duration} // ^error{Cannot convert float to duration}

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
Test := Window { export Test := Window {
a: [,]; a: [,];
// ^error{invalid expression} // ^error{invalid expression}
} }

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
SuperSimple := Rectangle { export SuperSimple := Rectangle {
TouchArea { TouchArea {
clicked => { root.x = 1phx; } clicked => { root.x = 1phx; }
} }

View file

@ -5,7 +5,7 @@ Foo := Rectangle {
drop-shadow-color: red; drop-shadow-color: red;
} }
SuperSimple := Window { export SuperSimple := Window {
drop-shadow-color: #00000080; drop-shadow-color: #00000080;
// ^warning{The drop-shadow-color property cannot be used on the root element, the shadow will not be visible} // ^warning{The drop-shadow-color property cannot be used on the root element, the shadow will not be visible}

View file

@ -33,7 +33,7 @@ TestBox2 := Rectangle {
// ^error{The @children placeholder can only appear once in an element hierarchy} // ^error{The @children placeholder can only appear once in an element hierarchy}
} }
Final := TestBox { export Final := TestBox {
Rectangle { Rectangle {
@children @children
// ^error{children placeholder not allowed in the final component} // ^error{children placeholder not allowed in the final component}

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
Final := Window { export Final := Window {
VerticalLayout { VerticalLayout {
@children @children
// ^error{children placeholder not allowed in the final component} // ^error{children placeholder not allowed in the final component}

View file

@ -3,7 +3,7 @@
MyTouchArea := TouchArea { } MyTouchArea := TouchArea { }
SubElements := Rectangle { export SubElements := Rectangle {
Rectangle { Rectangle {
clip: 42; clip: 42;
// ^error{Cannot convert float to bool} // ^error{Cannot convert float to bool}

View file

@ -4,7 +4,7 @@
// comment // comment
// line comment // line comment
SuperSimple := Rectangle { export SuperSimple := Rectangle {
/* block comment */ /* block comment */
background: green; background: green;

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
SuperSimple := Rectangle { export SuperSimple := Rectangle {
property<bool> zz: aa > bb == cc property<bool> zz: aa > bb == cc
// ^error{Use parentheses to disambiguate equality expression on the same level} // ^error{Use parentheses to disambiguate equality expression on the same level}
< dd; < dd;

View file

@ -26,7 +26,7 @@ SuperSimple := Rectangle {
} }
Test2 := Rectangle { export Test2 := Rectangle {
background: { background: {
// ^error{Cannot convert void to brush} // ^error{Cannot convert void to brush}
if (true) { if (true) {

View file

@ -47,7 +47,7 @@ MyDialog4 := Dialog {
} }
} }
Test := Rectangle { export Test := Rectangle {
MyDiag1 {} MyDiag1 {}
MyDiag2 {} MyDiag2 {}
MyDiag3 {} MyDiag3 {}

View file

@ -3,8 +3,8 @@
import { StandardButton } from "std-widgets.slint"; import { StandardButton } from "std-widgets.slint";
Test := Dialog { export Test := Dialog {
// ^error{A Dialog must have a single child element that is not StandardButton} // ^error{A Dialog must have a single child element that is not StandardButton}
StandardButton { kind: ok; } StandardButton { kind: ok; }
StandardButton { } StandardButton { }
// ^error{The `kind` property of the StandardButton in a Dialog must be set} // ^error{The `kind` property of the StandardButton in a Dialog must be set}

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
X := Rectangle { export X := Rectangle {
x: 42phx; x: 42phx;
x: 32phx; x: 32phx;

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
SuperSimple := Rectangle { export SuperSimple := Rectangle {
background: green; background: green;
background: red; background: red;
// ^error{Duplicated property} // ^error{Duplicated property}

View file

@ -26,7 +26,7 @@ SubElement := Rectangle {
// ^error{duplicated element id 'hello'} // ^error{duplicated element id 'hello'}
} }
TestCase := Rectangle { export TestCase := Rectangle {
unique := Rectangle { unique := Rectangle {
foo := SubElement { } foo := SubElement { }

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
X := Rectangle { export X := Rectangle {
animate x { easing: ease-in; } animate x { easing: ease-in; }
animate y { easing: foo; } animate y { easing: foo; }
// ^error{Unknown unqualified identifier 'foo'} // ^error{Unknown unqualified identifier 'foo'}

View file

@ -3,7 +3,7 @@
// Cannot be put in the easing.slint test because it is in a different pass // Cannot be put in the easing.slint test because it is in a different pass
X := Rectangle { export X := Rectangle {
property <int> g; animate g { easing: cubic-bezier; } property <int> g; animate g { easing: cubic-bezier; }
// ^error{must be called} // ^error{must be called}
} }

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
SuperSimple := Rectangle { export SuperSimple := Rectangle {
background: green; background: green;
for xx Text {} for xx Text {}

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
SubElements := Rectangle { export SubElements := Rectangle {
background: blue; background: blue;

View file

@ -7,7 +7,7 @@ Inline1 := Rectangle {
} }
} }
SubElements := Rectangle { export SubElements := Rectangle {
Inline1 { Inline1 {
background: yellow; background: yellow;
invalid: yellow; invalid: yellow;

View file

@ -19,7 +19,7 @@ Comp := Rectangle {
// ^error{'Rectangle' is not a valid type} // ^error{'Rectangle' is not a valid type}
} }
Foo := Rectangle { export Foo := Rectangle {
xx := Rectangle { } xx := Rectangle { }
Comp { Comp {
r: xx; r: xx;

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
X := Rectangle { export X := Rectangle {
lay := GridLayout { lay := GridLayout {
property<string> foo: "hello"; property<string> foo: "hello";

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
X := Rectangle { export X := Rectangle {
lay := GridLayout { lay := GridLayout {
property<string> foo: "hello"; property<string> foo: "hello";

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
X := Rectangle { export X := Rectangle {
property<brush> g1: @linear-gradient(); property<brush> g1: @linear-gradient();
// ^error{Expected angle expression} // ^error{Expected angle expression}
property<brush> g2: @linear-gradient(to left, blue, red); property<brush> g2: @linear-gradient(to left, blue, red);

View file

@ -6,7 +6,7 @@ global Plop := {
// ^error{Builtin function must be called} // ^error{Builtin function must be called}
} }
SuperSimple := Rectangle { export SuperSimple := Rectangle {
property <int> a: max + max() + max(45, "hello"); property <int> a: max + max() + max(45, "hello");
// ^error{Builtin function must be called} // ^error{Builtin function must be called}
// ^^error{Needs at least one argument} // ^^error{Needs at least one argument}

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
H := Rectangle { export H := Rectangle {
x: {foo: "42"}; x: {foo: "42"};
// ^error{Cannot convert \{ foo: string,\} to length} // ^error{Cannot convert \{ foo: string,\} to length}
y: [ 45, 45, 45, 45 ]; y: [ 45, 45, 45, 45 ];

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
SuperSimple := Window { export SuperSimple := Window {
opacity: 0.5; opacity: 0.5;
// ^warning{The opacity property cannot be used on the root element, it will not be applied} // ^warning{The opacity property cannot be used on the root element, it will not be applied}

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
SuperSimple := Rectangle { export SuperSimple := Rectangle {
88; 88;
// ^error{Parse error} // ^error{Parse error}
* / - + // no error there as this is already reported in the previous line * / - + // no error there as this is already reported in the previous line

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
TestCase := Rectangle { export TestCase := Rectangle {
Path { Path {
LineTo { x: 100; y: 0; } LineTo { x: 100; y: 0; }
LineTo { x: 100; y: 0; } LineTo { x: 100; y: 0; }

View file

@ -8,7 +8,7 @@ Test2 := Path {
// ^error{Error parsing SVG commands} // ^error{Error parsing SVG commands}
} }
TestCase := Rectangle { export TestCase := Rectangle {
Path { Path {
width: 100px; width: 100px;
height: 100px; height: 100px;

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
TestCase := Rectangle { export TestCase := Rectangle {
Path { Path {
MoveTo { MoveTo {
x: 0; x: 0;

View file

@ -12,7 +12,7 @@ Foo := Rectangle {
// ^error{conversion from percentage to length is only possible for the properties width and height} // ^error{conversion from percentage to length is only possible for the properties width and height}
} }
X := Rectangle { export X := Rectangle {
height: 30%; height: 30%;
// ^error{Cannot find parent property to apply relative length} // ^error{Cannot find parent property to apply relative length}
Foo { Foo {

View file

@ -2,8 +2,8 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
X := PopupWindow { export X := PopupWindow {
// ^error{PopupWindow cannot be the top level} // ^error{PopupWindow cannot be the top level}
Rectangle { Rectangle {

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
TestCase := Rectangle { export TestCase := Rectangle {
animate x { animate x {
duration: 1000ms; duration: 1000ms;
} }

View file

@ -5,7 +5,7 @@ Comp := Rectangle {
callback pressed; callback pressed;
} }
Test := Comp { export Test := Comp {
property<int> foo; property<int> foo;
foo: 100; foo: 100;
property<NonExistent> bar; property<NonExistent> bar;

View file

@ -5,7 +5,7 @@ Comp := Rectangle {
property<int> prop; property<int> prop;
} }
Test := Rectangle { export Test := Rectangle {
Comp { Comp {
prop: 45; prop: 45;
} }

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
X := Rectangle { export X := Rectangle {
property<brush> g1: @radial-gradient(); property<brush> g1: @radial-gradient();
// ^error{Expected 'circle': currently, only @radial-gradient\(circle, ...\) are supported} // ^error{Expected 'circle': currently, only @radial-gradient\(circle, ...\) are supported}
property<brush> g2: @radial-gradient(circle at 100%, #333, #333 50%, #eee 75%, #333 75%); property<brush> g2: @radial-gradient(circle at 100%, #333, #333 50%, #eee 75%, #333 75%);

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
X := Rectangle { export X := Rectangle {
background: { background: {
return 42; return 42;
// ^error{Cannot convert float to brush} // ^error{Cannot convert float to brush}

View file

@ -47,7 +47,7 @@ Ex2 := Rectangle {
} }
Ex3 := Rectangle { export Ex3 := Rectangle {
i1 := Image { i1 := Image {
// ^error{Elements with rotation properties cannot have children elements} // ^error{Elements with rotation properties cannot have children elements}
Rectangle {} Rectangle {}

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
SuperSimple := Rectangle { export SuperSimple := Rectangle {
TouchArea { TouchArea {
clicked => { root.x += 1phx; } clicked => { root.x += 1phx; }
} }

View file

@ -5,7 +5,7 @@ Base := Rectangle {
callback blah; callback blah;
} }
SubElements := Rectangle { export SubElements := Rectangle {
callback foobar; callback foobar;
callback foobar; callback foobar;
// ^error{Duplicated callback declaration} // ^error{Duplicated callback declaration}

View file

@ -87,7 +87,7 @@ component NewSyntax {
} }
component OldInNewSyntax { export component OldInNewSyntax {
property<bool> checked; property<bool> checked;
property <int> border; property <int> border;
property <color> color; property <color> color;
@ -130,4 +130,4 @@ component OldInNewSyntax {
text := Text {} text := Text {}
touch := TouchArea {} touch := TouchArea {}
} }

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
TestCase := Rectangle { export TestCase := Rectangle {
property<bool> checked; property<bool> checked;
property <int> border; property <int> border;
animate background { } animate background { }

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
Test := Window { export Test := Window {
Text { Text {
text: "hel\lo"; text: "hel\lo";
// ^error{Cannot parse string literal} // ^error{Cannot parse string literal}

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
SubElements := Rectangle { export SubElements := Rectangle {
Rectangle { Rectangle {
background: yellow; background: yellow;

View file

@ -2,6 +2,6 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
SuperSimple := Rectangle { export SuperSimple := Rectangle {
background: green; background: green;
} }

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
TestCase := Rectangle { export TestCase := Rectangle {
Path { Path {
commands: "M 350 300 L 550 300 "; commands: "M 350 300 L 550 300 ";
LineTo { x: 10; y: 100; } LineTo { x: 10; y: 100; }

View file

@ -30,7 +30,7 @@ global MyType := {
} }
SuperSimple := Rectangle { export SuperSimple := Rectangle {
MyType { MyType {
// ^error{Cannot create an instance of a global component} // ^error{Cannot create an instance of a global component}
ccc: "hello"; ccc: "hello";

View file

@ -3,7 +3,7 @@
struct Struct := { def: int, } struct Struct := { def: int, }
SuperSimple := Rectangle { export SuperSimple := Rectangle {
DoesNotExist { DoesNotExist {
// ^error{Unknown type DoesNotExist} // ^error{Unknown type DoesNotExist}
} }

View file

@ -8,7 +8,7 @@ global Singleton := {
// ^error{A global component cannot have an 'init' callback} // ^error{A global component cannot have an 'init' callback}
} }
Test := Rectangle { export Test := Rectangle {
callback init; callback init;
// ^error{Cannot override callback 'init'} // ^error{Cannot override callback 'init'}
} }

View file

@ -10,7 +10,7 @@ Foo := Rectangle {
} }
} }
Bar := Rectangle { export Bar := Rectangle {
Foo { Text {} } Foo { Text {} }
ListView { ListView {
Text {} Text {}
@ -32,4 +32,4 @@ Bar := Rectangle {
for x in 2: Rectangle {} for x in 2: Rectangle {}
// ^warning{A ListView can just have a single 'for' as children. Anything else is not supported} // ^warning{A ListView can just have a single 'for' as children. Anything else is not supported}
} }
} }

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
import { TabWidget } from "std-widgets.slint"; import { TabWidget } from "std-widgets.slint";
Test1 := Rectangle { export Test1 := Rectangle {
TabWidget { TabWidget {
Rectangle {} Rectangle {}
// ^error{Rectangle is not allowed within TabWidget. Only Tab are valid children} // ^error{Rectangle is not allowed within TabWidget. Only Tab are valid children}

View file

@ -3,7 +3,7 @@
import { TabWidget } from "std-widgets.slint"; import { TabWidget } from "std-widgets.slint";
Test2 := Rectangle { export Test2 := Rectangle {
TabWidget { TabWidget {
Tab { Tab {
visible: false; visible: false;

View file

@ -7,5 +7,5 @@ Test3 := Rectangle {
} }
} }
Foo := TabWidget { } export Foo := TabWidget { }
// ^error{Unknown type TabWidget. \(The type exist as an internal type, but cannot be accessed in this scope\)} // ^error{Unknown type TabWidget. \(The type exist as an internal type, but cannot be accessed in this scope\)}

View file

@ -0,0 +1,12 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
component Button {
}
component App {
//^warning{Component is implicitly marked for export. This is deprecated and it should be explicitly exported}
Button {}
}

View file

@ -0,0 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
global Settings {
//^warning{Global singleton is implicitly marked for export. This is deprecated and it should be explicitly exported}
in-out property <bool> active;
}

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
X := Rectangle { export X := Rectangle {
forward-focus: nothingness; forward-focus: nothingness;
// ^error{Unknown unqualified identifier} // ^error{Unknown unqualified identifier}
} }

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
X := Rectangle { export X := Rectangle {
edit := TextInput { } edit := TextInput { }
TouchArea { TouchArea {
clicked => { clicked => {

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
X := Rectangle { export X := Rectangle {
forward-focus: someRect; forward-focus: someRect;
// ^error{element is not focusable} // ^error{element is not focusable}

View file

@ -7,7 +7,7 @@ Abc := Rectangle {
function par() {} function par() {}
} }
Xxx := Rectangle { export Xxx := Rectangle {
function fooo(a: int, a: int) -> int { return a; } function fooo(a: int, a: int) -> int { return a; }
// ^error{Duplicated argument name 'a'} // ^error{Duplicated argument name 'a'}

View file

@ -10,7 +10,7 @@ Comp := Rectangle {
public function f2() {} public function f2() {}
} }
Xxx := Rectangle { export Xxx := Rectangle {
function foo(a: int) -> string { return a; } function foo(a: int) -> string { return a; }
comp := Comp {} comp := Comp {}

View file

@ -138,7 +138,7 @@ Foo_Legacy := Rectangle {
} }
Bar_Legacy := Rectangle { export Bar_Legacy := Rectangle {
pure callback xc1 <=> f.c1; pure callback xc1 <=> f.c1;
// ^error{Purity of callbacks 'xc1' and 'f.c1' doesn't match} // ^error{Purity of callbacks 'xc1' and 'f.c1' doesn't match}
callback xc2 <=> f.c2; callback xc2 <=> f.c2;
@ -149,4 +149,4 @@ Bar_Legacy := Rectangle {
// ^warning{Call of impure callback 'c1'} // ^warning{Call of impure callback 'c1'}
} }
} }
} }

View file

@ -3,7 +3,7 @@
import { Rec12 } from "../../typeloader/recursive_import1.slint"; import { Rec12 } from "../../typeloader/recursive_import1.slint";
// ^error{No exported type called 'Rec12' found in ".*recursive_import1.slint"} // ^error{No exported type called 'Rec12' found in ".*recursive_import1.slint"}
Blah := Rec12 { export Blah := Rec12 {
// ^error{Unknown type Rec12} // ^error{Unknown type Rec12}
width: 100px; width: 100px;
} }

View file

@ -5,7 +5,7 @@ import { LineEdit } from "sixtyfps_widgets.60";
// ^warning{"sixtyfps_widgets\.60" was renamed "std-widgets\.slint". Use of the old file name is deprecated} // ^warning{"sixtyfps_widgets\.60" was renamed "std-widgets\.slint". Use of the old file name is deprecated}
Blah := Window { export Blah := Window {
LineEdit {} // Not an error LineEdit {} // Not an error
Button {} // Not imported Button {} // Not imported
// ^error{Unknown type Button} // ^error{Unknown type Button}

View file

@ -3,7 +3,7 @@
import { X } from "../../typeloader/incpath/should_fail2.slint"; import { X } from "../../typeloader/incpath/should_fail2.slint";
Foo := Rectangle { export Foo := Rectangle {
x:= X { x:= X {
hello: 42; hello: 42;
meh: 12; meh: 12;

View file

@ -3,6 +3,6 @@
import { Y } from "../../typeloader/incpath/should_fail3.slint"; import { Y } from "../../typeloader/incpath/should_fail3.slint";
Foo := Rectangle { export Foo := Rectangle {
} }

View file

@ -3,7 +3,7 @@
import { Z } from "../../typeloader/incpath/should_fail4.slint"; import { Z } from "../../typeloader/incpath/should_fail4.slint";
Foo := Rectangle { export Foo := Rectangle {
Z { Z {
property <int> b: b1; property <int> b: b1;
} }

View file

@ -5,6 +5,6 @@ import { SomeRect } from "../../typeloader/incpath/local_helper_type.slint";
import "../../typeloader/incpath/local_helper_type.slint"; import "../../typeloader/incpath/local_helper_type.slint";
// ^error{Import names are missing. Please specify which types you would like to import} // ^error{Import names are missing. Please specify which types you would like to import}
X := Rectangle { export X := Rectangle {
} }

View file

@ -19,6 +19,6 @@ import "myimage.png";
import "."; import ".";
// ^error{Unsupported foreign import ".*"} // ^error{Unsupported foreign import ".*"}
X := Rectangle { export X := Rectangle {
} }

View file

@ -5,6 +5,6 @@ import { NotExported } from "../../typeloader/incpath/local_helper_type.slint";
import { } from "../../typeloader/incpath/local_helper_type.slint"; import { } from "../../typeloader/incpath/local_helper_type.slint";
// ^error{Import names are missing. Please specify which types you would like to import} // ^error{Import names are missing. Please specify which types you would like to import}
X := Rectangle { export X := Rectangle {
} }

View file

@ -10,6 +10,6 @@ export { Image as Plop }
export { string as Boob } export { string as Boob }
// ^error{Cannot export 'string' because it is not a component} // ^error{Cannot export 'string' because it is not a component}
Hello := Plop { export Hello := Plop {
// ^error{Unknown type Plop} // ^error{Unknown type Plop}
} }

View file

@ -5,7 +5,7 @@ import { SomeRect } from "../../typeloader/incpath/local_helper_type.slint";
import { X } from "../../typeloader/incpath/should_fail.slint"; import { X } from "../../typeloader/incpath/should_fail.slint";
Blah := X { export Blah := X {
width: 100px; width: 100px;
// ^error{Unknown property width in X} // ^error{Unknown property width in X}
} }

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
Test := Rectangle { export Test := Rectangle {
property <bool> condition; property <bool> condition;
GridLayout { GridLayout {

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
Test := Rectangle { export Test := Rectangle {
GridLayout { GridLayout {
Rectangle { Rectangle {

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
Hello := Rectangle { export Hello := Rectangle {
property <int> aa: 45; property <int> aa: 45;
property <{o:[int], c:string}> bb; property <{o:[int], c:string}> bb;

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
Xxx := Rectangle { export Xxx := Rectangle {
foo := Rectangle { foo := Rectangle {
callback hello(int) -> int; callback hello(int) -> int;

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
Xxx := Rectangle { export Xxx := Rectangle {
foo := Rectangle { foo := Rectangle {
callback hello(int) -> int; callback hello(int) -> int;

View file

@ -6,7 +6,7 @@ Sub := Rectangle {
callback compute_alias <=> compute; callback compute_alias <=> compute;
} }
Xxx := Rectangle { export Xxx := Rectangle {
foo := Rectangle { foo := Rectangle {
callback hello(int) -> int; callback hello(int) -> int;

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
Xxx := Rectangle { export Xxx := Rectangle {
callback plop() -> string; callback plop() -> string;
plop => {} plop => {}
// ^error{Cannot convert void to string} // ^error{Cannot convert void to string}

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
X := Rectangle { export X := Rectangle {
Rectangle { Rectangle {
background: blue; background: blue;
} }

View file

@ -15,7 +15,7 @@ global Glob := {
property <relative-font-size> rem_allowed: 42rem; property <relative-font-size> rem_allowed: 42rem;
} }
X := Rectangle { export X := Rectangle {
t := Text { t := Text {
x: "hello"; x: "hello";

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
Xxx := Rectangle { export Xxx := Rectangle {
my-rect := Rectangle { my-rect := Rectangle {
border-width: 44px; border-width: 44px;

View file

@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com> // Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
Xxx := Rectangle { export Xxx := Rectangle {
color: white; color: white;
// ^warning{The property 'color' has been deprecated. Please use 'background' instead} // ^warning{The property 'color' has been deprecated. Please use 'background' instead}

Some files were not shown because too many files have changed in this diff Show more