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

Method consider_decorator

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

Source from the content-addressed store, hash-verified

2077 }
2078
2079 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
2080 if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") {
2081 return;
2082 }
2083 let mut target: Option<Node> = None;
2084 for child in n.named_children(&mut n.walk()) {
2085 if child.kind() == "call_expression" {
2086 target = child.child_by_field_name("function").or_else(|| child.named_child(0));
2087 if target.is_some() {
2088 break;
2089 }
2090 }
2091 if matches!(
2092 child.kind(),
2093 "identifier" | "member_expression" | "scoped_identifier" | "navigation_expression"
2094 | "user_type" | "type_identifier"
2095 ) {
2096 target = Some(child);
2097 break;
2098 }
2099 }
2100 let Some(target) = target else { return };
2101 let mut name = self.text(target).to_string();
2102 if let Some(lt) = name.find('<') {
2103 if lt > 0 {
2104 name.truncate(lt);
2105 }
2106 }
2107 let last_dot = name
2108 .rfind('.')
2109 .map(|i| i as isize)
2110 .unwrap_or(-1)
2111 .max(name.rfind("::").map(|i| i as isize).unwrap_or(-1));
2112 if last_dot >= 0 {
2113 name = name[(last_dot as usize + 1)..].to_string();
2114 if name.starts_with(':') || name.starts_with('.') {
2115 name.remove(0);
2116 }
2117 }
2118 let name = name.trim().to_string();
2119 if name.is_empty() {
2120 return;
2121 }
2122 self.push_ref(decorated_row, &name, edge_kind_index("decorates").unwrap(), n);
2123 }
2124
2125 // --- extractInheritance (TS/JS clauses) ---------------------------------------------------
2126

Callers 1

Calls 6

edge_kind_indexFunction · 0.85
mapMethod · 0.80
textMethod · 0.65
unwrapMethod · 0.60
walkMethod · 0.45
push_refMethod · 0.45

Tested by

no test coverage detected