Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix ParentVars and IsInherited for Java #5232
The first step in being able to add overrides to parent fluent setters is to get the isInherited and parentVars props working so the templates can know that a particular var is inherited.
Looking at the other languages, inheritance seems to be handled above the DefaultCodegen class. I take this to mean that inheritance rules likely vary between languages so it needs to go in to a language specific generator class. I figured all Java inheritance is the same, so put these changes in the AbstractJavaCodegen that everything should extend from.
I also copied a test from the JavaCodegenClientTest and made it more robust by actually checking parentVars and isInherited props. These tests validated that the parent child relationship exists between CodegenModels, but not on the child properties etc. TDD style, these tests failed until I made the code changes.
The current implementation is very naive. It assumes that all variables shared between the parent and child are inherited. I chose this route because there may be multiple layers of inheritance, so any inherited props from the grandparent should be considered inherited on the child as well.