execute method
Executes the given requests.
Any changes that result from the given requests are reported to listeners as a series
of EditEvents.
Implementation
@override
void execute(List<EditRequest> requests) {
if (requests.isEmpty) {
// No changes were requested. Don't waste time starting and ending transactions, etc.
editorEditsLog.warning("Tried to execute requests without providing any requests");
return;
}
editorEditsLog.finer("Executing requests:");
for (final request in requests) {
editorEditsLog.finer(" - ${request.runtimeType}");
}
if (_activeCommandCount == 0 && !_isInTransaction) {
// No transaction was explicitly requested, but all changes exist in a transaction.
// Automatically start one, and then end the transaction after the current changes.
_isImplicitTransaction = true;
startTransaction();
}
_activeCommandCount += 1;
final undoableCommands = <EditCommand>[];
for (final request in requests) {
// Execute the given request.
final command = _findCommandForRequest(request);
final commandChanges = _executeCommand(command);
_activeChangeList!.addAll(commandChanges);
if (command.historyBehavior == HistoryBehavior.undoable) {
undoableCommands.add(command);
_transaction!.changes.addAll(List.from(commandChanges));
}
}
// Log the time at the end of the actions in this transaction.
_transaction!.lastChangeTime = clock.now();
if (undoableCommands.isNotEmpty) {
_transaction!.commands.addAll(undoableCommands);
}
if (_activeCommandCount == 1 && _isImplicitTransaction && !_isReacting) {
endTransaction();
} else {
_activeCommandCount -= 1;
}
}