trim noisy scalar const types from js_extra_walk, collapse docstring

This commit is contained in:
Safi
2026-05-07 11:02:15 +01:00
parent 2d44788931
commit 9bc79ef6e3
+2 -7
View File
@@ -611,11 +611,7 @@ def _get_cpp_func_name(node, source: bytes) -> str | None:
def _js_extra_walk(node, source: bytes, file_nid: str, stem: str, str_path: str,
nodes: list, edges: list, seen_ids: set, function_bodies: list,
parent_class_nid: str | None, add_node_fn, add_edge_fn) -> bool:
"""Handle lexical_declaration for JS/TS:
- arrow functions / function expressions (existing behaviour)
- module-level const literals (object/array/string/call/new/etc.) — TS codebases
use these for configs, route maps, DI tokens, enum-like unions.
Returns True if handled."""
"""Handle lexical_declaration (arrow functions and module-level const literals) for JS/TS. Returns True if handled."""
if node.type == "lexical_declaration":
for child in node.children:
if child.type == "variable_declarator":
@@ -632,8 +628,7 @@ def _js_extra_walk(node, source: bytes, file_nid: str, stem: str, str_path: str,
if body:
function_bodies.append((func_nid, body))
elif value and value.type in (
"object", "array", "as_expression", "call_expression",
"new_expression", "string", "template_string", "number",
"object", "array", "as_expression", "call_expression", "new_expression",
):
# Module-level const with literal/object/array/factory value
name_node = child.child_by_field_name("name")