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

Method consider_decorator

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

Source from the content-addressed store, hash-verified

1045 }
1046
1047 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
1048 if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") {
1049 return;
1050 }
1051 let mut target: Option<Node<'t>> = None;
1052 let mut cursor = n.walk();
1053 let kids: Vec<Node<'t>> = n.named_children(&mut cursor).collect();
1054 for child in kids {
1055 if child.kind() == "call_expression" {
1056 let fnn = child.child_by_field_name("function").or_else(|| child.named_child(0));
1057 if let Some(f) = fnn {
1058 target = Some(f);
1059 }
1060 if target.is_some() {
1061 break;
1062 }
1063 }
1064 if matches!(
1065 child.kind(),
1066 "identifier" | "member_expression" | "scoped_identifier" | "navigation_expression"
1067 | "user_type" | "type_identifier"
1068 ) {
1069 target = Some(child);
1070 break;
1071 }
1072 }
1073 let Some(target) = target else { return };
1074 let mut name = self.text(target).to_string();
1075 if let Some(lt) = name.find('<') {
1076 if lt > 0 {
1077 name.truncate(lt);
1078 }
1079 }
1080 let last_dot = name.rfind('.').map(|i| i as i64).unwrap_or(-1);
1081 let last_colons = name.rfind("::").map(|i| (i + 1) as i64).unwrap_or(-1);
1082 let last = last_dot.max(last_colons);
1083 if last >= 0 {
1084 name = name[(last as usize + 1)..].to_string();
1085 name = name.trim_start_matches([':', '.']).to_string();
1086 }
1087 let name = name.trim().to_string();
1088 if name.is_empty() {
1089 return;
1090 }
1091 self.push_ref_at(decorated_row, &name, "decorates", n);
1092 }
1093
1094 // --- extractInheritance — the scala branch (:5339-5360) ---------------
1095

Callers 1

Calls 3

textMethod · 0.65
collectMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected