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

Method consider_decorator

codegraph-kernel/src/python.rs:666–711  ·  view source on GitHub ↗
(&mut self, n: Node<'t>, decorated_row: u32)

Source from the content-addressed store, hash-verified

664 }
665
666 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
667 if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") {
668 return;
669 }
670 let mut target: Option<Node> = None;
671 for i in 0..n.named_child_count() {
672 let Some(child) = n.named_child(i) else { continue };
673 if child.kind() == "call_expression" {
674 target = child.child_by_field_name("function").or_else(|| child.named_child(0));
675 if target.is_some() {
676 break;
677 }
678 }
679 if matches!(
680 child.kind(),
681 "identifier" | "member_expression" | "scoped_identifier" | "navigation_expression"
682 | "user_type" | "type_identifier"
683 ) {
684 target = Some(child);
685 break;
686 }
687 }
688 let Some(target) = target else { return };
689 let mut name = self.text(target).to_string();
690 if let Some(lt) = name.find('<') {
691 if lt > 0 {
692 name.truncate(lt);
693 }
694 }
695 let last_dot = name
696 .rfind('.')
697 .map(|i| i as isize)
698 .unwrap_or(-1)
699 .max(name.rfind("::").map(|i| i as isize).unwrap_or(-1));
700 if last_dot >= 0 {
701 name = name[(last_dot as usize + 1)..].to_string();
702 if name.starts_with(':') || name.starts_with('.') {
703 name.remove(0);
704 }
705 }
706 let name = name.trim().to_string();
707 if name.is_empty() {
708 return;
709 }
710 self.push_ref_at(decorated_row, &name, edge_kind_index("decorates").unwrap(), n);
711 }
712
713 // --- fn refs (PYTHON_SPEC) ------------------------------------------------------
714

Callers 1

Calls 4

edge_kind_indexFunction · 0.85
textMethod · 0.65
unwrapMethod · 0.60
push_ref_atMethod · 0.45

Tested by

no test coverage detected