TextEdit class final

An edit replacing [startOffset, endOffset) with newText.

Constructors

TextEdit(int startOffset, int endOffset, String newText)
Creates an edit replacing [startOffset, endOffset) with newText.
TextEdit.delete(int startOffset, int endOffset)
A deletion of [startOffset, endOffset) (inserts nothing).
factory
TextEdit.insert(int offset, String text)
An insertion of text at offset (deletes nothing).
factory
TextEdit.replace(int startOffset, int endOffset, String newText)
A replacement of [startOffset, endOffset) with newText. Alias for the default constructor, for symmetry with insert / delete.
factory

Properties

deleteLength → int
Number of characters deleted by this edit.
no setter
endOffset → int
End of the replaced range (exclusive, 0-indexed).
final
hashCode → int
The hash code for this object.
no setterinherited
insertLength → int
Number of characters inserted by this edit.
no setter
isDeletion → bool
True if this edit only deletes (inserts nothing).
no setter
isInsertion → bool
True if this edit only inserts (deletes nothing).
no setter
isReplacement → bool
True if this edit both deletes and inserts.
no setter
lengthDelta → int
Net change in document length: positive grows, negative shrinks.
no setter
newText → String
The text inserted in place of the replaced range.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
startOffset → int
Start of the replaced range (inclusive, 0-indexed).
final

Methods

adjustOffset(int offset) → int
Map a pre-edit offset to its position in the post-edit document.
affects(int rangeStart, int rangeEnd) → bool
Whether this edit overlaps or abuts the range [rangeStart, rangeEnd).
apply(String source) → String
Apply this edit to source, returning the new source.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

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

Static Methods

compose(List<TextEdit> edits) → List<TextEdit>
Compose edits into a sequence applicable left-to-right.