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 function = node.parent;
final match = function?.parent?.parent?.parent;
if (function == null ||
match == null ||
function is! FunctionExpression ||
match is! InstanceCreationExpression) {
return;
}
final matchType = match.staticType;
if (matchType == null) return;
final isFirebaseMatch = firebaseMatchChecker.isAssignableFromType(
matchType,
);
final path = resolveMatchPath(arguments: match.argumentList.arguments);
if (path == null) return;
final expectedSignature = _validateSignature(
path: path,
function: function,
isFirebaseMatch: isFirebaseMatch,
);
if (expectedSignature == null) return;
await builder.addDartFileEdit(file, (builder) {
builder.addSimpleReplacement(range.entity(node), expectedSignature);
});
}