Rename @image-url(..., 9slice(...)) to @image-url(..., nine-slice(...))

As per API review:
 - In the Rust and C++ API we use `set_nine_slice_edges` because the getter couldn't start with 9
 - in english we spell number less than 10 with letters and this is a name
This commit is contained in:
Olivier Goffart 2024-03-07 14:36:39 +01:00
parent c588013530
commit 255dc59ef4
13 changed files with 62 additions and 62 deletions

View file

@ -219,7 +219,7 @@ impl<'a, T> Display for DisplayExpression<'a, T> {
Expression::ImageReference { resource_ref, nine_slice } => {
write!(f, "{:?}", resource_ref)?;
if let Some(nine_slice) = &nine_slice {
write!(f, "9slice({:?})", nine_slice)?;
write!(f, "nine-slice({:?})", nine_slice)?;
}
Ok(())
}

View file

@ -417,8 +417,8 @@ fn parse_tr(p: &mut impl Parser) {
/// ```test,AtImageUrl
/// @image-url("foo.png")
/// @image-url("foo.png",)
/// @image-url("foo.png", 9slice(1 2 3 4))
/// @image-url("foo.png", 9slice(1))
/// @image-url("foo.png", nine-slice(1 2 3 4))
/// @image-url("foo.png", nine-slice(1))
/// ```
fn parse_image_url(p: &mut impl Parser) {
let mut p = p.start_node(SyntaxKind::AtImageUrl);
@ -449,8 +449,8 @@ fn parse_image_url(p: &mut impl Parser) {
if p.test(SyntaxKind::RParent) {
return;
}
if p.peek().as_str() != "9slice" {
p.error("Expected '9slice(...)' argument");
if p.peek().as_str() != "nine-slice" {
p.error("Expected 'nine-slice(...)' argument");
p.until(SyntaxKind::RParent);
return;
}
@ -474,7 +474,7 @@ fn parse_image_url(p: &mut impl Parser) {
p.consume();
}
SyntaxKind::Comma | SyntaxKind::Colon => {
p.error("Arguments of 9slice need to be separated by spaces");
p.error("Arguments of nine-slice need to be separated by spaces");
p.until(SyntaxKind::RParent);
break;
}

View file

@ -369,16 +369,16 @@ impl Expression {
.children_with_tokens()
.filter_map(|n| n.into_token())
.filter(|t| t.kind() == SyntaxKind::NumberLiteral)
.skip(1) // slip "9slice"
.map(|arg| {
arg.text().parse().unwrap_or_else(|err: std::num::ParseIntError| {
match err.kind() {
IntErrorKind::PosOverflow | IntErrorKind::NegOverflow => {
ctx.diag.push_error("Number too big".into(), &arg)
}
IntErrorKind::InvalidDigit => ctx
.diag
.push_error("Border widths of a 9slice can't have units".into(), &arg),
IntErrorKind::InvalidDigit => ctx.diag.push_error(
"Border widths of a nine-slice can't have units".into(),
&arg,
),
_ => ctx.diag.push_error("Cannot parse number literal".into(), &arg),
};
0u16

View file

@ -15,34 +15,34 @@ export component SuperSimple {
property <image> i6: @image-url;
// ^error{Syntax error: expected '\('}
property <image> i7: @image-url("foo", "bar");
// ^error{Expected '9slice\(...\)' argument}
// ^error{Expected 'nine-slice\(...\)' argument}
property <image> i8: @image-url("foo", xyz(abc));
// ^error{Expected '9slice\(...\)' argument}
property <image> i9: @image-url("foo", 9slice(abc));
// ^error{Expected number literal or '\)'}
property <image> i10: @image-url("foo", 9slice(1 2 3));
// ^error{Expected 1 or 2 or 4 numbers}
property <image> i11: @image-url("foo", 9slice());
// ^error{Expected 1 or 2 or 4 numbers}
property <image> i12: @image-url("foo", 9slice(1 2 3 4 5));
// ^error{Expected 'nine-slice\(...\)' argument}
property <image> i9: @image-url("foo", nine-slice(abc));
// ^error{Expected number literal or '\)'}
property <image> i10: @image-url("foo", nine-slice(1 2 3));
// ^error{Expected 1 or 2 or 4 numbers}
property <image> i13: @image-url("foo", 9slice(1 2 foobar 4 5));
property <image> i11: @image-url("foo", nine-slice());
// ^error{Expected 1 or 2 or 4 numbers}
property <image> i12: @image-url("foo", nine-slice(1 2 3 4 5));
// ^error{Expected 1 or 2 or 4 numbers}
property <image> i13: @image-url("foo", nine-slice(1 2 foobar 4 5));
// ^error{Expected number literal or '\)'}
property <image> i14: @image-url("foo", nine-slice);
// ^error{Syntax error: expected '\('}
property <image> i15: @image-url("foo", nine-slice,);
// ^error{Syntax error: expected '\('}
property <image> i16: @image-url("foo", nine-slice 42 42);
// ^error{Syntax error: expected '\('}
property <image> i17: @image-url("foo", nine-slice(1px)); // error reported later
property <image> i18: @image-url("foo", nine-slice(1%)); // error reported later
property <image> i19: @image-url("foo", nine-slice(1, 2));
// ^error{Arguments of nine-slice need to be separated by spaces}
property <image> i20: @image-url("foo", nine-slice(2 + 3 ));
// ^error{Expected number literal or '\)'}
property <image> i21: @image-url("foo", nine-slice(2 -3 ));
// ^error{Expected number literal or '\)'}
property <image> i22: @image-url("foo", nine-slice(-2));
// ^error{Expected number literal or '\)'}
property <image> i14: @image-url("foo", 9slice);
// ^error{Syntax error: expected '\('}
property <image> i15: @image-url("foo", 9slice,);
// ^error{Syntax error: expected '\('}
property <image> i16: @image-url("foo", 9slice 42 42);
// ^error{Syntax error: expected '\('}
property <image> i17: @image-url("foo", 9slice(1px)); // error reported later
property <image> i18: @image-url("foo", 9slice(1%)); // error reported later
property <image> i19: @image-url("foo", 9slice(1, 2));
// ^error{Arguments of 9slice need to be separated by spaces}
property <image> i20: @image-url("foo", 9slice(2 + 3 ));
// ^error{Expected number literal or '\)'}
property <image> i21: @image-url("foo", 9slice(2 -3 ));
// ^error{Expected number literal or '\)'}
property <image> i22: @image-url("foo", 9slice(-2));
// ^error{Expected number literal or '\)'}
property <image> i22: @image-url("foo", 9slice(123456789));
property <image> i22: @image-url("foo", nine-slice(123456789));
}

View file

@ -2,14 +2,14 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
export component SuperSimple {
property <image> i17: @image-url("foo", 9slice(1px));
// ^error{Border widths of a 9slice can't have units}
property <image> i18: @image-url("foo", 9slice(1%));
// ^error{Border widths of a 9slice can't have units}
property <image> i22: @image-url("foo", 9slice(123456789));
// ^error{Number too big}
property <image> j01: @image-url("foo", 9slice(1 52deg 456456456 12abc));
// ^error{Border widths of a 9slice can't have units}
// ^^error{Border widths of a 9slice can't have units}
// ^^^error{Number too big}
property <image> i17: @image-url("foo", nine-slice(1px));
// ^error{Border widths of a nine-slice can't have units}
property <image> i18: @image-url("foo", nine-slice(1%));
// ^error{Border widths of a nine-slice can't have units}
property <image> i22: @image-url("foo", nine-slice(123456789));
// ^error{Number too big}
property <image> j01: @image-url("foo", nine-slice(1 52deg 456456456 12abc));
// ^error{Border widths of a nine-slice can't have units}
// ^^error{Border widths of a nine-slice can't have units}
// ^^^error{Number too big}
}