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

Function goStructFieldTypeNames

src/extraction/languages/go.ts:144–159  ·  view source on GitHub ↗
(node: SyntaxNode, source: string)

Source from the content-addressed store, hash-verified

142 * written bare, which a linked list's `next *node` names.
143 */
144export function goStructFieldTypeNames(node: SyntaxNode, source: string): SyntaxNode[] {
145 const fields = getChildByField(node, 'type')?.namedChildren.find((c: SyntaxNode) => c.type === 'field_declaration_list');
146 const names: SyntaxNode[] = [];
147 if (!fields) return names;
148 const declared = goDeclaredNames(node, source);
149 for (const field of fields.namedChildren) {
150 if (field.type !== 'field_declaration') continue;
151 let type = getChildByField(field, 'type');
152 // Embedded: no field name (extractInheritance's test).
153 if (type && !field.namedChildren.some((c: SyntaxNode) => c.type === 'field_identifier')) {
154 type = type.type === 'generic_type' ? getChildByField(type, 'type_arguments') : null;
155 }
156 if (type) collectGoTypeNames(type, declared, source, names);
157 }
158 return names;
159}
160
161/**
162 * The name nodes of the types a Go interface method's signature names, in

Callers 1

extractTypeAliasMethod · 0.90

Calls 3

getChildByFieldFunction · 0.90
goDeclaredNamesFunction · 0.85
collectGoTypeNamesFunction · 0.85

Tested by

no test coverage detected