InsertIntoFunction class
Inserts statements into the body of a top-level function, next to the statements that contain an anchor text.
The target is the first top-level function named function; methods don't count. insert goes before each statement of its body whose source contains beforeStatement, and after each one that contains afterStatement, the source being the statement as the parser prints it. Only the statements directly in the body are checked, not those nested in blocks, and when none matches nothing is inserted.
Throws an Exception when the function is missing or has an expression
body, and a FormatterException when insert leaves invalid code.
When the body already has the statements of insert in a row, as the parser prints them, nothing is inserted, so running it again changes nothing; an insert of nothing but comments is added on every run.
Only the new lines are added: the comments and blank lines of the body stay, and a comment above a statement stays with it. The whole file is then reformatted, or returned as it is when nothing is inserted.
- Inheritance
-
- Object
- Contribution
- InsertIntoFunction
Constructors
Properties
- afterStatement → String?
-
Text that marks the statements to insert after, such as
WidgetsFlutterBinding.ensureInitialized.final - beforeStatement → String?
-
Text that marks the statements to insert before, such as
runApp(.final - dartFormater → DartFormatter
-
The formatter contributions run over the code they produce.
no setterinherited
- file → String
-
The path of the file to change, relative to the project root.
finalinherited
- function → String
-
The name of the top-level function to patch, such as
main.final - hashCode → int
-
The hash code for this object.
no setterinherited
- insert → String
-
The statements to insert.
PatchEnginerenders its placeholders.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
apply(
String original) → Future< String> -
Returns
original, the content of file, with this change applied.override -
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