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

Method try_visit_hook

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

Source from the content-addressed store, hash-verified

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

Callers 1

visit_nodeMethod · 0.45

Calls 10

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

Tested by

no test coverage detected