Patch.fromAstNode constructor

Patch.fromAstNode(
  1. AstNode astNode, {
  2. required String replaceTo,
})

Implementation

factory Patch.fromAstNode(
  AstNode astNode, {
  required String replaceTo,
}) {
  return Patch(
    replaceTo: replaceTo,
    offset: astNode.offset,
    // if Directive should include the `\n`
    length: astNode.length + (astNode is Directive ? 1 : 0),
  );
}