* A Pascal signature's parameter groups, the text between its parentheses * split at the `;`s outside brackets and strings; [] when it has no * parameter list, null when the list doesn't close.
(signature: string | undefined)
| 651 | * parameter list, null when the list doesn't close. |
| 652 | */ |
| 653 | function pascalParameterGroups(signature: string | undefined): string[] | null { |
| 654 | const text = signature ?? ''; |
| 655 | const open = text.indexOf('('); |
| 656 | if (open < 0) return []; |
| 657 | const groups: string[] = []; |
| 658 | let depth = 0; |
| 659 | let start = open + 1; |
| 660 | for (let i = open; i < text.length; i++) { |
| 661 | const c = text[i]!; |
| 662 | if (c === "'") { |
| 663 | for (i++; i < text.length && !(text[i] === "'" && text[i + 1] !== "'"); i += text[i] === "'" ? 2 : 1); |
| 664 | } else if (c === '(' || c === '[') { |
| 665 | depth++; |
| 666 | } else if (c === ')' || c === ']') { |
| 667 | depth--; |
| 668 | if (depth === 0) { |
| 669 | groups.push(text.slice(start, i)); |
| 670 | return groups; |
| 671 | } |
| 672 | } else if (c === ';' && depth === 1) { |
| 673 | groups.push(text.slice(start, i)); |
| 674 | start = i + 1; |
| 675 | } |
| 676 | } |
| 677 | return null; |
| 678 | } |
| 679 | |
| 680 | /** See gatePascalCall: a call resolved to data. */ |
| 681 | function gatePascalDataCall(target: Node, result: ResolvedRef, ref: UnresolvedRef, context: ResolutionContext): ResolvedRef | null { |
no test coverage detected