feat: add codegen support for @BoundAny field generation#660
Conversation
📝 WalkthroughWalkthroughAdds Java binding support for Metaschema "any" instances: new AnyInstanceTypeInfoImpl, integration into assembly type-info mapping, a codegen test, and a new checklist document. No runtime behavior changes beyond codegen/typeinfo and tests. Changes
Sequence DiagramsequenceDiagram
participant Codegen as Codegen
participant Assy as AssemblyDefinitionTypeInfoImpl
participant AnyInfo as AnyInstanceTypeInfoImpl
participant Builder as TypeSpec.Builder
Codegen->>Assy: buildInstanceMap(definition)
Assy->>Assy: collect flag & model instances
alt definition.getAnyInstance() != null
Assy->>AnyInfo: wrap(definition.getAnyInstance(), parent)
AnyInfo-->>Assy: AnyInstanceTypeInfoImpl
Assy->>Assy: append AnyInstance to instance stream
end
Assy->>AnyInfo: buildField(typeBuilder, fieldBuilder)
AnyInfo->>Builder: add `@BoundAny` to field
AnyInfo-->>Assy: return (empty set)
Assy-->>Codegen: instance-to-type-info map ready
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 PMD (7.21.0)databind/src/main/java/dev/metaschema/databind/codegen/typeinfo/def/AssemblyDefinitionTypeInfoImpl.java[ERROR] Cannot load ruleset pmd/category/java/custom.xml: Cannot resolve rule/ruleset reference 'pmd/category/java/custom.xml'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath. databind/src/main/java/dev/metaschema/databind/codegen/typeinfo/AnyInstanceTypeInfoImpl.java[ERROR] Cannot load ruleset pmd/category/java/custom.xml: Cannot resolve rule/ruleset reference 'pmd/category/java/custom.xml'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath. databind/src/test/java/dev/metaschema/databind/codegen/AnyCodegenTest.java[ERROR] Cannot load ruleset pmd/category/java/custom.xml: Cannot resolve rule/ruleset reference 'pmd/category/java/custom.xml'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath. Comment |
…framework#220) The code generator now emits @BoundAny-annotated IAnyContent fields when an assembly definition contains <any/> in its model. This complements the runtime <any/> support added in PR metaschema-framework#657 by enabling generated binding classes to capture unmodeled content. Also adds a Claude rule documenting the full scope of changes required when adding new Metaschema model features.
ada24a6 to
d2a9f53
Compare
1ce3494
into
metaschema-framework:develop
Summary
AnyInstanceTypeInfoImplto generate@BoundAny-annotatedIAnyContentfields during code generationAssemblyDefinitionTypeInfoImpl.processModel()to handleIAnyInstancefrom assembly definitionsAnyAssemblyfixtureThis complements PR #657 which added runtime
<any/>support (core model, databind I/O, schemagen) but did not update the code generator. Without this change, generated binding classes for assemblies with<any/>would not capture unmodeled content.Closes #220
Test plan
AnyCodegenTestverifies generated class has@BoundAnyfield of typeIAnyContentwith getter/settermvn clean install -PCI -Prelease) passes with 0 SpotBugs/Checkstyle violationsSummary by CodeRabbit
New Features
Tests
Documentation