sync method
Recomputes diagnostics from the controller's current text.
Implementation
void sync({bool force = false}) {
if (_disposed) return;
if (_rangeDiagnostics case final diagnosticsSource?) {
final diagnostics = diagnosticsSource.value.toList(growable: false);
if (diagnostics.isEmpty) {
_controller.clearDiagnostics();
return;
}
_controller.setDiagnostics(diagnostics);
return;
}
if (_positionDiagnostics case final diagnosticsSource?) {
final diagnostics = diagnosticsSource.value.toList(growable: false);
if (diagnostics.isEmpty) {
_controller.clearDiagnostics();
return;
}
_controller.setDiagnosticsFromPositions(diagnostics);
return;
}
final text = _controller.text;
if (!force && text == _lastText) {
return;
}
_lastText = text;
final diagnostics = _buildDiagnostics!(text).toList(growable: false);
if (diagnostics.isEmpty) {
_controller.clearDiagnostics();
return;
}
_controller.setDiagnosticsFromPositions(diagnostics);
}