diagnostics method
The plan's numbering diagnostics (T15), in a stable order: duplicates by first appearance, then per table ascending.
Implementation
List<Diagnostic> diagnostics() {
final out = <Diagnostic>[];
final byNumber = <String, List<Handle>>{};
for (final t in tables) {
if (t.number != null) (byNumber[t.number!] ??= []).add(t.instance);
}
for (final MapEntry(key: number, value: handles) in byNumber.entries) {
if (handles.length < 2) continue;
out.add(Diagnostic(
severity: DiagnosticSeverity.warning,
code: TableDiagnosticCodes.duplicateNumber,
message: 'Number $number is used by ${handles.length} tables',
handles: handles,
));
}
for (final t in tables) {
if (t.number == null) {
out.add(Diagnostic(
severity: DiagnosticSeverity.warning,
code: TableDiagnosticCodes.unnumbered,
message: 'Table ${t.instance.toHex()} has no number',
handles: [t.instance],
));
}
final more = extraLabels[t.instance];
if (more != null) {
out.add(Diagnostic(
severity: DiagnosticSeverity.warning,
code: TableDiagnosticCodes.extraLabel,
message: 'Table ${t.instance.toHex()} has ${more.length + 1} '
'number labels; the first is used',
handles: [t.instance, ...more],
));
}
// Host embedding API spec E-6, S-3: a payload outside the limits is
// kept verbatim and reads as no data; the plan is never refused.
if (_keptData.contains(t.instance)) {
out.add(Diagnostic(
severity: DiagnosticSeverity.warning,
code: TableDiagnosticCodes.invalidData,
message: 'Table ${t.instance.toHex()} carries host data outside '
'the limits; it is kept as read and reads as none',
handles: [t.instance],
));
}
// Plan colours spec PC-4: a payload of another shape, or a hue this
// release does not know, is kept as read and drawn as none.
if (_invalidColor.contains(t.instance)) {
out.add(Diagnostic(
severity: DiagnosticSeverity.warning,
code: TableDiagnosticCodes.invalidColor,
message: 'Table ${t.instance.toHex()} carries a colour this '
'release cannot read; it is kept as read and drawn as none',
handles: [t.instance],
));
}
}
for (final h in nested) {
out.add(Diagnostic(
severity: DiagnosticSeverity.info,
code: TableDiagnosticCodes.nested,
message: '${h.toHex()} is inside a group and is not a table',
handles: [h],
));
}
return out;
}