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

Method consider_decorator

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 4

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

Tested by

no test coverage detected