Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lsp: Return the node index as well as the Element ref when filtering #4604

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

hunger
Copy link
Member

@hunger hunger commented Feb 12, 2024

Return the node index as well as the &Element itself when filtering nodes on Elements. This allows for easier access/storage of the which node is actually relevant.

Copy link
Member

@ogoffart ogoffart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably would be nice to document a bit more the function. We are in the common module, so it might not be obvious what this do. (also i didn't find the name very obvious, it says it is a filter, but it only take one element.)
I even wonder why this is in common this doesn't seem to be a funciton that would be re-used a lot.

Maybe have a is_ignored_element(&syntax_nodes::Element)->bool would be a function that i can see being re-used.

@hunger
Copy link
Member Author

hunger commented Feb 12, 2024

It takes one element and filters the nodes attached to it. I could turn it into a is_*(...) returning a boolean, true, doing the iteration elsewhere.

... returning a bool.

Do the iteration where needed instead.
@hunger
Copy link
Member Author

hunger commented Feb 12, 2024

Turned this into a function taking an &Element and returning a bool and move the iteration to where it is actually used.

@hunger hunger merged commit 25f0fd1 into slint-ui:master Feb 12, 2024
34 of 35 checks passed
@hunger hunger deleted the lp_dnd_5 branch February 12, 2024 13:59
Comment on lines +32 to +33
.next()
.and_then(|n| {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of ? would simplify this function slightly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants