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

Method consider_decorator

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

Source from the content-addressed store, hash-verified

842 }
843
844 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
845 if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") {
846 return;
847 }
848 let mut target: Option<Node> = None;
849 for i in 0..n.named_child_count() {
850 let Some(child) = n.named_child(i) else { continue };
851 if child.kind() == "call_expression" {
852 target = child.child_by_field_name("function").or_else(|| child.named_child(0));
853 if target.is_some() {
854 break;
855 }
856 }
857 if matches!(
858 child.kind(),
859 "identifier" | "member_expression" | "scoped_identifier" | "navigation_expression"
860 | "user_type" | "type_identifier"
861 ) {
862 target = Some(child);
863 break;
864 }
865 }
866 let Some(target) = target else { return };
867 let mut name = self.text(target).to_string();
868 if let Some(lt) = name.find('<') {
869 if lt > 0 {
870 name.truncate(lt);
871 }
872 }
873 let last_dot = name
874 .rfind('.')
875 .map(|i| i as isize)
876 .unwrap_or(-1)
877 .max(name.rfind("::").map(|i| i as isize).unwrap_or(-1));
878 if last_dot >= 0 {
879 name = name[(last_dot as usize + 1)..].to_string();
880 if name.starts_with(':') || name.starts_with('.') {
881 name.remove(0);
882 }
883 }
884 let name = name.trim().to_string();
885 if name.is_empty() {
886 return;
887 }
888 self.push_ref_at(decorated_row, &name, edge_kind_index("decorates").unwrap(), n);
889 }
890
891 // --- fn refs (PYTHON_SPEC) ------------------------------------------------------
892

Callers 1

Calls 5

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

Tested by

no test coverage detected