mirror of
https://github.com/OMGeeky/appmap_tracing_test.git
synced 2025-12-27 23:08:08 +01:00
Stuff working: - method calls with the tracing::instrument attribute get recorded and added to the AppMap (as classMap structure if not already there and as event) This results in the Trace View and the Dependency Map starting to work (not with many features yet but hey, better than nothing)
86 lines
2.1 KiB
Rust
86 lines
2.1 KiB
Rust
use crate::appmap_definition::*;
|
|
|
|
pub fn find_class_in_tree<'a>(
|
|
node: &'a CodeObjectType,
|
|
class: &str,
|
|
) -> Option<&'a ClassCodeObject> {
|
|
let children = match node {
|
|
CodeObjectType::Class(c) => {
|
|
if class.ends_with(&c.name) {
|
|
return Some(c);
|
|
}
|
|
if class.starts_with(&c.name) {
|
|
c.children.as_ref()
|
|
} else {
|
|
None
|
|
}
|
|
}
|
|
_ => None,
|
|
};
|
|
if let Some(children) = children {
|
|
for x in children.iter() {
|
|
let child_found = find_class_in_tree(x, class);
|
|
if child_found.is_some() {
|
|
return child_found;
|
|
}
|
|
}
|
|
}
|
|
return None;
|
|
}
|
|
pub fn is_node_the_searched_function<'a>(
|
|
node: &'a CodeObjectType,
|
|
method: &str,
|
|
) -> Option<&'a CodeObjectType> {
|
|
match node {
|
|
CodeObjectType::Function(f) => {
|
|
if f.name == method {
|
|
return Some(node);
|
|
}
|
|
None
|
|
}
|
|
_ => None,
|
|
}
|
|
}
|
|
pub fn find_class_in_tree_mut<'a>(
|
|
node: &'a mut CodeObjectType,
|
|
class: &str,
|
|
) -> Option<&'a mut ClassCodeObject> {
|
|
println!("trying to find class: {} in node: {:?}", class, node);
|
|
let children = match node {
|
|
CodeObjectType::Class(c) => {
|
|
if class.ends_with(&c.name) {
|
|
return Some(c);
|
|
}
|
|
if class.starts_with(&c.name) {
|
|
c.children.as_mut()
|
|
} else {
|
|
None
|
|
}
|
|
}
|
|
_ => None,
|
|
};
|
|
if let Some(children) = children {
|
|
for x in children.iter_mut() {
|
|
let child_found = find_class_in_tree_mut(x, class);
|
|
if child_found.is_some() {
|
|
return child_found;
|
|
}
|
|
}
|
|
}
|
|
return None;
|
|
}
|
|
pub fn is_node_the_searched_function_mut<'a>(
|
|
node: &'a mut CodeObjectType,
|
|
method: &str,
|
|
) -> Option<&'a mut CodeObjectType> {
|
|
match node {
|
|
CodeObjectType::Function(f) => {
|
|
if f.name == method {
|
|
return Some(node);
|
|
}
|
|
None
|
|
}
|
|
_ => None,
|
|
}
|
|
}
|