codeSpecKindChips function

List<SpecChip> codeSpecKindChips(
  1. KindLink? link, {
  2. bool suppressUnmapped = false,
})

The @CodeSpecKind chips for link.

Three-state — mapped, explicitly mapped to nothing, or undeclared. All three are rendered because the third is the open question a structural reviewer is looking for; leaving it blank would hide it among the mapped ones. Pass suppressUnmapped when the node is already classified by another taxonomy, so the undeclared marker would be a false statement rather than an open question.

Implementation

List<SpecChip> codeSpecKindChips(
  KindLink? link, {
  bool suppressUnmapped = false,
}) {
  if (link == null) {
    if (suppressUnmapped) return const [];
    return const [
      SpecChip(
        'cs?',
        SpecChipRole.codeSpecUnmapped,
        tooltip: 'No @CodeSpecKind — not yet mapped to a CodeSpecs part',
      ),
    ];
  }
  if (link.kinds.isEmpty) {
    return const [
      SpecChip(
        'cs:none',
        SpecChipRole.codeSpecNone,
        tooltip:
            '@CodeSpecKind with no kinds — recorded as mapping to no '
            'CodeSpecs part',
      ),
    ];
  }
  return [
    for (final kind in link.kinds)
      SpecChip('cs:$kind', SpecChipRole.codeSpecMapped, tooltip: link.note),
  ];
}