* Extract an interface/protocol/trait
(node: SyntaxNode)
| 1838 | * Extract an interface/protocol/trait |
| 1839 | */ |
| 1840 | private extractInterface(node: SyntaxNode): void { |
| 1841 | if (!this.extractor) return; |
| 1842 | |
| 1843 | const name = extractName(node, this.source, this.extractor); |
| 1844 | const docstring = getPrecedingDocstring(node, this.source); |
| 1845 | const isExported = this.extractor.isExported?.(node, this.source); |
| 1846 | |
| 1847 | const kind: NodeKind = this.extractor.interfaceKind ?? 'interface'; |
| 1848 | |
| 1849 | const interfaceNode = this.createNode(kind, name, node, { |
| 1850 | docstring, |
| 1851 | isExported, |
| 1852 | }); |
| 1853 | if (!interfaceNode) return; |
| 1854 | |
| 1855 | // Extract extends (interface inheritance) |
| 1856 | this.extractInheritance(node, interfaceNode.id); |
| 1857 | |
| 1858 | // Visit body children for interface methods and nested types |
| 1859 | this.nodeStack.push(interfaceNode.id); |
| 1860 | let body = this.extractor.resolveBody?.(node, this.extractor.bodyField) |
| 1861 | ?? getChildByField(node, this.extractor.bodyField); |
| 1862 | if (!body) body = node; |
| 1863 | for (let i = 0; i < body.namedChildCount; i++) { |
| 1864 | const child = body.namedChild(i); |
| 1865 | if (child) { |
| 1866 | this.visitNode(child); |
| 1867 | } |
| 1868 | } |
| 1869 | this.nodeStack.pop(); |
| 1870 | } |
| 1871 | |
| 1872 | /** |
| 1873 | * Extract a struct |
no test coverage detected