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

Method extractInterface

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

* Extract an interface/protocol/trait

(node: SyntaxNode)

Source from the content-addressed store, hash-verified

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