InsertIntoListInMethodInClass class
Adds an element at the end of a list literal passed as a named argument
in a method, such as the supportedLocales of the MaterialApp built in
MainApp.build.
The target is the first method named method in the first class named className. In its body, the candidates are the lists passed as a listVariableMatch argument, nested ones included, to a call or widget creation that matches parentExpressionMatch; index picks one of them in source order, and insert goes last in it, past a comment that trails its last element on its line.
Throws an Exception when the class or the method is missing, when the method body is an expression, or when there is no candidate at index.
When the list already has every element of insert, as the parser prints them, the file is returned as it is, so running it again changes nothing. Comments in the file are kept, but the whole file is reformatted.
- Inheritance
-
- Object
- Contribution
- InsertIntoListInMethodInClass
Constructors
Properties
- className → String
-
The name of the class that declares method, such as
MainApp.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
- hashCode → int
-
The hash code for this object.
no setterinherited
- index → int
-
Which of the matching lists to change, counting from zero in source
order.
final
- insert → String
-
The element to add, such as
Locale('uk'),. PatchEngine renders its placeholders.final - listVariableMatch → String
-
The name of the argument that takes the list, such as
supportedLocales.final - method → String
-
The name of the method that holds the list, such as
build.final - parentExpressionMatch → String
-
Text that the call or widget creation taking the list, or one around
it, has before its arguments, such as
MaterialApp.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