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;
final copyWithMethod = getCopyWithMethod(classDecl);
if (copyWithMethod == null) return;
if (getMissingFieldsInCopyWith(classDecl, copyWithMethod).isEmpty) {
return;
}
await builder.addDartFileEdit(file, (builder) {
final methodRange = copyWithMethod.offset;
final methodLength = copyWithMethod.length;
final replacementSnippet = buildCopyWithSnippet(classDecl);
if (replacementSnippet != null) {
builder.addSimpleReplacement(
SourceRange(methodRange, methodLength),
replacementSnippet,
);
builder.format(SourceRange(0, unitResult.content.length));
}
});
}