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

Method consider_decorator

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

Source from the content-addressed store, hash-verified

1118 }
1119
1120 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
1121 if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") {
1122 return;
1123 }
1124 let mut target: Option<Node<'t>> = None;
1125 let mut cursor = n.walk();
1126 let kids: Vec<Node<'t>> = n.named_children(&mut cursor).collect();
1127 for child in kids {
1128 if child.kind() == "call_expression" {
1129 let fnn = child.child_by_field_name("function").or_else(|| child.named_child(0));
1130 if let Some(f) = fnn {
1131 target = Some(f);
1132 }
1133 if target.is_some() {
1134 break;
1135 }
1136 }
1137 if matches!(
1138 child.kind(),
1139 "identifier" | "member_expression" | "scoped_identifier" | "navigation_expression"
1140 | "user_type" | "type_identifier"
1141 ) {
1142 target = Some(child);
1143 break;
1144 }
1145 }
1146 let Some(target) = target else { return };
1147 let mut name = self.text(target).to_string();
1148 if let Some(lt) = name.find('<') {
1149 if lt > 0 {
1150 name.truncate(lt);
1151 }
1152 }
1153 let last_dot = name.rfind('.').map(|i| i as i64).unwrap_or(-1);
1154 let last_colons = name.rfind("::").map(|i| (i + 1) as i64).unwrap_or(-1);
1155 let last = last_dot.max(last_colons);
1156 if last >= 0 {
1157 name = name[(last as usize + 1)..].to_string();
1158 name = name.trim_start_matches([':', '.']).to_string();
1159 }
1160 let name = name.trim().to_string();
1161 if name.is_empty() {
1162 return;
1163 }
1164 self.push_ref_at(decorated_row, &name, "decorates", n);
1165 }
1166
1167 // --- extractInheritance — the dart rows (:5368-5393, :5437-5459) ------
1168

Callers 1

Calls 3

collectMethod · 0.45
textMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected