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

Function canonNode

scripts/kernel-parity.mjs:128–141  ·  view source on GitHub ↗

* Node identity for cross-referencing edges/refs: the node id itself (both * paths compute the same deterministic ids, and id embeds kind+name+line).

(n)

Source from the content-addressed store, hash-verified

126 * paths compute the same deterministic ids, and id embeds kind+name+line).
127 */
128function canonNode(n) {
129 const out = {
130 id: n.id, kind: n.kind, name: n.name, qualifiedName: n.qualifiedName,
131 filePath: n.filePath, language: n.language,
132 startLine: n.startLine, endLine: n.endLine,
133 startColumn: n.startColumn, endColumn: n.endColumn,
134 };
135 for (const k of ['docstring', 'signature', 'visibility', 'isExported', 'isAsync', 'isStatic', 'isAbstract', 'returnType']) {
136 if (n[k] !== undefined) out[k] = n[k];
137 }
138 if (n.decorators !== undefined) out.decorators = n.decorators;
139 if (n.typeParameters !== undefined) out.typeParameters = n.typeParameters;
140 return JSON.stringify(out);
141}
142
143function canonEdge(e) {
144 const out = { source: e.source, target: e.target, kind: e.kind };

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected