Make it possible to augment constructor initializer in FieldDefinitionMacro #56337
Open
Description
To clarify, I refer specifically to FieldDefinitionMacros. I believe it's already possible to augment constructor initializers in ClassDefinitionMacro.
Now we can augment field initializer (though not implemented yet)
builder.augment(
initializer: ExpressionCode.fromParts([
observableListClazz,
"(augmented)",
]),
);
I think it's reasonable to allow augmenting constructor initializer for this field:
builder.augment(
constructorInitializer: ExpressionCode.fromParts([
observableListClazz,
"(augmented)",
]),
);
Or may be just duplicate initializer's ExpressionCode to constructor if field doesn't have initializer.
Before:
class MyClass {
@observable
final List<String> names;
MyClass(this.name);
}
After:
augment class MyClass {
augment MyClass(List<String> names): this.names = generatedCodeByMacro(augmented)
}