compute method
Computes the changes for this producer using builder.
This method should not modify fixKind.
Implementation
@override
Future<void> compute(ChangeBuilder builder) async {
final classDecl = node.thisOrAncestorOfType<ClassDeclaration>();
if (classDecl == null) return;
if (getToStringMethod(classDecl) != null) return;
final className = getClassName(classDecl);
final classFieldNames = getClassFields(
classDecl,
).map((field) => field.name);
await builder.addDartFileEdit(file, (builder) {
final insertOffset = classDecl.rightBracket.offset;
builder.addInsertion(insertOffset, (builder) {
builder.write(buildToStringSnippet(className, classFieldNames));
});
builder.format(SourceRange(0, unitResult.content.length));
});
}