* Get outgoing edges from a node. Preserve the source/kind index order * (calls before imports/references), then break ties deterministically.
(sourceId: string, kinds?: EdgeKind[], provenance?: string, limit?: number)
| 2738 | * (calls before imports/references), then break ties deterministically. |
| 2739 | */ |
| 2740 | getOutgoingEdges(sourceId: string, kinds?: EdgeKind[], provenance?: string, limit?: number): Edge[] { |
| 2741 | if ((kinds && kinds.length > 0) || provenance || limit !== undefined) { |
| 2742 | let sql = 'SELECT * FROM edges WHERE source = ?'; |
| 2743 | const params: (string | number)[] = [sourceId]; |
| 2744 | |
| 2745 | if (kinds && kinds.length > 0) { |
| 2746 | sql += ` AND kind IN (${kinds.map(() => '?').join(',')})`; |
| 2747 | params.push(...kinds); |
| 2748 | } |
| 2749 | |
| 2750 | if (provenance) { |
| 2751 | sql += ' AND provenance = ?'; |
| 2752 | params.push(provenance); |
| 2753 | } |
| 2754 | |
| 2755 | sql += ' ORDER BY kind, target, line, col'; |
| 2756 | if (limit !== undefined) { |
| 2757 | sql += ' LIMIT ?'; |
| 2758 | params.push(Math.max(0, Math.floor(limit))); |
| 2759 | } |
| 2760 | const rows = this.edgeKindStmt(sql).all(...params) as EdgeRow[]; |
| 2761 | return rows.map(rowToEdge); |
| 2762 | } |
| 2763 | |
| 2764 | if (!this.stmts.getEdgesBySource) { |
| 2765 | this.stmts.getEdgesBySource = this.db.prepare('SELECT * FROM edges WHERE source = ? ORDER BY kind, target, line, col'); |
| 2766 | } |
| 2767 | const rows = this.stmts.getEdgesBySource.all(sourceId) as EdgeRow[]; |
| 2768 | return rows.map(rowToEdge); |
| 2769 | } |
| 2770 | |
| 2771 | /** |
| 2772 | * Get incoming edges to a node. Kind must precede opaque source IDs: |
no test coverage detected