diff --git a/crates/eww/src/widgets/def_widget_macro.rs b/crates/eww/src/widgets/def_widget_macro.rs index 2fdcacf2..00a11eca 100644 --- a/crates/eww/src/widgets/def_widget_macro.rs +++ b/crates/eww/src/widgets/def_widget_macro.rs @@ -16,7 +16,7 @@ macro_rules! def_widget { // If an attribute is explicitly marked as optional (? appended to type) // the attribute will still show up here, as a `None` value. Otherwise, all values in this map // will be `Some`. - let attr_map: Result>> = try { + let attr_map: Result>> = try { ::maplit::hashmap! { $( eww_shared_util::AttrName(::std::stringify!($attr_name).to_owned()) => @@ -78,14 +78,14 @@ macro_rules! def_widget { (@value_depending_on_type $values:expr, $attr_name:ident : as_action $(? $(@ $optional:tt @)?)? $(= $default:expr)?) => { match $attr_name { - Some(yuck::config::action::AttrValue::Action(action)) => Some(action.eval_exprs(&$values)?), + Some(yuck::config::attr_value::AttrValue::Action(action)) => Some(action.eval_exprs(&$values)?), _ => None, } }; (@value_depending_on_type $values:expr, $attr_name:ident : $typecast_func:ident $(? $(@ $optional:tt @)?)? $(= $default:expr)?) => { match $attr_name { - Some(yuck::config::action::AttrValue::SimplExpr(expr)) => Some(expr.eval(&$values)?.$typecast_func()?), + Some(yuck::config::attr_value::AttrValue::SimplExpr(expr)) => Some(expr.eval(&$values)?.$typecast_func()?), _ => None, } }; @@ -97,18 +97,18 @@ macro_rules! def_widget { // The attribute is explicitly marked as optional - the value should be provided to the prop function body as Option (@get_value $args:ident, $name:expr, ?) => { - $args.widget_use.attrs.ast_optional::($name)?.clone() + $args.widget_use.attrs.ast_optional::($name)?.clone() }; // The attribute has a default value (@get_value $args:ident, $name:expr, = $default:expr) => { - Some($args.widget_use.attrs.ast_optional::($name)? + Some($args.widget_use.attrs.ast_optional::($name)? .clone() - .unwrap_or_else(|| yuck::config::action::AttrValue::SimplExpr(simplexpr::SimplExpr::synth_literal($default)))) + .unwrap_or_else(|| yuck::config::attr_value::AttrValue::SimplExpr(simplexpr::SimplExpr::synth_literal($default)))) }; // The attribute is required - the prop will only be ran if this attribute is actually provided. (@get_value $args:ident, $name:expr,) => { - Some($args.widget_use.attrs.ast_required::($name)?.clone()) + Some($args.widget_use.attrs.ast_required::($name)?.clone()) } } diff --git a/crates/yuck/src/config/action.rs b/crates/yuck/src/config/attr_value.rs similarity index 100% rename from crates/yuck/src/config/action.rs rename to crates/yuck/src/config/attr_value.rs diff --git a/crates/yuck/src/config/mod.rs b/crates/yuck/src/config/mod.rs index 7e463872..e91ca3b0 100644 --- a/crates/yuck/src/config/mod.rs +++ b/crates/yuck/src/config/mod.rs @@ -1,4 +1,4 @@ -pub mod action; +pub mod attr_value; pub mod attributes; pub mod backend_window_options; pub mod config; diff --git a/crates/yuck/src/format_diagnostic.rs b/crates/yuck/src/format_diagnostic.rs index 3333f8ef..25cdaea9 100644 --- a/crates/yuck/src/format_diagnostic.rs +++ b/crates/yuck/src/format_diagnostic.rs @@ -99,7 +99,7 @@ impl ToDiagnostic for AstError { AstError::UnknownAction(span, actual) => gen_diagnostic! { msg = format!("Unknown action `{}`", actual), label = span, - note = format!("Must be one of: {}", crate::config::action::ACTION_NAMES.iter().join(", ")), + note = format!("Must be one of: {}", crate::config::attr_value::ACTION_NAMES.iter().join(", ")), }, AstError::ParseError { file_id, source } => lalrpop_error_to_diagnostic(source, *file_id), diff --git a/crates/yuck/src/parser/from_ast.rs b/crates/yuck/src/parser/from_ast.rs index 2138d3ce..65c999ce 100644 --- a/crates/yuck/src/parser/from_ast.rs +++ b/crates/yuck/src/parser/from_ast.rs @@ -2,7 +2,11 @@ use super::{ ast::{Ast, AstType}, ast_iterator::AstIterator, }; -use crate::{config::action::AttrValue, error::*, parser}; +use crate::{ + config::attr_value::{Action, AttrValue}, + error::*, + parser, +}; use eww_shared_util::{AttrName, Span, VarName}; use itertools::Itertools; use simplexpr::{ast::SimplExpr, dynval::DynVal}; @@ -57,7 +61,6 @@ impl FromAst for SimplExpr { } } -use crate::config::action::Action; impl FromAst for Action { fn from_ast(e: Ast) -> AstResult { let mut iter = e.try_ast_iter()?;