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

Method consider_decorator

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

Source from the content-addressed store, hash-verified

1062 }
1063
1064 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
1065 if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") {
1066 return;
1067 }
1068 let mut target: Option<Node<'t>> = None;
1069 let mut cursor = n.walk();
1070 let kids: Vec<Node<'t>> = n.named_children(&mut cursor).collect();
1071 for child in kids {
1072 if child.kind() == "call_expression" {
1073 let fnn = child.child_by_field_name("function").or_else(|| child.named_child(0));
1074 if let Some(f) = fnn {
1075 target = Some(f);
1076 }
1077 if target.is_some() {
1078 break;
1079 }
1080 }
1081 if matches!(
1082 child.kind(),
1083 "identifier" | "member_expression" | "scoped_identifier" | "navigation_expression"
1084 | "user_type" | "type_identifier"
1085 ) {
1086 target = Some(child);
1087 break;
1088 }
1089 }
1090 let Some(target) = target else { return };
1091 let mut name = self.text(target).to_string();
1092 if let Some(lt) = name.find('<') {
1093 if lt > 0 {
1094 name.truncate(lt);
1095 }
1096 }
1097 let last_dot = name.rfind('.').map(|i| i as i64).unwrap_or(-1);
1098 let last_colons = name.rfind("::").map(|i| (i + 1) as i64).unwrap_or(-1);
1099 let last = last_dot.max(last_colons);
1100 if last >= 0 {
1101 name = name[(last as usize + 1)..].to_string();
1102 name = name.trim_start_matches([':', '.']).to_string();
1103 }
1104 let name = name.trim().to_string();
1105 if name.is_empty() {
1106 return;
1107 }
1108 self.push_ref_at(decorated_row, &name, "decorates", n);
1109 }
1110
1111 // --- extractInheritance — the scala branch (:5339-5360) ---------------
1112

Callers 1

Calls 5

walkMethod · 0.80
mapMethod · 0.80
textMethod · 0.65
collectMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected