PatchEngine class

Applies contributions to the files under projectRoot.

Mustache placeholders, such as {{app_name_sc}}, are rendered with mustacheVariables in the text that contributions insert. The code that is already in the files is never rendered.

For the contribution types of this package, only the fields that hold new code are rendered, such as InsertIntoFunction.insert or ReplaceWidget.toWidget; the fields that find the target, such as function names and anchors, are matched as written. A contribution of any other type, a subclass included, is applied first and its result rendered, with the {{ that was already in the file kept out of it.

Each file is read once, gets its contributions in list order and is written back once. A failure leaves the file being patched untouched, but the files written before it stay patched.

Constructors

PatchEngine(List<Contribution> contributions, {required String projectRoot, Map? mustacheVariables, Logger? logger})
Creates an engine that applies contributions to the files under projectRoot.
const

Properties

contributions → List<Contribution>
The changes to apply, in list order within each file.
final
hashCode → int
The hash code for this object.
no setterinherited
logger → Logger?
Reports the progress of each file, when given.
final
mustacheVariables → Map?
The values of the placeholders, such as {'app_name': 'shop app'}.
final
projectRoot → String
The directory that each Contribution.file is relative to.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

applyAll() → Future<void>
Applies contributions and writes the patched files back.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited