insertDeployFunctions static method

String? insertDeployFunctions(
  1. String source,
  2. List<String> functions
)

Insert functions into the m.deploy([...]) array in source.

Returns null if the deploy array cannot be found.

source内のm.deploy([...])配列にfunctionsを挿入します。

deploy配列が見つからない場合はnullを返します。

Implementation

static String? insertDeployFunctions(
  String source,
  List<String> functions,
) {
  if (functions.isEmpty) {
    return source;
  }
  final deployFunctions = _findDeployFunctions(source);
  if (deployFunctions == null) {
    return null;
  }
  final insert =
      "${_needsLeadingComma(source, deployFunctions) ? "," : ""}\n${functions.join("\n")}";
  return source.replaceRange(
    deployFunctions.end,
    deployFunctions.end,
    insert,
  );
}