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

Method consider_decorator

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 5

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

Tested by

no test coverage detected