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

Method consider_decorator

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

Source from the content-addressed store, hash-verified

1184 }
1185
1186 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
1187 if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") {
1188 return;
1189 }
1190 let mut target: Option<Node> = None;
1191 for i in 0..n.named_child_count() {
1192 let Some(child) = n.named_child(i) else { continue };
1193 if child.kind() == "call_expression" {
1194 target = child.child_by_field_name("function").or_else(|| child.named_child(0));
1195 if target.is_some() {
1196 break;
1197 }
1198 }
1199 if matches!(
1200 child.kind(),
1201 "identifier" | "member_expression" | "scoped_identifier" | "navigation_expression"
1202 | "user_type" | "type_identifier"
1203 ) {
1204 target = Some(child);
1205 break;
1206 }
1207 }
1208 let Some(target) = target else { return };
1209 let mut name = self.text(target).to_string();
1210 if let Some(lt) = name.find('<') {
1211 if lt > 0 {
1212 name.truncate(lt);
1213 }
1214 }
1215 let last_dot = name
1216 .rfind('.')
1217 .map(|i| i as isize)
1218 .unwrap_or(-1)
1219 .max(name.rfind("::").map(|i| i as isize).unwrap_or(-1));
1220 if last_dot >= 0 {
1221 name = name[(last_dot as usize + 1)..].to_string();
1222 if name.starts_with(':') || name.starts_with('.') {
1223 name.remove(0);
1224 }
1225 }
1226 let name = name.trim().to_string();
1227 if name.is_empty() {
1228 return;
1229 }
1230 self.push_ref(decorated_row, &name, edge_kind_index("decorates").unwrap(), n);
1231 }
1232
1233 // --- extractInheritance (TS/JS clauses) ---------------------------------------------------
1234

Callers 1

Calls 4

edge_kind_indexFunction · 0.85
textMethod · 0.65
unwrapMethod · 0.60
push_refMethod · 0.45

Tested by

no test coverage detected