MCPcopy
hub / github.com/colbymchenry/codegraph / extractInterface

Method extractInterface

src/extraction/tree-sitter.ts:1707–1737  ·  view source on GitHub ↗

* Extract an interface/protocol/trait

(node: SyntaxNode)

Source from the content-addressed store, hash-verified

1705 * Extract an interface/protocol/trait
1706 */
1707 private extractInterface(node: SyntaxNode): void {
1708 if (!this.extractor) return;
1709
1710 const name = extractName(node, this.source, this.extractor);
1711 const docstring = getPrecedingDocstring(node, this.source);
1712 const isExported = this.extractor.isExported?.(node, this.source);
1713
1714 const kind: NodeKind = this.extractor.interfaceKind ?? 'interface';
1715
1716 const interfaceNode = this.createNode(kind, name, node, {
1717 docstring,
1718 isExported,
1719 });
1720 if (!interfaceNode) return;
1721
1722 // Extract extends (interface inheritance)
1723 this.extractInheritance(node, interfaceNode.id);
1724
1725 // Visit body children for interface methods and nested types
1726 this.nodeStack.push(interfaceNode.id);
1727 let body = this.extractor.resolveBody?.(node, this.extractor.bodyField)
1728 ?? getChildByField(node, this.extractor.bodyField);
1729 if (!body) body = node;
1730 for (let i = 0; i < body.namedChildCount; i++) {
1731 const child = body.namedChild(i);
1732 if (child) {
1733 this.visitNode(child);
1734 }
1735 }
1736 this.nodeStack.pop();
1737 }
1738
1739 /**
1740 * Extract a struct

Callers 2

visitNodeMethod · 0.95

Calls 6

createNodeMethod · 0.95
extractInheritanceMethod · 0.95
visitNodeMethod · 0.95
getPrecedingDocstringFunction · 0.90
getChildByFieldFunction · 0.90
extractNameFunction · 0.85

Tested by

no test coverage detected