* Whether a routine nested in another is declared `forward` above a line * (`procedure Late; forward;`), which puts it in scope there ahead of its * body (#2550): a header of its name, as indented as its own, that ends in * `forward;`, between the line and the header indented less above it, the
(routine: Node, line: number, context: ResolutionContext)
| 901 | * routine both are nested in. |
| 902 | */ |
| 903 | function declaredForward(routine: Node, line: number, context: ResolutionContext): boolean { |
| 904 | const lines = fileLines(routine.filePath, context); |
| 905 | const name = routine.name.toLowerCase(); |
| 906 | for (let i = Math.min(line, lines.length) - 1; i >= 0; i--) { |
| 907 | const m = /^(\s*)(?:class\s+)?(?:procedure|function|constructor|destructor)\s+([A-Za-z_]\w*)/i.exec(lines[i]!); |
| 908 | if (!m) continue; |
| 909 | if (m[1]!.length < routine.startColumn) return false; |
| 910 | if (m[1]!.length !== routine.startColumn || m[2]!.toLowerCase() !== name) continue; |
| 911 | // Its parameters may go on over a few lines. |
| 912 | let text = lines[i]!.replace(/\/\/.*$|\{[^}]*\}|\(\*.*?\*\)/g, ' '); |
| 913 | for (let j = i + 1; j < lines.length && j <= i + 4 && (text.split('(').length > text.split(')').length); j++) { |
| 914 | text += ' ' + lines[j]!.replace(/\/\/.*$|\{[^}]*\}|\(\*.*?\*\)/g, ' '); |
| 915 | } |
| 916 | if (/\bforward\s*;/i.test(text)) return true; |
| 917 | } |
| 918 | return false; |
| 919 | } |
| 920 | |
| 921 | /** |
| 922 | * Whether a node is a routine nested in another (see nestedRoutineInScope): |
no test coverage detected