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

Method consider_decorator

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 5

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

Tested by

no test coverage detected