1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
3 | |
4 | use crate::Cli; |
5 | use i_slint_compiler::parser::{SyntaxKind, SyntaxNode}; |
6 | use std::io::Write; |
7 | |
8 | pub(crate) fn fold_node( |
9 | node: &SyntaxNode, |
10 | file: &mut impl Write, |
11 | _state: &mut crate::State, |
12 | _args: &Cli, |
13 | ) -> std::io::Result<bool> { |
14 | let kind: SyntaxKind = node.kind(); |
15 | if kind == SyntaxKind::QualifiedName |
16 | && node.parent().map_or(default:false, |n: SyntaxNode| n.kind() == SyntaxKind::Expression) |
17 | { |
18 | let q: String = i_slint_compilerQualifiedTypeName::object_tree::QualifiedTypeName::from_node(node.clone().into()) |
19 | .to_string(); |
20 | if q == "PointerEventButton.none" { |
21 | for t: NodeOrToken in node.children_with_tokens() { |
22 | let text: String = t.into_token().unwrap().to_string(); |
23 | write!(file, " {}" , if text == "none" { "other" } else { &text })?; |
24 | } |
25 | return Ok(true); |
26 | } else if q.starts_with("Keys." ) { |
27 | for t: NodeOrToken in node.children_with_tokens() { |
28 | let text: String = t.into_token().unwrap().to_string(); |
29 | write!(file, " {}" , if text == "Keys" { "Key" } else { &text })?; |
30 | } |
31 | return Ok(true); |
32 | } |
33 | } |
34 | |
35 | Ok(false) |
36 | } |
37 | |