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

Rename node helpers #187

Merged
merged 3 commits into from
Apr 25, 2021
Merged

Rename node helpers #187

merged 3 commits into from
Apr 25, 2021

Conversation

CedNaru
Copy link
Member

@CedNaru CedNaru commented Apr 24, 2021

Extensions are now in their own package and I split them into 2 files, one for Object, one for Node.

Also because of a conflict with the "getNode" name, the helpers have been rename simple "node".

related issue : #183

@CedNaru CedNaru linked an issue Apr 24, 2021 that may be closed by this pull request
Comment on lines 7 to 10
inline fun <T : Node> Node.node(path: String) = getNode(NodePath(path)) as T?

@Suppress("NOTHING_TO_INLINE", "UNCHECKED_CAST")
inline fun <T : Node> Node.node(nodePath: NodePath) = getNode(nodePath) as T?
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the rename necessary? It works for me if they just have a different package path.

Copy link
Member Author

Choose a reason for hiding this comment

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

It works for getNode(String) but not for getNode(NodePath) in my case.

Copy link
Contributor

Choose a reason for hiding this comment

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

1.png
Hmm it does for me

Copy link
Member Author

Choose a reason for hiding this comment

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

it's suggested but when I select it, it still doesn't work, the import is not made so I just get a red line.

Copy link
Contributor

Choose a reason for hiding this comment

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

might be good to test out latest kotlin versions and enabling JVM IR - from what I understand the code still compiles but the only IDE marks it as red?

Copy link
Contributor

@raniejade raniejade left a comment

Choose a reason for hiding this comment

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

I like the package change, but I'm not too sure about the rename.

@raniejade
Copy link
Contributor

I just did a test, moving to a different package only hides the issue - when you start using the helpers the problem can occur - so a rename is a must. I think we need a way to tell the helper is connected to getNode, WDYT about using something like getNodeOfType or maybe getNodeAs?

@chippmann
Copy link
Contributor

Hmm weird. I dont seem to have those issues. Anyways. Then I'm all in for either just node or getNodeAs.
The latter would even be more "normal" for generic functions i think

@raniejade
Copy link
Contributor

getNodeAs is a bit a more descriptive since the helper justs calls getNode and attempts to cast it to the reified type.

@CedNaru
Copy link
Member Author

CedNaru commented Apr 25, 2021

GetNodeAs seems nice, it creates a whole sentence that way getNodeAs<Button>

@CedNaru CedNaru merged commit 1bee833 into master Apr 25, 2021
@CedNaru CedNaru deleted the fix/node-helpers branch April 25, 2021 14:29
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.

getNode extension function shadowed by member
3 participants