Skip to content

Commit ab09ef8

Browse files
committed
Update
1 parent 39ae298 commit ab09ef8

File tree

2 files changed

+107
-2
lines changed

2 files changed

+107
-2
lines changed

crates/parser/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mxmlextrema-as3parser"
3-
version = "1.5.4"
3+
version = "1.6.0"
44
edition = "2021"
55
authors = ["Matheus Dias de Souza <[email protected]>"]
66
repository = "https://github.com/mxmlextrema/as3parser"

crates/parser/tree/css.rs

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,30 @@ impl CssSelector {
121121
}
122122
}
123123

124+
impl Eq for CssSelector {}
125+
126+
impl PartialEq for CssSelector {
127+
fn eq(&self, other: &Self) -> bool {
128+
match self {
129+
Self::Invalidated(_) => matches!(other, Self::Invalidated(_)),
130+
Self::Base(v1) => {
131+
if let Self::Base(v2) = other {
132+
v1 == v2
133+
} else {
134+
false
135+
}
136+
},
137+
Self::Combinator(v1) => {
138+
if let Self::Combinator(v2) = other {
139+
v1 == v2
140+
} else {
141+
false
142+
}
143+
},
144+
}
145+
}
146+
}
147+
124148
/// Array property values are comma-separated values in CSS properties.
125149
///
126150
/// For example:
@@ -156,6 +180,16 @@ pub struct CssBaseSelector {
156180
pub conditions: Vec<Rc<CssSelectorCondition>>,
157181
}
158182

183+
impl Eq for CssBaseSelector {}
184+
185+
impl PartialEq for CssBaseSelector {
186+
fn eq(&self, other: &Self) -> bool {
187+
self.namespace_prefix.as_ref().map(|p| &p.0) == other.namespace_prefix.as_ref().map(|p| &p.0) &&
188+
self.element_name.as_ref().map(|n| &n.0) == other.element_name.as_ref().map(|n| &n.0) &&
189+
self.conditions == other.conditions
190+
}
191+
}
192+
159193
/// Supported condition types for [`CssSelectorCondition`].
160194
#[derive(Clone, Serialize, Deserialize)]
161195
pub enum CssSelectorCondition {
@@ -185,7 +219,68 @@ pub enum CssSelectorCondition {
185219
},
186220
}
187221

188-
#[derive(Clone, Serialize, Deserialize)]
222+
impl Eq for CssSelectorCondition {}
223+
224+
impl PartialEq for CssSelectorCondition {
225+
fn eq(&self, other: &Self) -> bool {
226+
match self {
227+
Self::Invalidated(_) => matches!(other, Self::Invalidated(_)),
228+
Self::Class((v1, _)) => {
229+
if let Self::Class((v2, _)) = other {
230+
v1 == v2
231+
} else {
232+
false
233+
}
234+
},
235+
Self::Id((v1, _)) => {
236+
if let Self::Id((v2, _)) = other {
237+
v1 == v2
238+
} else {
239+
false
240+
}
241+
},
242+
Self::Pseudo((v1, _)) => {
243+
if let Self::Pseudo((v2, _)) = other {
244+
v1 == v2
245+
} else {
246+
false
247+
}
248+
},
249+
Self::PseudoElement((v1, _)) => {
250+
if let Self::PseudoElement((v2, _)) = other {
251+
v1 == v2
252+
} else {
253+
false
254+
}
255+
},
256+
Self::NthChild((v1, _)) => {
257+
if let Self::NthChild((v2, _)) = other {
258+
v1 == v2
259+
} else {
260+
false
261+
}
262+
},
263+
Self::Not { condition: c1, .. } => {
264+
if let Self::Not { condition: c2, ..} = other {
265+
c1 == c2
266+
} else {
267+
false
268+
}
269+
},
270+
Self::Attribute { name: (name1, _), operator: op1, value: value1, .. } => {
271+
let value1 = value1.as_ref().map(|(v, _)| v);
272+
if let Self::Attribute { name: (name2, _), operator: op2, value: value2, .. } = other {
273+
let value2 = value2.as_ref().map(|(v, _)| v);
274+
name1 == name2 && op1 == op2 && value1 == value2
275+
} else {
276+
false
277+
}
278+
},
279+
}
280+
}
281+
}
282+
283+
#[derive(Clone, Serialize, Deserialize, PartialEq, Eq)]
189284
pub enum CssNthChildKind {
190285
Invalidated,
191286
Odd,
@@ -367,6 +462,16 @@ pub struct CssCombinatorSelector {
367462
pub combinator_type: CssCombinatorType,
368463
}
369464

465+
impl Eq for CssCombinatorSelector {}
466+
467+
impl PartialEq for CssCombinatorSelector {
468+
fn eq(&self, other: &Self) -> bool {
469+
self.left == other.left &&
470+
self.right == other.right &&
471+
self.combinator_type == other.combinator_type
472+
}
473+
}
474+
370475
/// The root object of a CSS DOM. The CSS3 DOM objects serve not only IDE
371476
/// features in code model, but also CSS compilation.
372477
#[derive(Clone, Serialize, Deserialize)]

0 commit comments

Comments
 (0)