amazon-ion / ion-cli

Apache License 2.0
31 stars 15 forks source link

Changes to generate anonymous types inside parent type's namespace #109

Closed desaikd closed 3 months ago

desaikd commented 3 months ago

Issue #103:

Description of changes:

This PR works on first portion of #103 issue which is defining a namespace corresponding to parent type for anonymous types. As described in the issue:

Generated code:

List of changes:


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

desaikd commented 3 months ago

Do the generated unit tests exercise this new functionality?

Yes, it does. The nested_struct.isl file contains a 2-level anonymous type/nested type for which the code generates, In Java the anonymous class into the parent class and for Rust the anonymous struct into parent struct's module.

desaikd commented 3 months ago

As per the conversation in this PR and offline, it would be simpler to express sequence and scalar nested types as is instead of creating another nested class/struct for it. This will be implemented in a separate PR. Example ISL:

type::{
   name: foo,
   fields: {
      sequence_type: { type: list, element: int },
      scalar_type: { type: string }
   }
}

Output Java:

class Foo {
   private sequence_type: ArrayList<Integer>; // current impl would treat it as `NestedTypeX`
   private scalar_type: String; // current impl would treat it as `NestedTypeY`
   ...
}