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

Method extractInterface

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

* Extract an interface/protocol/trait

(node: SyntaxNode)

Source from the content-addressed store, hash-verified

3032 * Extract an interface/protocol/trait
3033 */
3034 private extractInterface(node: SyntaxNode): void {
3035 if (!this.extractor) return;
3036
3037 const name = extractName(node, this.source, this.extractor);
3038 const docstring = this.docstringFor(node);
3039 const isExported = this.extractor.isExported?.(node, this.source);
3040
3041 const kind: NodeKind = this.extractor.interfaceKind ?? 'interface';
3042
3043 const interfaceNode = this.createNode(kind, name, node, {
3044 docstring,
3045 isExported,
3046 });
3047 if (!interfaceNode) return;
3048
3049 // Extract extends (interface inheritance)
3050 this.extractInheritance(node, interfaceNode.id);
3051
3052 // Visit body children for interface methods and nested types
3053 this.nodeStack.push(interfaceNode.id);
3054 let body = this.extractor.resolveBody?.(node, this.extractor.bodyField)
3055 ?? getChildByField(node, this.extractor.bodyField);
3056 if (!body) body = node;
3057 for (let i = 0; i < body.namedChildCount; i++) {
3058 const child = body.namedChild(i);
3059 if (child) {
3060 this.visitNode(child);
3061 }
3062 }
3063 this.nodeStack.pop();
3064 }
3065
3066 /**
3067 * 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