@@ -6131,6 +6131,13 @@ def node_text(node) -> str:
61316131 def named_children (node ) -> list [object ]:
61326132 return [child for child in node .children if getattr (child , "is_named" , False )]
61336133
6134+ def make_clojure_id (* parts : str ) -> str :
6135+ combined = "_" .join (p .strip ("_." ) for p in parts if p )
6136+ combined = unicodedata .normalize ("NFKC" , combined )
6137+ cleaned = re .sub (r"[^\w]+" , "_" , combined , flags = re .UNICODE )
6138+ cleaned = re .sub (r"_+" , "_" , cleaned )
6139+ return cleaned .strip ("_" )
6140+
61346141 def form_head (node ) -> str | None :
61356142 if node .type != "list_lit" :
61366143 return None
@@ -6199,7 +6206,7 @@ def add_import_edges(ns_form) -> None:
61996206 else :
62006207 continue
62016208 if module_name :
6202- add_edge (src_nid , _make_id (module_name ), "imports_from" ,
6209+ add_edge (src_nid , make_clojure_id (module_name ), "imports_from" ,
62036210 module_node .start_point [0 ] + 1 , context = "import" )
62046211 elif clause_head == ":import" :
62056212 for import_form in clause_children [1 :]:
@@ -6214,7 +6221,7 @@ def add_import_edges(ns_form) -> None:
62146221 imported = import_symbols [1 :] or [package ]
62156222 for name in imported :
62166223 target = f"{ package } .{ name } " if name != package else package
6217- add_edge (src_nid , _make_id (target ), "imports" ,
6224+ add_edge (src_nid , make_clojure_id (target ), "imports" ,
62186225 import_form .start_point [0 ] + 1 , context = "import" )
62196226
62206227 def add_protocol_methods (protocol_nid : str , protocol_form ) -> None :
@@ -6225,7 +6232,7 @@ def add_protocol_methods(protocol_nid: str, protocol_form) -> None:
62256232 if not method_name :
62266233 continue
62276234 line = child .start_point [0 ] + 1
6228- method_nid = _make_id (protocol_nid , method_name )
6235+ method_nid = make_clojure_id (protocol_nid , method_name )
62296236 add_node (method_nid , f".{ method_name } ()" , line )
62306237 add_edge (protocol_nid , method_nid , "method" , line )
62316238
@@ -6257,16 +6264,16 @@ def add_definition(form) -> None:
62576264 if head == "defmethod" :
62586265 dispatch = node_text (children [2 ]) if len (children ) > 2 else ""
62596266 label = f"{ name } { dispatch } " .strip ()
6260- nid = _make_id (stem , name , dispatch )
6267+ nid = make_clojure_id (stem , name , dispatch )
62616268 elif head in type_heads :
62626269 label = name
6263- nid = _make_id (stem , name )
6270+ nid = make_clojure_id (stem , name )
62646271 elif head in callable_heads or head == "defmulti" :
62656272 label = f"{ name } ()"
6266- nid = _make_id (stem , name )
6273+ nid = make_clojure_id (stem , name )
62676274 else :
62686275 label = name
6269- nid = _make_id (stem , name )
6276+ nid = make_clojure_id (stem , name )
62706277
62716278 add_node (nid , label , line )
62726279 add_edge (parent_nid (), nid , "contains" , line )
@@ -6284,7 +6291,7 @@ def add_definition(form) -> None:
62846291 ns_children = named_children (child )
62856292 if len (ns_children ) > 1 and ns_children [1 ].type == "sym_lit" :
62866293 namespace_name = node_text (ns_children [1 ])
6287- namespace_nid = _make_id (stem , namespace_name )
6294+ namespace_nid = make_clojure_id (stem , namespace_name )
62886295 add_node (namespace_nid , namespace_name , ns_children [1 ].start_point [0 ] + 1 )
62896296 add_edge (file_nid , namespace_nid , "contains" , ns_children [1 ].start_point [0 ] + 1 )
62906297 add_import_edges (child )
@@ -6295,7 +6302,7 @@ def add_definition(form) -> None:
62956302 for n in nodes :
62966303 raw = n ["label" ]
62976304 normalised = raw .strip ("()" ).lstrip ("." ).split (" " , 1 )[0 ]
6298- label_to_nid [normalised . casefold () ] = n ["id" ]
6305+ label_to_nid [normalised ] = n ["id" ]
62996306
63006307 seen_call_pairs : set [tuple [str , str ]] = set ()
63016308
@@ -6319,7 +6326,7 @@ def walk_calls(node, caller_nid: str) -> None:
63196326 if raw_head :
63206327 callee_name = callee_from_symbol (raw_head )
63216328 if callee_name :
6322- tgt_nid = label_to_nid .get (callee_name . casefold () )
6329+ tgt_nid = label_to_nid .get (callee_name )
63236330 if tgt_nid and tgt_nid != caller_nid :
63246331 pair = (caller_nid , tgt_nid )
63256332 if pair not in seen_call_pairs :
0 commit comments