More when bug fixes.

This commit is contained in:
Samuel Guerra 2021-02-08 22:21:22 -03:00
parent 247e88e4af
commit 1b2e29b100
2 changed files with 26 additions and 0 deletions

View File

@ -1093,6 +1093,8 @@ mod widget_tests {
}
#[test]
pub fn wgt_when() {
let mut wgt = when_wgt!();
let mut ctx = TestWidgetContext::wait_new();
// TODO
}

View File

@ -376,6 +376,7 @@ pub fn expand(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
// properties that are only introduced in when conditions.
// reexported if they have default values.
let mut when_condition_default_props = TokenStream::default();
let mut wgt_properties = wgt_properties;
for w_prop in &wgt_when_properties {
// property not introduced in the widget first, validate that it has a default value.
@ -396,6 +397,20 @@ pub fn expand(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
}
}
});
#[cfg(debug_assertions)]
{
let loc_ident = ident!("__loc_{}", w_prop);
when_condition_default_props.extend(quote_spanned! {p_ident.span()=>
#w_prop::code_gen! {
if default=>
#[doc(hidden)]
pub fn #loc_ident() -> #crate_core::debug::SourceLocation {
#crate_core::debug::source_location!()
}
}
});
}
// OR compile error because the property has no default value.
let msg = format!("property `{}` is not declared in the widget and has no default value", w_prop);
@ -406,6 +421,15 @@ pub fn expand(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
std::compile_error! { #msg }
}
});
wgt_properties.extend(quote! {
#w_prop {
docs { } // TODO
cfg { } // TODO
default { true }
required { false }
}
});
}
let gen_docs = TokenStream::default();