MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / try_visit_hook

Method try_visit_hook

codegraph-kernel/src/php.rs:485–535  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

483 // --- the visitNode hook (php.ts:108) ------------------------------------------
484
485 fn try_visit_hook(&mut self, node: Node<'t>) -> bool {
486 match node.kind() {
487 // Class/interface/trait/enum/top-level constants: one `constant`
488 // node per const_element, NO extras, values never walked.
489 "const_declaration" => {
490 let elements: Vec<Node> = (0..node.named_child_count())
491 .filter_map(|i| node.named_child(i))
492 .filter(|c| c.kind() == "const_element")
493 .collect();
494 for elem in elements {
495 let name_node = (0..elem.named_child_count())
496 .filter_map(|i| elem.named_child(i))
497 .find(|c| c.kind() == "name");
498 let Some(name_node) = name_node else { continue };
499 let name = self.text(name_node).to_string();
500 self.create_node("constant", &name, elem, Extra::default());
501 }
502 true
503 }
504 // Trait use inside a class-like body: one `implements` ref per
505 // used name (full qualified text), all at the use_declaration's
506 // position — WITH filePath (the hook sets ctx.filePath; v2 flag).
507 "use_declaration" => {
508 let names: Vec<Node> = (0..node.named_child_count())
509 .filter_map(|i| node.named_child(i))
510 .filter(|c| matches!(c.kind(), "name" | "qualified_name"))
511 .collect();
512 let parent = self.top_row();
513 let implements = edge_kind_index("implements").unwrap();
514 let line = self.line_of(node);
515 let col = self.col_of(node);
516 for n in names {
517 let name_ref = self.arena.put(self.text(n));
518 self.tables.push_ref_flagged(
519 &RefRow {
520 from_idx: parent,
521 kind: implements,
522 line,
523 column: col,
524 reference_name: name_ref,
525 candidates: NONE_STR,
526 from_id_str: NONE_STR,
527 },
528 REF_FLAG_FILE_PATH,
529 );
530 }
531 true
532 }
533 _ => false,
534 }
535 }
536
537 // --- the dispatcher (visitNode, PHP-relevant branches) ------------------------
538

Callers 1

visit_nodeMethod · 0.45

Calls 10

edge_kind_indexFunction · 0.85
push_ref_flaggedMethod · 0.80
textMethod · 0.65
putMethod · 0.65
unwrapMethod · 0.60
collectMethod · 0.45
create_nodeMethod · 0.45
top_rowMethod · 0.45
line_ofMethod · 0.45
col_ofMethod · 0.45

Tested by

no test coverage detected