Skip to content

Commit

Permalink
Remove deprecated Keys enum in slint language
Browse files Browse the repository at this point in the history
ogoffart committed Jan 26, 2023
1 parent 5951ae6 commit 5bb84c1
Showing 3 changed files with 9 additions and 17 deletions.
5 changes: 0 additions & 5 deletions internal/compiler/lookup.rs
Original file line number Diff line number Diff line change
@@ -97,7 +97,6 @@ pub enum LookupResult {
pub enum BuiltinNamespace {
Colors,
Math,
Keys,
Key,
SlintInternal,
}
@@ -112,7 +111,6 @@ impl LookupResult {
pub fn deprecated(&self) -> Option<&str> {
match self {
Self::Expression { deprecated: Some(x), .. } => Some(x.as_str()),
Self::Namespace(BuiltinNamespace::Keys) => Some("Key"),
_ => None,
}
}
@@ -162,7 +160,6 @@ impl LookupObject for LookupResult {
(ColorSpecific, ColorFunctions).for_each_entry(ctx, f)
}
LookupResult::Namespace(BuiltinNamespace::Math) => MathFunctions.for_each_entry(ctx, f),
LookupResult::Namespace(BuiltinNamespace::Keys) => KeysLookup.for_each_entry(ctx, f),
LookupResult::Namespace(BuiltinNamespace::Key) => KeysLookup.for_each_entry(ctx, f),
LookupResult::Namespace(BuiltinNamespace::SlintInternal) => {
SlintInternal.for_each_entry(ctx, f)
@@ -178,7 +175,6 @@ impl LookupObject for LookupResult {
(ColorSpecific, ColorFunctions).lookup(ctx, name)
}
LookupResult::Namespace(BuiltinNamespace::Math) => MathFunctions.lookup(ctx, name),
LookupResult::Namespace(BuiltinNamespace::Keys) => KeysLookup.lookup(ctx, name),
LookupResult::Namespace(BuiltinNamespace::Key) => KeysLookup.lookup(ctx, name),
LookupResult::Namespace(BuiltinNamespace::SlintInternal) => {
SlintInternal.lookup(ctx, name)
@@ -733,7 +729,6 @@ impl LookupObject for BuiltinNamespaceLookup {
) -> Option<R> {
None.or_else(|| f("Colors", LookupResult::Namespace(BuiltinNamespace::Colors)))
.or_else(|| f("Math", LookupResult::Namespace(BuiltinNamespace::Math)))
.or_else(|| f("Keys", LookupResult::Namespace(BuiltinNamespace::Keys)))
.or_else(|| f("Key", LookupResult::Namespace(BuiltinNamespace::Key)))
.or_else(|| {
f("SlintInternal", LookupResult::Namespace(BuiltinNamespace::SlintInternal))
10 changes: 0 additions & 10 deletions internal/compiler/tests/syntax/lookup/deprecated_property.slint
Original file line number Diff line number Diff line change
@@ -24,14 +24,4 @@ export Xxx := Rectangle {
// ^warning{The property 'color' has been deprecated. Please use 'background' instead}
}

Foo := FocusScope {
key-pressed(event) => {
if (event.text == Keys.Escape) {
// ^warning{The property 'Keys' has been deprecated. Please use 'Key' instead}
debug("Esc key was pressed")
}
accept
}
}

}
11 changes: 9 additions & 2 deletions tools/updater/transforms/renames.rs
Original file line number Diff line number Diff line change
@@ -15,13 +15,20 @@ pub(crate) fn fold_node(
if kind == SyntaxKind::QualifiedName
&& node.parent().map_or(false, |n| n.kind() == SyntaxKind::Expression)
{
let q = i_slint_compiler::object_tree::QualifiedTypeName::from_node(node.clone().into());
if q.to_string() == "PointerEventButton.none" {
let q = i_slint_compiler::object_tree::QualifiedTypeName::from_node(node.clone().into())
.to_string();
if q == "PointerEventButton.none" {
for t in node.children_with_tokens() {
let text = t.into_token().unwrap().to_string();
write!(file, "{}", if text == "none" { "other" } else { &text })?;
}
return Ok(true);
} else if q.starts_with("Keys.") {
for t in node.children_with_tokens() {
let text = t.into_token().unwrap().to_string();
write!(file, "{}", if text == "Keys" { "Key" } else { &text })?;
}
return Ok(true);
}
}

0 comments on commit 5bb84c1

Please sign in to comment.