Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 38 additions & 14 deletions crates/debugging/src/tree/ui/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use std::fmt::Debug;
/// All nodes should have a tag that explains what the node represents
/// and a pretty string representation of data held by the node.
pub trait NodeDisplay {
const TAG: &'static str;
fn tag(&self) -> &'static str;
fn string_pretty(&self) -> String;

fn display(&self) -> String {
let tag = console::style(Self::TAG).magenta();
let tag = console::style(self.tag()).magenta();
let content = self.string_pretty();
if content.is_empty() {
format!("[{tag}]")
Expand All @@ -27,84 +27,108 @@ pub trait NodeDisplay {
}

impl NodeDisplay for TestName {
const TAG: &'static str = "test name";
fn tag(&self) -> &'static str {
"test name"
}
fn string_pretty(&self) -> String {
self.0.clone()
}
}

impl NodeDisplay for ContractName {
const TAG: &'static str = "contract name";
fn tag(&self) -> &'static str {
"contract name"
}
fn string_pretty(&self) -> String {
self.0.to_string()
}
}

impl NodeDisplay for Selector {
const TAG: &'static str = "selector";
fn tag(&self) -> &'static str {
"selector"
}
fn string_pretty(&self) -> String {
self.0.to_string()
}
}

impl NodeDisplay for EntryPointType {
const TAG: &'static str = "entry point type";
fn tag(&self) -> &'static str {
"entry point type"
}
fn string_pretty(&self) -> String {
string_debug(self)
}
}

impl NodeDisplay for TransformedCalldata {
const TAG: &'static str = "calldata";
fn tag(&self) -> &'static str {
"calldata"
}
fn string_pretty(&self) -> String {
self.0.clone()
}
}

impl NodeDisplay for ContractAddress {
const TAG: &'static str = "contract address";
fn tag(&self) -> &'static str {
"contract address"
}
fn string_pretty(&self) -> String {
string_hex(self.0)
}
}

impl NodeDisplay for CallerAddress {
const TAG: &'static str = "caller address";
fn tag(&self) -> &'static str {
"caller address"
}
fn string_pretty(&self) -> String {
string_hex(self.0)
}
}

impl NodeDisplay for CallType {
const TAG: &'static str = "call type";
fn tag(&self) -> &'static str {
"call type"
}
fn string_pretty(&self) -> String {
string_debug(self)
}
}

impl NodeDisplay for TransformedCallResult {
const TAG: &'static str = "call result";
fn tag(&self) -> &'static str {
"call result"
}
fn string_pretty(&self) -> String {
self.0.clone()
}
}

impl NodeDisplay for FunctionTrace {
const TAG: &'static str = "function call tree";
fn tag(&self) -> &'static str {
"function call tree"
}
fn string_pretty(&self) -> String {
String::new()
}
}

impl NodeDisplay for FunctionTraceError {
const TAG: &'static str = "function trace error";
fn tag(&self) -> &'static str {
"function trace error"
}
fn string_pretty(&self) -> String {
self.to_string()
}
}

impl NodeDisplay for FunctionNode {
const TAG: &'static str = "non inlined";
fn tag(&self) -> &'static str {
"non inlined"
}
fn string_pretty(&self) -> String {
self.value.function_name().to_string()
}
Expand Down
Loading