Skip to content

Commit 458c88c

Browse files
committed
Update loop-count to iteration-count in PropertyAnimation
1 parent b348d1a commit 458c88c

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

tools/syntax_updater/from_0_1_0.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright © SixtyFPS GmbH <[email protected]>
2+
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
3+
4+
use std::io::Write;
5+
6+
use sixtyfps_compilerlib::parser::{syntax_nodes, SyntaxNode};
7+
8+
/// Rename `loop-count` to `iteration-count` in `PropertyAnimation`s
9+
pub(crate) fn fold_node(
10+
node: &SyntaxNode,
11+
file: &mut impl Write,
12+
state: &mut crate::State,
13+
) -> std::io::Result<bool> {
14+
if let Some(binding) = syntax_nodes::Binding::new(node.clone()) {
15+
let property_name = state.property_name.as_deref().unwrap_or_default();
16+
if (property_name == "loop-count" || property_name == "loop_count")
17+
&& has_parent_anim(&binding.clone().into())
18+
{
19+
let text = node.text().to_string();
20+
let text = text.replace("loop-count", "iteration-count");
21+
let text = text.replace("loop_count", "iteration-count");
22+
file.write_all(text.as_bytes())?;
23+
return Ok(true);
24+
}
25+
};
26+
Ok(false)
27+
}
28+
29+
fn has_parent_anim(node: &SyntaxNode) -> bool {
30+
let node = node.parent();
31+
if let Some(node) = node {
32+
syntax_nodes::PropertyAnimation::new(node).is_some()
33+
} else {
34+
false
35+
}
36+
}

tools/syntax_updater/main.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use clap::Parser;
2424

2525
mod from_0_0_5;
2626
mod from_0_0_6;
27+
mod from_0_1_0;
2728

2829
#[derive(clap::Parser)]
2930
struct Cli {
@@ -219,11 +220,14 @@ fn fold_node(
219220
if args.from == "0.0.5" && from_0_0_5::fold_node(node, file, state)? {
220221
return Ok(true);
221222
}
222-
if args.from.as_str() <= "0.0.6" {
223-
from_0_0_6::fold_node(node, file, state)
224-
} else {
225-
Ok(false)
223+
if args.from.as_str() <= "0.0.6" && from_0_0_6::fold_node(node, file, state)? {
224+
return Ok(true);
225+
}
226+
if args.from.as_str() <= "0.1.0" && from_0_1_0::fold_node(node, file, state)? {
227+
return Ok(true);
226228
}
229+
230+
Ok(false)
227231
}
228232

229233
fn fold_token(

0 commit comments

Comments
 (0)