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

Method consider_decorator

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

Source from the content-addressed store, hash-verified

812 }
813
814 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
815 if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") {
816 return;
817 }
818 let mut target: Option<Node> = None;
819 for child in n.named_children(&mut n.walk()) {
820 if child.kind() == "call_expression" {
821 target = child.child_by_field_name("function").or_else(|| child.named_child(0));
822 if target.is_some() {
823 break;
824 }
825 }
826 if matches!(
827 child.kind(),
828 "identifier" | "member_expression" | "scoped_identifier" | "navigation_expression"
829 | "user_type" | "type_identifier"
830 ) {
831 target = Some(child);
832 break;
833 }
834 }
835 let Some(target) = target else { return };
836 let mut name = self.text(target).to_string();
837 if let Some(lt) = name.find('<') {
838 if lt > 0 {
839 name.truncate(lt);
840 }
841 }
842 let last_dot = name
843 .rfind('.')
844 .map(|i| i as isize)
845 .unwrap_or(-1)
846 .max(name.rfind("::").map(|i| i as isize).unwrap_or(-1));
847 if last_dot >= 0 {
848 name = name[(last_dot as usize + 1)..].to_string();
849 if name.starts_with(':') || name.starts_with('.') {
850 name.remove(0);
851 }
852 }
853 let name = name.trim().to_string();
854 if name.is_empty() {
855 return;
856 }
857 self.push_ref_at(decorated_row, &name, edge_kind_index("decorates").unwrap(), n);
858 }
859
860 // --- fn refs (PYTHON_SPEC) ------------------------------------------------------
861

Callers 1

Calls 6

edge_kind_indexFunction · 0.85
mapMethod · 0.80
textMethod · 0.65
unwrapMethod · 0.60
walkMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected