* Extract an interface/protocol/trait
(node: SyntaxNode)
| 3032 | * Extract an interface/protocol/trait |
| 3033 | */ |
| 3034 | private extractInterface(node: SyntaxNode): void { |
| 3035 | if (!this.extractor) return; |
| 3036 | |
| 3037 | const name = extractName(node, this.source, this.extractor); |
| 3038 | const docstring = this.docstringFor(node); |
| 3039 | const isExported = this.extractor.isExported?.(node, this.source); |
| 3040 | |
| 3041 | const kind: NodeKind = this.extractor.interfaceKind ?? 'interface'; |
| 3042 | |
| 3043 | const interfaceNode = this.createNode(kind, name, node, { |
| 3044 | docstring, |
| 3045 | isExported, |
| 3046 | }); |
| 3047 | if (!interfaceNode) return; |
| 3048 | |
| 3049 | // Extract extends (interface inheritance) |
| 3050 | this.extractInheritance(node, interfaceNode.id); |
| 3051 | |
| 3052 | // Visit body children for interface methods and nested types |
| 3053 | this.nodeStack.push(interfaceNode.id); |
| 3054 | let body = this.extractor.resolveBody?.(node, this.extractor.bodyField) |
| 3055 | ?? getChildByField(node, this.extractor.bodyField); |
| 3056 | if (!body) body = node; |
| 3057 | for (let i = 0; i < body.namedChildCount; i++) { |
| 3058 | const child = body.namedChild(i); |
| 3059 | if (child) { |
| 3060 | this.visitNode(child); |
| 3061 | } |
| 3062 | } |
| 3063 | this.nodeStack.pop(); |
| 3064 | } |
| 3065 | |
| 3066 | /** |
| 3067 | * Extract a struct |
no test coverage detected