ON_invocationFindByMethodName method

  1. @override
MethodManagerResultData ON_invocationFindByMethodName({
  1. String? replacementHandlerBody,
})
override

Implementation

@override
MethodManagerResultData ON_invocationFindByMethodName({
  String? replacementHandlerBody,
}) {
  final visitor = ON_invocationFindByMethodNameVisitor(methodName!);
  parsedFileUnit.visitChildren(visitor);
  if (visitor.result == null) {
    return dataSingleton;
  }
  if (replacementHandlerBody == null) {
    dataSingleton.addTaskResultValue(visitor.result);
    return dataSingleton;
  }

  String? fullNewSourceCode;
  fullNewSourceCode = parsedFileContent.replaceRange(
    visitor.result!.handlerBody.offset,
    visitor.result!.handlerBody.end,
    replacementHandlerBody.trim(),
  );
  dataSingleton.addTaskResultValue(visitor.result, {
    "fullNewSourceCode": fullNewSourceCode,
  });
  return dataSingleton;
}