* Update metadata for nodes in a cached file
(filePath: string, metadata: CachedMetadata)
| 1460 | * Update metadata for nodes in a cached file |
| 1461 | */ |
| 1462 | updateMetadata(filePath: string, metadata: CachedMetadata) { |
| 1463 | const normalizedPath = this.toRelativePath(filePath); |
| 1464 | const fileCache = this.files[normalizedPath]; |
| 1465 | if (!fileCache) return; |
| 1466 | |
| 1467 | let updated = false; |
| 1468 | for (const node of fileCache.nodes) { |
| 1469 | const funcName = node.source?.function; |
| 1470 | if (!funcName) continue; |
| 1471 | |
| 1472 | // Update label if provided |
| 1473 | if (metadata.labels[funcName] && metadata.labels[funcName] !== node.label) { |
| 1474 | node.label = metadata.labels[funcName]; |
| 1475 | updated = true; |
| 1476 | } |
| 1477 | |
| 1478 | // Update description if provided |
| 1479 | if (metadata.descriptions?.[funcName]) { |
| 1480 | node.description = metadata.descriptions[funcName]; |
| 1481 | updated = true; |
| 1482 | } |
| 1483 | } |
| 1484 | |
| 1485 | // Update edge labels |
| 1486 | if (metadata.edgeLabels && Object.keys(metadata.edgeLabels).length > 0) { |
| 1487 | for (const edge of fileCache.internalEdges) { |
| 1488 | const edgeKey = `${edge.source}->${edge.target}`; |
| 1489 | if (metadata.edgeLabels[edgeKey]) { |
| 1490 | edge.label = metadata.edgeLabels[edgeKey]; |
| 1491 | updated = true; |
| 1492 | } |
| 1493 | } |
| 1494 | } |
| 1495 | |
| 1496 | if (updated) { |
| 1497 | this.scheduleSave(); |
| 1498 | } |
| 1499 | } |
| 1500 | |
| 1501 | /** |
| 1502 | * Prune stale entries for files that no longer exist |
no test coverage detected