| 767 | } |
| 768 | |
| 769 | function getNodeIndex(node: any, edge: "start" | "end", lineStarts: number[]): number | null { |
| 770 | const direct = edge === "start" ? node.start : node.end; |
| 771 | if (typeof direct === "number") return direct; |
| 772 | |
| 773 | const loc = node.loc?.[edge]; |
| 774 | if (!loc) return null; |
| 775 | const lineIndex = lineStarts[loc.line - 1]; |
| 776 | if (lineIndex == null) return null; |
| 777 | return lineIndex + loc.column; |
| 778 | } |
| 779 | |
| 780 | function getSourceBetween(prevNode: any, nextNode: any, source?: string, lineStarts?: number[]): string { |
| 781 | if (!source) return ""; |