MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / precedingSpec

Function precedingSpec

src/extraction/languages/erlang.ts:82–90  ·  view source on GitHub ↗

The -spec directly above a function (comments may sit between), if it names it.

(node: SyntaxNode, name: string, source: string)

Source from the content-addressed store, hash-verified

80
81/** The -spec directly above a function (comments may sit between), if it names it. */
82function 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 `->`. */
93function clauseHeader(clause: SyntaxNode, source: string): string | undefined {

Callers 1

handleFunDeclFunction · 0.85

Calls 2

getChildByFieldFunction · 0.90
atomTextFunction · 0.85

Tested by

no test coverage detected