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

Method consider_decorator

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

Source from the content-addressed store, hash-verified

1941 }
1942
1943 fn consider_decorator(&mut self, n: Node<'t>, decorated_row: u32) {
1944 if !matches!(n.kind(), "decorator" | "annotation" | "marker_annotation" | "attribute") {
1945 return;
1946 }
1947 let mut target: Option<Node> = None;
1948 for i in 0..n.named_child_count() {
1949 let Some(child) = n.named_child(i) else { continue };
1950 if child.kind() == "call_expression" {
1951 target = child.child_by_field_name("function").or_else(|| child.named_child(0));
1952 if target.is_some() {
1953 break;
1954 }
1955 }
1956 if matches!(
1957 child.kind(),
1958 "identifier" | "member_expression" | "scoped_identifier" | "navigation_expression"
1959 | "user_type" | "type_identifier"
1960 ) {
1961 target = Some(child);
1962 break;
1963 }
1964 }
1965 let Some(target) = target else { return };
1966 let mut name = self.text(target).to_string();
1967 if let Some(lt) = name.find('<') {
1968 if lt > 0 {
1969 name.truncate(lt);
1970 }
1971 }
1972 let last_dot = name
1973 .rfind('.')
1974 .map(|i| i as isize)
1975 .unwrap_or(-1)
1976 .max(name.rfind("::").map(|i| i as isize).unwrap_or(-1));
1977 if last_dot >= 0 {
1978 name = name[(last_dot as usize + 1)..].to_string();
1979 if name.starts_with(':') || name.starts_with('.') {
1980 name.remove(0);
1981 }
1982 }
1983 let name = name.trim().to_string();
1984 if name.is_empty() {
1985 return;
1986 }
1987 self.push_ref(decorated_row, &name, edge_kind_index("decorates").unwrap(), n);
1988 }
1989
1990 // --- extractInheritance (TS/JS clauses) ---------------------------------------------------
1991

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