mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 20:53:06 +00:00
fix diffing
This commit is contained in:
parent
690aad7912
commit
9261e4d5e9
3 changed files with 55 additions and 23 deletions
15
Cargo.lock
generated
15
Cargo.lock
generated
|
@ -734,6 +734,9 @@ dependencies = [
|
|||
"enumset",
|
||||
"euclid",
|
||||
"keyboard-types",
|
||||
"serde",
|
||||
"serde-value",
|
||||
"serde_repr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -840,6 +843,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "b52c2ef4a78da0ba68fbe1fd920627411096d2ac478f7f4c9f3a54ba6705bade"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2387,6 +2391,17 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_repr"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a5ec9fa74a20ebbe5d9ac23dac1fc96ba0ecfe9f50f2843b52e537b10fbcb4e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_urlencoded"
|
||||
version = "0.7.1"
|
||||
|
|
|
@ -73,9 +73,9 @@ mlua = { version = "0.8.1", features = [
|
|||
] }
|
||||
ctrlc = "3.2.3"
|
||||
# dioxus-rsx = "0.0.1"
|
||||
dioxus-rsx = { path = "/home/evan/Desktop/github/dioxus/packages/rsx" }
|
||||
dioxus-html = { path = "/home/evan/Desktop/github/dioxus/packages/html" }
|
||||
dioxus-core = { path = "/home/evan/Desktop/github/dioxus/packages/core", features = ["serialize"] }
|
||||
dioxus-rsx = { path = "c:/users/Desktop/github/dioxus/packages/rsx" }
|
||||
dioxus-html = { path = "c:/users/Desktop/github/dioxus/packages/html" }
|
||||
dioxus-core = { path = "c:/users/Desktop/github/dioxus/packages/core", features = ["serialize"] }
|
||||
|
||||
[[bin]]
|
||||
path = "src/main.rs"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use proc_macro2::TokenStream;
|
||||
use syn::{File, Macro};
|
||||
use syn::{File, Macro, __private::ToTokens};
|
||||
|
||||
pub enum DiffResult {
|
||||
CodeChanged,
|
||||
|
@ -108,7 +108,12 @@ fn find_rsx_item(
|
|||
|| new_item.self_ty != old_item.self_ty
|
||||
|| new_item.brace_token != old_item.brace_token
|
||||
}
|
||||
(syn::Item::Macro(new_item), syn::Item::Macro(old_item)) => old_item != new_item,
|
||||
(syn::Item::Macro(new_item), syn::Item::Macro(old_item)) => {
|
||||
find_rsx_macro(&new_item.mac, &old_item.mac, rsx_calls)
|
||||
|| new_item.attrs != old_item.attrs
|
||||
|| new_item.semi_token != old_item.semi_token
|
||||
|| new_item.ident != old_item.ident
|
||||
}
|
||||
(syn::Item::Macro2(new_item), syn::Item::Macro2(old_item)) => old_item != new_item,
|
||||
(syn::Item::Mod(new_item), syn::Item::Mod(old_item)) => {
|
||||
match (&new_item.content, &old_item.content) {
|
||||
|
@ -158,7 +163,7 @@ fn find_rsx_item(
|
|||
(syn::Item::Union(new_item), syn::Item::Union(old_item)) => old_item != new_item,
|
||||
(syn::Item::Use(new_item), syn::Item::Use(old_item)) => old_item != new_item,
|
||||
(syn::Item::Verbatim(_), syn::Item::Verbatim(_)) => false,
|
||||
_ => return true,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -421,23 +426,8 @@ fn find_rsx_expr(
|
|||
|| new_expr.loop_token != old_expr.loop_token
|
||||
}
|
||||
(syn::Expr::Macro(new_expr), syn::Expr::Macro(old_expr)) => {
|
||||
let new_mac = &new_expr.mac;
|
||||
let old_mac = &old_expr.mac;
|
||||
if new_mac.path.get_ident().map(|ident| ident.to_string()) == Some("rsx".to_string())
|
||||
&& matches!(
|
||||
old_mac
|
||||
.path
|
||||
.get_ident()
|
||||
.map(|ident| ident.to_string())
|
||||
.as_deref(),
|
||||
Some("rsx" | "render")
|
||||
)
|
||||
{
|
||||
rsx_calls.push((old_mac.clone(), new_mac.tokens.clone()));
|
||||
false
|
||||
} else {
|
||||
new_expr != old_expr
|
||||
}
|
||||
find_rsx_macro(&new_expr.mac, &old_expr.mac, rsx_calls)
|
||||
|| new_expr.attrs != old_expr.attrs
|
||||
}
|
||||
(syn::Expr::Match(new_expr), syn::Expr::Match(old_expr)) => {
|
||||
if find_rsx_expr(&new_expr.expr, &old_expr.expr, rsx_calls) {
|
||||
|
@ -618,3 +608,30 @@ fn find_rsx_expr(
|
|||
_ => true,
|
||||
}
|
||||
}
|
||||
|
||||
fn find_rsx_macro(
|
||||
new_mac: &syn::Macro,
|
||||
old_mac: &syn::Macro,
|
||||
rsx_calls: &mut Vec<(Macro, TokenStream)>,
|
||||
) -> bool {
|
||||
if matches!(
|
||||
new_mac
|
||||
.path
|
||||
.get_ident()
|
||||
.map(|ident| ident.to_string())
|
||||
.as_deref(),
|
||||
Some("rsx" | "render")
|
||||
) && matches!(
|
||||
old_mac
|
||||
.path
|
||||
.get_ident()
|
||||
.map(|ident| ident.to_string())
|
||||
.as_deref(),
|
||||
Some("rsx" | "render")
|
||||
) {
|
||||
rsx_calls.push((old_mac.clone(), new_mac.tokens.clone()));
|
||||
false
|
||||
} else {
|
||||
new_mac != old_mac
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue