expectedShowcaseChipLabels function

Set<String> expectedShowcaseChipLabels(
  1. SpecModel model
)

Every chip label the shared descriptors produce anywhere in model.

Computed from the descriptor functions rather than written out, so a chip the display layer starts producing joins this set automatically — and then fails in whichever app has not rendered it.

Implementation

Set<String> expectedShowcaseChipLabels(SpecModel model) {
  final labels = <String>{};
  void addAll(List<SpecChip> chips) {
    labels.addAll(chips.map((c) => c.label));
  }

  for (final cls in model.classes.values) {
    if (cls.isCodeSpecsProjection) labels.add(projectionChip.label);
    if (cls.isUnused) labels.add(unusedChip.label);
    if (cls.hasReferences) labels.add(referencesChip.label);
    final group = cls.oneOf;
    if (group != null) addAll(oneOfChips(group));
    addAll(kindChips(cls.codeSpecKind, cls.followUpKind, cls.noArtifact));
    for (final field in cls.fields) {
      if (field.isUnused) labels.add(unusedChip.label);
      if (field.hasReferences) labels.add(referencesChip.label);
      addAll(fieldChips(field));
    }
  }
  return labels;
}