MCPcopy
hub / github.com/colbymchenry/codegraph / cDeclaratorIdentifier

Function cDeclaratorIdentifier

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

* Resolve the declared identifier inside a C declarator. A `declaration`'s * `declarator` field nests the name through `init_declarator` (with value), * `pointer_declarator`/`array_declarator`/`parenthesized_declarator` * wrappers (each via their own `declarator` field) down to an `identifier`.

(node: SyntaxNode | null)

Source from the content-addressed store, hash-verified

207 * function-pointer var) — return null so it isn't extracted as a variable.
208 */
209function cDeclaratorIdentifier(node: SyntaxNode | null): SyntaxNode | null {
210 let cur: SyntaxNode | null = node;
211 let guard = 0;
212 while (cur && guard++ < 12) {
213 switch (cur.type) {
214 case 'identifier':
215 return cur;
216 case 'function_declarator':
217 return null;
218 case 'init_declarator':
219 case 'pointer_declarator':
220 case 'array_declarator':
221 case 'parenthesized_declarator':
222 cur = getChildByField(cur, 'declarator');
223 break;
224 default:
225 return null;
226 }
227 }
228 return null;
229}
230
231/** First `simple_identifier` in `node`'s subtree (breadth-ish, first-found).
232 * Swift's property name nests as `property_declaration → <name> pattern →

Callers 2

flushValueRefsMethod · 0.85
extractVariableMethod · 0.85

Calls 1

getChildByFieldFunction · 0.90

Tested by

no test coverage detected