Skip to content

Flattened struct helper functions#273

Open
Exotik850 wants to merge 11 commits into
Bergmann89:masterfrom
Exotik850:flattened-functions
Open

Flattened struct helper functions#273
Exotik850 wants to merge 11 commits into
Bergmann89:masterfrom
Exotik850:flattened-functions

Conversation

@Exotik850

Copy link
Copy Markdown

Add flattened content helpers render step

This PR introduces the FlattenedContentHelpersRenderStep which generates ergonomic helper accessor methods for flattened struct content patterns (e.g., pub struct Foo { pub content: Vec<FooContent>, ... } with pub enum FooContent { ... }). The step creates methods like fn bar(&self) -> Option<&String> and mutable variants thereof for each enum variant, improving usability of generated code.

Changes include:

  • New render step implementation in src/pipeline/renderer/steps/flattened.rs
  • Adds the step to the publicly available render steps
  • Test case verifying generated helper methods for a sample schema

The feature is enabled via the renderer configuration and follows the existing pattern for optional render steps

e.g.

Config::default().with_render_step(FlattenedContentHelpersRenderStep)

@Bergmann89 Bergmann89 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looks good to me, nice work 👍
Some smaller things that need to be cleaned up, then this can be merged 🙃

Comment thread xsd-parser/src/pipeline/renderer/steps/flattened.rs Outdated
Comment thread xsd-parser/src/pipeline/renderer/steps/flattened.rs Outdated
Comment thread xsd-parser/src/pipeline/renderer/steps/content_helper.rs
Comment thread xsd-parser/src/pipeline/renderer/steps/content_helper.rs Outdated
Comment thread xsd-parser/src/pipeline/renderer/steps/flattened.rs Outdated

@Bergmann89 Bergmann89 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

One last thing you forgot to revert 🙃

Comment thread xsd-parser/src/models/naming/mod.rs Outdated
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