The -spec directly above a function (comments may sit between), if it names it.
(node: SyntaxNode, name: string, source: string)
| 80 | |
| 81 | /** The -spec directly above a function (comments may sit between), if it names it. */ |
| 82 | function precedingSpec(node: SyntaxNode, name: string, source: string): SyntaxNode | null { |
| 83 | let prev = node.previousNamedSibling; |
| 84 | while (prev && prev.type === 'comment') prev = prev.previousNamedSibling; |
| 85 | if (prev?.type === 'spec') { |
| 86 | const specFun = getChildByField(prev, 'fun'); |
| 87 | if (specFun && atomText(specFun, source) === name) return prev; |
| 88 | } |
| 89 | return null; |
| 90 | } |
| 91 | |
| 92 | /** `name(Args) when Guard` — the clause text up to the `->`. */ |
| 93 | function clauseHeader(clause: SyntaxNode, source: string): string | undefined { |
no test coverage detected