* Extract an interface/protocol/trait
(node: SyntaxNode)
| 2913 | * Extract an interface/protocol/trait |
| 2914 | */ |
| 2915 | private extractInterface(node: SyntaxNode): void { |
| 2916 | if (!this.extractor) return; |
| 2917 | |
| 2918 | const name = extractName(node, this.source, this.extractor); |
| 2919 | const docstring = this.docstringFor(node); |
| 2920 | const isExported = this.extractor.isExported?.(node, this.source); |
| 2921 | |
| 2922 | const kind: NodeKind = this.extractor.interfaceKind ?? 'interface'; |
| 2923 | |
| 2924 | const interfaceNode = this.createNode(kind, name, node, { |
| 2925 | docstring, |
| 2926 | isExported, |
| 2927 | }); |
| 2928 | if (!interfaceNode) return; |
| 2929 | |
| 2930 | // Extract extends (interface inheritance) |
| 2931 | this.extractInheritance(node, interfaceNode.id); |
| 2932 | |
| 2933 | // Visit body children for interface methods and nested types |
| 2934 | this.nodeStack.push(interfaceNode.id); |
| 2935 | let body = this.extractor.resolveBody?.(node, this.extractor.bodyField) |
| 2936 | ?? getChildByField(node, this.extractor.bodyField); |
| 2937 | if (!body) body = node; |
| 2938 | for (let i = 0; i < body.namedChildCount; i++) { |
| 2939 | const child = body.namedChild(i); |
| 2940 | if (child) { |
| 2941 | this.visitNode(child); |
| 2942 | } |
| 2943 | } |
| 2944 | this.nodeStack.pop(); |
| 2945 | } |
| 2946 | |
| 2947 | /** |
| 2948 | * Extract a struct |
no test coverage detected