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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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