| 42 | } |
| 43 | |
| 44 | function fallbackReceiveName(node: SyntaxNode): string { |
| 45 | // tree-sitter-solidity reuses one node type for both `fallback() ...` and |
| 46 | // `receive() ...` — the keyword is an unnamed/anonymous child. Walk all |
| 47 | // children (named + unnamed) and pick the first whose text is one of these. |
| 48 | for (let i = 0; i < node.childCount; i++) { |
| 49 | const child = node.child(i); |
| 50 | if (!child) continue; |
| 51 | const t = child.text; |
| 52 | if (t === 'fallback' || t === 'receive') return t; |
| 53 | } |
| 54 | return 'fallback'; |
| 55 | } |
| 56 | |
| 57 | export const solidityExtractor: LanguageExtractor = { |
| 58 | // Free functions (file-level) AND methods inside contracts use the same |