slint/tools/syntax_updater/experiments/input_output_properties.rs
Olivier Goffart 5613fc4416 Rename inout property to input output
`inout` and `input` are too similar, so use a longer form for `inout`

CC https://github.com/slint-ui/slint/issues/191#issuecomment-1296176978
2022-10-31 14:57:52 +01:00

28 lines
1,022 B
Rust

// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
use crate::Cli;
use i_slint_compiler::parser::{SyntaxKind, SyntaxNode};
use std::io::Write;
pub(crate) fn fold_node(
node: &SyntaxNode,
file: &mut impl Write,
_state: &mut crate::State,
_args: &Cli,
) -> std::io::Result<bool> {
if node.kind() == SyntaxKind::PropertyDeclaration
&& node
.parent()
.and_then(|n| n.parent())
.map_or(false, |n| n.kind() == SyntaxKind::Component)
{
// check that the first identifier is "property" as opposed to an already converted "input output" token
if node.child_token(SyntaxKind::Identifier).map_or(false, |t| t.text() == "property") {
// Consider that all property are input output, because we don't do enough analysis in the syntax_updater to know
// if they should be private
write!(file, "input output ")?;
}
}
Ok(false)
}