(t: Type, names: OrderedSet<string>, parentNames: OrderedSet<string> | null)
| 16 | let processed: Set<Type> = Set(); |
| 17 | |
| 18 | function processType(t: Type, names: OrderedSet<string>, parentNames: OrderedSet<string> | null) { |
| 19 | if (t.isNamedType()) { |
| 20 | const alternatives: string[] = []; |
| 21 | names.forEach(name => { |
| 22 | if (parentNames !== null) { |
| 23 | alternatives.push(...parentNames.map(pn => `${pn}_${name}`).toArray()); |
| 24 | } |
| 25 | alternatives.push(`${name}_${t.kind}`); |
| 26 | if (parentNames !== null) { |
| 27 | alternatives.push(...parentNames.map(pn => `${pn}_${name}_${t.kind}`).toArray()); |
| 28 | } |
| 29 | }); |
| 30 | t.addNames({ names, alternatives: OrderedSet(alternatives) }, true); |
| 31 | } |
| 32 | if (processed.has(t)) return; |
| 33 | processed = processed.add(t); |
| 34 | matchCompoundType( |
| 35 | t, |
| 36 | arrayType => { |
| 37 | processType(arrayType.items, names.map(pluralize.singular), parentNames); |
| 38 | }, |
| 39 | classType => { |
| 40 | const properties = classType.properties.sortBy((_, n) => n); |
| 41 | properties.forEach((propertyType, propertyName) => { |
| 42 | processType(propertyType, OrderedSet([propertyName]), names); |
| 43 | }); |
| 44 | }, |
| 45 | mapType => { |
| 46 | processType(mapType.values, names.map(pluralize.singular), parentNames); |
| 47 | }, |
| 48 | unionType => { |
| 49 | const members = unionType.members.sortBy(member => member.kind); |
| 50 | members.forEach(memberType => { |
| 51 | processType(memberType, names, parentNames); |
| 52 | }); |
| 53 | } |
| 54 | ); |
| 55 | } |
| 56 | |
| 57 | graph.topLevels.forEach((t, name) => { |
| 58 | processType(t, OrderedSet([name]), null); |
no test coverage detected
searching dependent graphs…