6
6
use i_slint_compiler:: expression_tree:: Expression ;
7
7
use i_slint_compiler:: langtype:: { Function , Type } ;
8
8
use i_slint_compiler:: object_tree:: PropertyVisibility ;
9
+ use i_slint_compiler:: parser:: syntax_nodes;
9
10
use i_slint_compiler:: typeloader:: TypeLoader ;
10
11
use i_slint_compiler:: typeregister:: TypeRegister ;
11
12
use smol_str:: { SmolStr , ToSmolStr } ;
@@ -19,11 +20,17 @@ struct PropertyInfo {
19
20
ty : Type ,
20
21
vis : PropertyVisibility ,
21
22
pure : bool ,
23
+ /// For a function or callback: the names of the arguments
24
+ arg_names : Vec < SmolStr > ,
22
25
}
23
26
24
27
impl Display for PropertyInfo {
25
28
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
26
- write ! ( f, "{}/{}{:?}" , self . ty, if self . pure { "pure-" } else { "" } , self . vis)
29
+ write ! ( f, "{}/{}{:?}" , self . ty, if self . pure { "pure-" } else { "" } , self . vis) ?;
30
+ if !self . arg_names . is_empty ( ) {
31
+ write ! ( f, "{:?}" , self . arg_names) ?
32
+ }
33
+ Ok ( ( ) )
27
34
}
28
35
}
29
36
@@ -55,6 +62,29 @@ fn load_component(component: &Rc<i_slint_compiler::object_tree::Component>) -> C
55
62
ty : v. property_type . clone ( ) ,
56
63
vis : v. visibility ,
57
64
pure : v. pure . unwrap_or ( false ) ,
65
+ arg_names : v
66
+ . node
67
+ . as_ref ( )
68
+ . map ( |n| {
69
+ if let Some ( n) =
70
+ syntax_nodes:: CallbackDeclaration :: new ( n. clone ( ) )
71
+ {
72
+ n. CallbackDeclarationParameter ( )
73
+ . map ( |p| {
74
+ p. DeclaredIdentifier ( )
75
+ . map ( |p| p. text ( ) . to_smolstr ( ) )
76
+ . unwrap_or_default ( )
77
+ } )
78
+ . collect ( )
79
+ } else if let Some ( n) = syntax_nodes:: Function :: new ( n. clone ( ) ) {
80
+ n. ArgumentDeclaration ( )
81
+ . map ( |p| p. DeclaredIdentifier ( ) . to_smolstr ( ) )
82
+ . collect ( )
83
+ } else {
84
+ vec ! [ ]
85
+ }
86
+ } )
87
+ . unwrap_or_default ( ) ,
58
88
} ,
59
89
)
60
90
} ) ,
@@ -89,6 +119,7 @@ fn load_component(component: &Rc<i_slint_compiler::object_tree::Component>) -> C
89
119
ty : v. ty . clone ( ) ,
90
120
vis : v. property_visibility ,
91
121
pure : false ,
122
+ arg_names : vec ! [ ] ,
92
123
} ,
93
124
)
94
125
} ) ,
@@ -104,6 +135,7 @@ fn load_component(component: &Rc<i_slint_compiler::object_tree::Component>) -> C
104
135
} ) ) ,
105
136
vis : PropertyVisibility :: Public ,
106
137
pure : false ,
138
+ arg_names : vec ! [ ] ,
107
139
} ,
108
140
) ;
109
141
result. properties . insert (
@@ -115,6 +147,7 @@ fn load_component(component: &Rc<i_slint_compiler::object_tree::Component>) -> C
115
147
} ) ) ,
116
148
vis : PropertyVisibility :: Public ,
117
149
pure : false ,
150
+ arg_names : vec ! [ ] ,
118
151
} ,
119
152
) ;
120
153
}
0 commit comments