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
Set the file header to be added before any generated imports. A blank line will automatically be added after the file header.
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
Check if the code for a type annotation for the given type can be written.
convertFunctionFromSyncToAsync(FunctionBody body, TypeProvider typeProvider) → void
Create 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
Format the code covered by the range.
importLibrary(Uri uri, {String? prefix, String? showName}) String
Arrange to have an import added for the library with the given uri. If a prefix is provided it will be used in the import directive.
importLibraryElement(Uri uri) ImportLibraryElementResult
Ensure that the library with the given uri is imported.
importsLibrary(Uri uri) bool
Return true if the given library uri is already imported or will be imported by a scheduled edit.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
replaceTypeWithFuture(TypeAnnotation typeAnnotation, TypeProvider typeProvider) → void
Optionally create an edit to replace the given typeAnnotation with the type Future (with the given type annotation as the type argument). The typeProvider is used to check the current type, because if it is already Future no edit will be added.
toString() String
A string representation of this object.
inherited

Operators

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