mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 22:54:36 +00:00
fix missing warning of missing export
... for last component when globals are exported
This commit is contained in:
parent
786933966a
commit
acb7da11d2
7 changed files with 34 additions and 22 deletions
|
@ -8,7 +8,7 @@ import { SideBar } from "ui/side_bar.slint";
|
|||
|
||||
export { TableViewPageAdapter }
|
||||
|
||||
component App inherits Window {
|
||||
export component App inherits Window {
|
||||
preferred-width: 700px;
|
||||
preferred-height: 500px;
|
||||
title: @tr("Slint Widgets Gallery");
|
||||
|
|
|
@ -28,7 +28,7 @@ component SideBarIcon inherits Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
component MainWindow inherits Window {
|
||||
export component MainWindow inherits Window {
|
||||
/// Note that this property is overwritten in the .cpp and .rs code.
|
||||
/// The data is only in this file so it looks good in the viewer
|
||||
in property <[InkLevel]> ink-levels: [
|
||||
|
|
|
@ -32,7 +32,7 @@ component SideBarIcon inherits Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
component MainWindow inherits Window {
|
||||
export component MainWindow inherits Window {
|
||||
width: 320px;
|
||||
height: 240px;
|
||||
title: "Slint printer demo";
|
||||
|
|
|
@ -10,7 +10,7 @@ export struct TodoItem {
|
|||
checked: bool,
|
||||
}
|
||||
|
||||
component MainWindow inherits Window {
|
||||
export component MainWindow inherits Window {
|
||||
in property <[TodoItem]> todo-model: [
|
||||
{ title: "Implement the .slint file", checked: true },
|
||||
{ title: "Do the Rust part", checked: false },
|
||||
|
|
|
@ -2555,18 +2555,21 @@ impl Exports {
|
|||
sorted_deduped_exports.push((exported_name, compo_or_type));
|
||||
}
|
||||
|
||||
if sorted_deduped_exports.is_empty() {
|
||||
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)
|
||||
if let Some(last_compo) = inner_components.last() {
|
||||
let name = last_compo.id.clone();
|
||||
if last_compo.is_global() {
|
||||
if sorted_deduped_exports.is_empty() {
|
||||
diag.push_warning("Global singleton is implicitly marked for export. This is deprecated and it should be explicitly exported".into(), &last_compo.node);
|
||||
sorted_deduped_exports.push((
|
||||
ExportedName { name, name_ident: doc.clone().into() },
|
||||
Either::Left(last_compo.clone()),
|
||||
))
|
||||
}
|
||||
let name = last_compo.id.clone();
|
||||
} else if !sorted_deduped_exports
|
||||
.iter()
|
||||
.any(|e| e.1.as_ref().left().is_some_and(|c| !c.is_global()))
|
||||
{
|
||||
diag.push_warning("Component is implicitly marked for export. This is deprecated and it should be explicitly exported".into(), &last_compo.node);
|
||||
sorted_deduped_exports.push((
|
||||
ExportedName { name, name_ident: doc.clone().into() },
|
||||
Either::Left(last_compo.clone()),
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
||||
|
||||
export global Foo {}
|
||||
|
||||
component App {
|
||||
//^warning{Component is implicitly marked for export. This is deprecated and it should be explicitly exported}
|
||||
}
|
||||
|
|
@ -1057,7 +1057,7 @@ impl ComponentInstance {
|
|||
/// use slint_interpreter::{ComponentDefinition, ComponentCompiler, Value, SharedString, ComponentHandle};
|
||||
/// use core::convert::TryInto;
|
||||
/// let code = r#"
|
||||
/// component MyWin inherits Window {
|
||||
/// export component MyWin inherits Window {
|
||||
/// callback foo(int) -> int;
|
||||
/// in-out property <int> my_prop: 12;
|
||||
/// }
|
||||
|
@ -1116,7 +1116,7 @@ impl ComponentInstance {
|
|||
/// in-out property <int> my_property: 42;
|
||||
/// }
|
||||
/// export { Glob as TheGlobal }
|
||||
/// component MyWin inherits Window {
|
||||
/// export component MyWin inherits Window {
|
||||
/// }
|
||||
/// "#;
|
||||
/// let mut compiler = ComponentCompiler::default();
|
||||
|
@ -1171,7 +1171,7 @@ impl ComponentInstance {
|
|||
/// export global Logic {
|
||||
/// pure callback to_uppercase(string) -> string;
|
||||
/// }
|
||||
/// component MyWin inherits Window {
|
||||
/// export component MyWin inherits Window {
|
||||
/// out property <string> hello: Logic.to_uppercase("world");
|
||||
/// }
|
||||
/// "#;
|
||||
|
@ -1666,7 +1666,7 @@ fn call_functions() {
|
|||
return a-a + b-b;
|
||||
}
|
||||
}
|
||||
export Test := Rectangle {
|
||||
export component Test {
|
||||
out property<int> p;
|
||||
public function foo-bar(a: int, b:int) -> int {
|
||||
p = a;
|
||||
|
@ -1713,8 +1713,8 @@ fn component_definition_struct_properties() {
|
|||
export struct Settings {
|
||||
string_value: string,
|
||||
}
|
||||
export Dummy := Rectangle {
|
||||
property <Settings> test;
|
||||
export component Dummy {
|
||||
in-out property <Settings> test;
|
||||
}"#
|
||||
.into(),
|
||||
"".into(),
|
||||
|
@ -1759,7 +1759,7 @@ fn component_definition_model_properties() {
|
|||
let mut compiler = ComponentCompiler::default();
|
||||
compiler.set_style("fluent".into());
|
||||
let comp_def = spin_on::spin_on(compiler.build_from_source(
|
||||
"export Dummy := Rectangle { property <[int]> prop: [42, 12]; }".into(),
|
||||
"export component Dummy { in-out property <[int]> prop: [42, 12]; }".into(),
|
||||
"".into(),
|
||||
))
|
||||
.unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue