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

Method consider_decorator

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

Source from the content-addressed store, hash-verified

1975 }
1976
1977 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
1978 if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") {
1979 return;
1980 }
1981 let mut target: Option<Node<'t>> = None;
1982 let mut cursor = n.walk();
1983 let kids: Vec<Node<'t>> = n.named_children(&mut cursor).collect();
1984 for child in kids {
1985 if child.kind() == "call_expression" {
1986 let fnn = child.child_by_field_name("function").or_else(|| child.named_child(0));
1987 if let Some(f) = fnn {
1988 target = Some(f);
1989 }
1990 if target.is_some() {
1991 break;
1992 }
1993 }
1994 if matches!(
1995 child.kind(),
1996 "identifier" | "member_expression" | "scoped_identifier" | "navigation_expression"
1997 | "user_type" | "type_identifier"
1998 ) {
1999 target = Some(child);
2000 break;
2001 }
2002 }
2003 let Some(target) = target else { return };
2004 let mut name = self.text(target).to_string();
2005 if let Some(lt) = name.find('<') {
2006 if lt > 0 {
2007 name.truncate(lt);
2008 }
2009 }
2010 let last_dot = name.rfind('.').map(|i| i as i64).unwrap_or(-1);
2011 let last_colons = name.rfind("::").map(|i| (i + 1) as i64).unwrap_or(-1);
2012 let last = last_dot.max(last_colons);
2013 if last >= 0 {
2014 name = name[(last as usize + 1)..].to_string();
2015 name = name.trim_start_matches([':', '.']).to_string();
2016 }
2017 let name = name.trim().to_string();
2018 if name.is_empty() {
2019 return;
2020 }
2021 self.push_ref_at(decorated_row, &name, "decorates", n);
2022 }
2023
2024 // --- extractInheritance — the dart rows (:5368-5393, :5437-5459) ------
2025

Callers 1

Calls 5

mapMethod · 0.80
textMethod · 0.65
walkMethod · 0.45
collectMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected