gitnexus 1.6.3-rc.23 → 1.6.3-rc.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,17 +55,17 @@ const FUNCTION_LIKE_TYPES = new Set([
55
55
  * numbers don't apply.
56
56
  */
57
57
  export const findFunctionNode = (root) => {
58
- if (FUNCTION_LIKE_TYPES.has(root.type))
59
- return root;
60
- for (let i = 0; i < root.namedChildCount; i++) {
61
- const child = root.namedChild(i);
62
- if (!child)
63
- continue;
64
- if (FUNCTION_LIKE_TYPES.has(child.type))
65
- return child;
66
- const found = findFunctionNode(child);
67
- if (found)
68
- return found;
58
+ // Iterative DFS — avoids stack overflow on deeply nested ASTs.
59
+ const stack = [root];
60
+ while (stack.length > 0) {
61
+ const node = stack.pop();
62
+ if (FUNCTION_LIKE_TYPES.has(node.type))
63
+ return node;
64
+ for (let i = node.namedChildCount - 1; i >= 0; i--) {
65
+ const child = node.namedChild(i);
66
+ if (child)
67
+ stack.push(child);
68
+ }
69
69
  }
70
70
  return null;
71
71
  };
@@ -89,17 +89,17 @@ export const findDeclarationNode = (root) => {
89
89
  'object_declaration', // Kotlin: object
90
90
  'impl_item', // Rust: impl
91
91
  ]);
92
- if (CLASS_LIKE_TYPES.has(root.type))
93
- return root;
94
- for (let i = 0; i < root.namedChildCount; i++) {
95
- const child = root.namedChild(i);
96
- if (!child)
97
- continue;
98
- if (CLASS_LIKE_TYPES.has(child.type))
99
- return child;
100
- const found = findDeclarationNode(child);
101
- if (found)
102
- return found;
92
+ // Iterative DFS — avoids stack overflow on deeply nested ASTs.
93
+ const stack = [root];
94
+ while (stack.length > 0) {
95
+ const node = stack.pop();
96
+ if (CLASS_LIKE_TYPES.has(node.type))
97
+ return node;
98
+ for (let i = node.namedChildCount - 1; i >= 0; i--) {
99
+ const child = node.namedChild(i);
100
+ if (child)
101
+ stack.push(child);
102
+ }
103
103
  }
104
104
  return null;
105
105
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.3-rc.23",
3
+ "version": "1.6.3-rc.24",
4
4
  "description": "Graph-powered code intelligence for AI agents. Index any codebase, query via MCP or CLI.",
5
5
  "author": "Abhigyan Patwari",
6
6
  "license": "PolyForm-Noncommercial-1.0.0",