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