Skip to content

fix(dart/transform) Merge setter registrations with the same name #886

Closed
@kegluneq

Description

@kegluneq

Currently we generate one setter registration per bind value. For example, this annotation:

'bind': {'text': 'tool-tip'}

attached to two classes, A and B would generate

registerSetters({'text': (A obj, String value) => obj.text = value})
registerSetters({'text': (B obj, String value) => obj.text = value})

Instead we need to generate a single setter registration using a common parent class of A and B. This would be tough to do without resolving in our transformer, which we would like to avoid. As a first approximation, we can omit the parameter type (A and B above) which will be interpreted as dynamic.

To do this, we need global knowledge of the setters which would be registered.

  1. Modify the bind_generator transformer, its primary inputs are the .ngDeps.dart files generated by the app entry points.
  2. Parse these files, gathering information on the setters to be generated.
  3. Also parse all .ngDeps.dart files imported by the primary inputs.
  4. Where there are multiple setters for a single property, remove type information from the registered setter.
  5. Output a .ngSetters.dart file with a setupReflection method that registers all setters.
  6. Generate code to import and call setupReflection during app setup.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions