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

Method consider_decorator

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

Source from the content-addressed store, hash-verified

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

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