File tree Expand file tree Collapse file tree 2 files changed +44
-4
lines changed Expand file tree Collapse file tree 2 files changed +44
-4
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ use clap::Parser;
2424
2525mod from_0_0_5;
2626mod from_0_0_6;
27+ mod from_0_1_0;
2728
2829#[ derive( clap:: Parser ) ]
2930struct 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
229233fn fold_token (
You can’t perform that action at this time.
0 commit comments