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

Method extractInterface

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

* Extract an interface/protocol/trait

(node: SyntaxNode)

Source from the content-addressed store, hash-verified

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