DartFileEditBuilder class abstract

A FileEditBuilder used to build edits for Dart files.

Clients may not extend, implement or mix-in this class.

Implemented types

Constructors

DartFileEditBuilder()

Properties

fileHeader String
Sets the file header to be added before any generated imports.
no getter
hashCode int
The hash code for this object.
no setterinherited
requiredImports List<Uri>
A list of new URIs that must be imported for the types being referenced in edits.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addDeletion(SourceRange range) → void
Add a deletion of text specified by the given range. The range is relative to the original source. This is fully equivalent to
inherited
addInsertion(int offset, void buildEdit(DartEditBuilder builder)) → void
Add an insertion of text at the given offset. The offset is relative to the original source. The buildEdit function is used to write the text to be inserted. This is fully equivalent to
override
addLinkedPosition(SourceRange range, String groupName) → void
Add the region of text specified by the given range to the linked edit group with the given groupName. The range is relative to the original source. This is typically used to include preexisting regions of text in a group. If the region to be included is part of newly generated text, then the method EditBuilder.addLinkedEdit should be used instead.
inherited
addReplacement(SourceRange range, void buildEdit(DartEditBuilder builder)) → void
Add a replacement of text specified by the given range. The range is relative to the original source. The buildEdit function is used to write the text that will replace the specified region.
override
addSimpleInsertion(int offset, String text) → void
Add an insertion of the given text at the given offset. The offset is relative to the original source. This is fully equivalent to
inherited
addSimpleReplacement(SourceRange range, String text) → void
Add a replacement of the text specified by the given range. The range is relative to the original source. The original content will be replaced by the given text. This is fully equivalent to
inherited
canWriteType(DartType? type, {ExecutableElement? methodBeingCopied}) bool
Checks whether the code for a type annotation for the given type can be written.
convertFunctionFromSyncToAsync({required FunctionBody body, required TypeSystem typeSystem, required TypeProvider typeProvider}) → void
Creates one or more edits that will convert the given function body from being synchronous to be asynchronous. This includes adding the async modifier to the body as well as potentially replacing the return type of the function to Future.
format(SourceRange range) → void
Formats the code covered by the range.
importLibrary(Uri uri, {String? prefix, String? showName, bool useShow = false}) String
Arranges to have an import added for the library with the given uri.
importLibraryElement(Uri uri) ImportLibraryElementResult
Ensures that the library with the given uri is imported.
importsLibrary(Uri uri) bool
Returns whether the given library uri is already imported or will be imported by a scheduled edit.
insertCaseClauseAtEnd(void buildEdit(DartEditBuilder builder), {required Token switchKeyword, required Token rightParenthesis, required Token leftBracket, required Token rightBracket}) → void
Inserts the code for a case clause at the end of a switch statement or switch expression.
insertConstructor(CompilationUnitMember container, void buildEdit(DartEditBuilder builder)) → void
Inserts the code for a constructor.
insertField(CompilationUnitMember compilationUnitMember, void buildEdit(DartEditBuilder builder)) → void
Inserts the code for a field.
insertGetter(CompilationUnitMember compilationUnitMember, void buildEdit(DartEditBuilder builder)) → void
Inserts the code for a getter.
insertIntoUnitMember(CompilationUnitMember compilationUnitMember, void buildEdit(DartEditBuilder builder), {bool lastMemberFilter(ClassMember existingMember)?}) → void
Inserts into a CompilationUnitMember.
insertMethod(CompilationUnitMember compilationUnitMember, void buildEdit(DartEditBuilder builder)) → void
Inserts the code for a method.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
replaceTypeWithFuture({required TypeAnnotation typeAnnotation, required TypeSystem typeSystem, required TypeProvider typeProvider}) → void
Optionally creates an edit to replace the given typeAnnotation with the type Future (with the given type annotation as the type argument).
toString() String
A string representation of this object.
inherited

Operators

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