MCPcopy Index your code
hub / github.com/github/copilot-sdk / buildNamespaceTree

Function buildNamespaceTree

java/scripts/codegen/java.ts:1513–1535  ·  view source on GitHub ↗

Build a namespace tree by recursively walking a schema section object

(node: Record<string, unknown>)

Source from the content-addressed store, hash-verified

1511
1512/** Build a namespace tree by recursively walking a schema section object */
1513function buildNamespaceTree(node: Record<string, unknown>): NamespaceTree {
1514 const tree: NamespaceTree = { methods: new Map(), subspaces: new Map() };
1515 for (const [key, value] of Object.entries(node)) {
1516 if (typeof value !== "object" || value === null) continue;
1517 const obj = value as Record<string, unknown>;
1518 if ("rpcMethod" in obj) {
1519 tree.methods.set(key, {
1520 rpcMethod: String(obj.rpcMethod),
1521 stability: String(obj.stability ?? "stable"),
1522 deprecated: obj.deprecated === true,
1523 params: (obj.params as JSONSchema7) ?? null,
1524 result: (obj.result as JSONSchema7) ?? null,
1525 });
1526 } else {
1527 const child = buildNamespaceTree(obj);
1528 // Only add non-empty sub-trees
1529 if (child.methods.size > 0 || child.subspaces.size > 0) {
1530 tree.subspaces.set(key, child);
1531 }
1532 }
1533 }
1534 return tree;
1535}
1536
1537/**
1538 * Derive the Java class name for an API namespace class.

Callers 1

generateRpcWrappersFunction · 0.70

Calls 2

StringFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…