Skip to content

Handle Properties in kdl #2088

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

Merged
merged 11 commits into from
Aug 1, 2025
Merged

Conversation

Bashamega
Copy link
Contributor

reference #2053

I've added support for handling properties and refactored the mixin handling into smaller, more manageable functions.

…vents and properties from mixin nodes. Update `handleMixin` to utilize these new functions, improving code organization and clarity.
Copy link
Contributor

Thanks for the PR!

This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged.

mixins[name] = { name, events: { event } };

const event: Event[] = extractMixinEvents(node);
const property: Properties = extractMixinProperties(node);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'd want to iterate on children rather than filtering, so that if there's an unknown child then it can throw. Just like how handleMixin is called from parseKDL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it now better @saschanaz, I have updated it :)

property[name] = {
name,
exposed: child.properties?.exposed as string,
};
Copy link
Contributor

Choose a reason for hiding this comment

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

I think separate functions for each is better, as I'm sure this will become longer, even for property alone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have created smaller functions @saschanaz, would you prefer smaller files?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this wouldn't become super huge to justify extra modules, for now let's keep it this way and see how it goes.

* @param child The child node to handle.
* @param event The event array to update.
*/
function handleEventChild(child: Node, event: Event[], name: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Every event will be child so no need to have Child in the name. Same for property.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have renamed it @saschanaz

* @param event The event array to update.
*/
function handleEvent(child: Node, event: Event[], name: string) {
event.push({
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we return Event here and do event.push in the caller? Like event.push(handleEvent(child)).

Also probably better to get the name in each function, as I think not all members will have a name, e.g. constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated it for events and properties

Copy link
Contributor

@saschanaz saschanaz left a comment

Choose a reason for hiding this comment

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

LGTM with nits

Bashamega and others added 4 commits August 1, 2025 07:27
Co-authored-by: Kagami Sascha Rosylight <saschanaz@outlook.com>
Co-authored-by: Kagami Sascha Rosylight <saschanaz@outlook.com>
@Bashamega
Copy link
Contributor Author

Thank you @saschanaz,
I have updated it

Copy link
Contributor

@saschanaz saschanaz left a comment

Choose a reason for hiding this comment

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

LGTM

}
}

mixins[name] = { name, events: { event }, properties: { property } };
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to return a value as handleProperty now does. But as handleEnum already does this, this can be done in a separate PR.

@saschanaz
Copy link
Contributor

LGTM

@github-actions github-actions bot merged commit 40a54bf into microsoft:main Aug 1, 2025
5 of 6 checks passed
Copy link
Contributor

github-actions bot commented Aug 1, 2025

Merging because @saschanaz is a code-owner of all the changes - thanks!

@Bashamega Bashamega deleted the kdl/property branch August 2, 2025 04:33
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.

3 participants