MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / extractInterface

Method extractInterface

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

* Extract an interface/protocol/trait

(node: SyntaxNode)

Source from the content-addressed store, hash-verified

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