aboutsummaryrefslogtreecommitdiff
path: root/mingling_macros/src/node.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-20 00:59:17 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-20 01:01:27 +0800
commit1f583f625a7d541dc7d47a8136b31d29a5ed5441 (patch)
tree795006c8c2a9f10c866951de5aba318a64007219 /mingling_macros/src/node.rs
parente8ae63988d562969df47ae6d92129974e7fb6980 (diff)
chore(macros): reorganize module hierarchy in mingling_macros
Restructure flat module layout into logical directories (attr/, derive/, func/, systems/, extensions/, utils.rs). Tighten internal function visibility to pub(crate). All public API signatures remain unchanged.
Diffstat (limited to 'mingling_macros/src/node.rs')
-rw-r--r--mingling_macros/src/node.rs59
1 files changed, 0 insertions, 59 deletions
diff --git a/mingling_macros/src/node.rs b/mingling_macros/src/node.rs
deleted file mode 100644
index b3a61c6..0000000
--- a/mingling_macros/src/node.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-use just_fmt::kebab_case;
-use proc_macro::TokenStream;
-use proc_macro2::TokenStream as TokenStream2;
-use quote::quote;
-use syn::parse::{Parse, ParseStream};
-use syn::{LitStr, Result as SynResult};
-
-/// Parses a string literal input for the node macro
-struct NodeInput {
- path: LitStr,
-}
-
-impl Parse for NodeInput {
- fn parse(input: ParseStream) -> SynResult<Self> {
- Ok(NodeInput {
- path: input.parse()?,
- })
- }
-}
-
-pub fn node(input: TokenStream) -> TokenStream {
- // Parse the input as a string literal
- let input_parsed = syn::parse_macro_input!(input as NodeInput);
- let path_str = input_parsed.path.value();
-
- // If the input string is empty, return an empty Node
- if path_str.is_empty() {
- return quote! {
- mingling::Node::default()
- }
- .into();
- }
-
- // Split the path by dots
- let parts: Vec<String> = path_str
- .split('.')
- .map(|s| {
- if s.starts_with('_') {
- s.to_string()
- } else {
- kebab_case!(s).to_string()
- }
- })
- .collect();
-
- // Build the expression starting from Node::default()
- let mut expr: TokenStream2 = quote! {
- mingling::Node::default()
- };
-
- // Add .join() calls for each part of the path
- for part in parts {
- expr = quote! {
- #expr.join(#part)
- };
- }
-
- expr.into()
-}