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

Method extractInterface

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

* Extract an interface/protocol/trait

(node: SyntaxNode)

Source from the content-addressed store, hash-verified

2913 * Extract an interface/protocol/trait
2914 */
2915 private extractInterface(node: SyntaxNode): void {
2916 if (!this.extractor) return;
2917
2918 const name = extractName(node, this.source, this.extractor);
2919 const docstring = this.docstringFor(node);
2920 const isExported = this.extractor.isExported?.(node, this.source);
2921
2922 const kind: NodeKind = this.extractor.interfaceKind ?? 'interface';
2923
2924 const interfaceNode = this.createNode(kind, name, node, {
2925 docstring,
2926 isExported,
2927 });
2928 if (!interfaceNode) return;
2929
2930 // Extract extends (interface inheritance)
2931 this.extractInheritance(node, interfaceNode.id);
2932
2933 // Visit body children for interface methods and nested types
2934 this.nodeStack.push(interfaceNode.id);
2935 let body = this.extractor.resolveBody?.(node, this.extractor.bodyField)
2936 ?? getChildByField(node, this.extractor.bodyField);
2937 if (!body) body = node;
2938 for (let i = 0; i < body.namedChildCount; i++) {
2939 const child = body.namedChild(i);
2940 if (child) {
2941 this.visitNode(child);
2942 }
2943 }
2944 this.nodeStack.pop();
2945 }
2946
2947 /**
2948 * Extract a struct

Callers 2

dispatchNodeMethod · 0.95

Calls 7

docstringForMethod · 0.95
createNodeMethod · 0.95
extractInheritanceMethod · 0.95
visitNodeMethod · 0.95
getChildByFieldFunction · 0.90
extractNameFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected