AFCodeBuffer class

An in-memory buffer containing code, used during code generation.

Constructors

AFCodeBuffer({required List<String>? projectPath, required List<String> lines, required bool modified, required List<String> extraImports})
AFCodeBuffer.empty()
factory
AFCodeBuffer.fromFullPath(List<String> projectPath, String fullPath)
Returns a code buffer containing the contents of fullPath
factory
AFCodeBuffer.fromGeneratePath(List<String> projectPath)
Returns a code buffer containing contents of a file under the project's 'generate' subfolder.
factory
AFCodeBuffer.fromPath(List<String> projectPath)
Returns a code buffer containing the contents of the file
factory
AFCodeBuffer.fromTemplate(AFSourceTemplate template)
Returns a code buffer created from the specified source template.
factory

Properties

extraImports List<String>
final
hashCode int
The hash code for this object.
no setterinherited
lines List<String>
final
modified bool
getter/setter pair
projectPath List<String>?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addLineBeforeIndex(AFCommandContext context, int idx, String line) → void
Adds a single line before the specified index.
addLinesAfter(AFCommandContext context, RegExp match, List<String> toInsert) → void
Adds a sete of lines after the first line containing match
addLinesAfterIdx(AFCommandContext context, int idx, List<String> toInsert) → void
Adds a set of line after the specified index.
addLinesAtEnd(AFCommandContext context, List<String> toInsert) → void
Adds a set of lines at the end of the file.
addLinesBefore(AFCommandContext context, RegExp match, List<String> toInsert) → void
Adds a set of linies before the first line containing match.
addLinesBeforeIdx(AFCommandContext context, int idx, List<String> toInsert) → void
Adds a set of line before the specified index.
appendLine(String line) → void
Adds the specified line at the end of the file.
appendLineEmpty() → void
Adds an empty line at the end of the file.
containsInsertionPoint(String insertionPoint) bool
Returns true if a line in the file contains the specified insertionPoint
findFirstAFTag() String?
Returns the first line containing a AFSourceTemplateInsertion tag
firstLineContaining(AFCommandContext context, RegExp match, {int startAt = 0}) int
Returns the index of the first line containing match in the file.
fixupImports(String filePath) → void
Sorts imports in the file and removes duplicates
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
performInsertions(AFCommandContext context, AFSourceTemplateInsertions insertions) → void
Converts AFSourceTemplateInsertion tags into the values specified in insertions.
removeLineAt(int idx) → void
replaceAllWithOptions(AFCommandContext context, dynamic id, List<String> createValue(AFCommandContext context, List<String> options)) → void
Replaces all the instances of id with the lines returned by createValue.
replaceInLine(AFCommandContext context, int lineIdx, String code, List<String> createValue(AFCommandContext context, List<String> options)) → void
Replaces all instances of code in the line with the lines returned by createValue
replaceLine(AFCommandContext context, int idx, String value) → void
Replaces the line at the specified index.
replaceTemplate(AFCommandContext context, dynamic id, AFSourceTemplate content) → void
Replaces the specified id with the content of the specified source template anywhere in the file.
replaceText(AFCommandContext context, dynamic id, String value) → void
Replaces the specified id with the specified text value anywhere in the file.
replaceTextLines(AFCommandContext context, dynamic id, List<String> linesIn) → void
Replaces all instances of id in the file with linesIn
resetText(String text) → void
Replaces the entire content of this file with the specified text.
toString() String
A string representation of this object.
override

Operators

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

Static Methods

quoteIfNonNull(String? value) String
Enclosed the specified value in quotes unless it is null.

Constants

endCode → const String
startCode → const String