(labels: readonly string[], visible = COMPACT_LABEL_CHARS)
| 125 | * fits the chip, and that end holds the difference: "…mapindex1.xml". |
| 126 | */ |
| 127 | export function distinctLabels(labels: readonly string[], visible = COMPACT_LABEL_CHARS): Map<string, string> { |
| 128 | const result = new Map<string, string>(); |
| 129 | const long = [...new Set(labels)].filter(label => label.length > visible); |
| 130 | for (const label of long) { |
| 131 | let shared = 0; |
| 132 | for (const other of long) { |
| 133 | if (other === label || other.slice(0, visible - 1) !== label.slice(0, visible - 1)) continue; |
| 134 | let common = 0; |
| 135 | while (common < label.length && label[common] === other[common]) common++; |
| 136 | shared = Math.max(shared, common); |
| 137 | } |
| 138 | if (!shared) continue; |
| 139 | const cut = Math.max(...['/', '-', '_', '.'].map(separator => label.lastIndexOf(separator, shared - 1))); |
| 140 | const rest = cut > 0 ? (label[cut] === '/' ? label.slice(cut) : label.slice(cut + 1)) |
| 141 | : label.slice(Math.min(shared, Math.max(1, label.length - (visible - 1)))); |
| 142 | // A label that is the shared start itself keeps its full text; its neighbours carry the difference. |
| 143 | if (rest.replace('/', '').length > 1) result.set(label, `…${rest}`); |
| 144 | } |
| 145 | return result; |
| 146 | } |
| 147 | const sourceNode = (node: GraphNode) => Boolean(node.file_path && node.file_path !== '{}' |
| 148 | && !['Project', 'Folder', 'Package', 'Branch', 'Route'].includes(node.label)); |
| 149 | const symbolNode = (node: GraphNode): SemanticNode => ({ id: symbolId(node), |
no outgoing calls
no test coverage detected