Skip to content

Commit 6d2acc6

Browse files
authored
Remove tree command and pretty print functionality (#365)
1 parent e33ec1f commit 6d2acc6

File tree

3 files changed

+2
-124
lines changed

3 files changed

+2
-124
lines changed

bin/dev-cli/src/main.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,6 @@ fn main() {
7474
}
7575
}
7676
}
77-
"tree" => {
78-
let (graph, query_tree, _supergraph_state) = process_merged_tree(&args[2], &args[3]);
79-
80-
println!(
81-
"{}",
82-
query_tree
83-
.pretty_print(&graph)
84-
.expect("failed to print merged tree")
85-
)
86-
}
8777
"fetch_graph" => {
8878
let fetch_graph = process_fetch_graph(&args[2], &args[3]);
8979
println!("{}", fetch_graph);

lib/query-planner/src/planner/tree/query_tree.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{fmt::Write, sync::Arc};
1+
use std::sync::Arc;
22

33
use tracing::instrument;
44

@@ -61,16 +61,4 @@ impl QueryTree {
6161

6262
accumulator
6363
}
64-
65-
pub fn pretty_print(&self, graph: &Graph) -> Result<String, std::fmt::Error> {
66-
let mut result = String::new();
67-
let root_node = graph.node(self.root.node_index).unwrap();
68-
write!(result, "{}", root_node)?;
69-
70-
for step in self.root.children.iter() {
71-
write!(result, "{}", step.pretty_print(graph, 1)?)?;
72-
}
73-
74-
Ok(result)
75-
}
7664
}

lib/query-planner/src/planner/tree/query_tree_node.rs

Lines changed: 1 addition & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
use petgraph::graph::{EdgeIndex, NodeIndex};
2-
use std::fmt::Write;
32
use std::sync::Arc;
43
use tracing::{instrument, trace};
54

65
use crate::{
76
ast::{arguments::ArgumentsMap, merge_path::Condition},
8-
graph::{edge::Edge, error::GraphError, Graph},
7+
graph::{error::GraphError, Graph},
98
planner::walker::path::{OperationPath, PathSegment, SelectionAttributes},
109
};
1110

@@ -225,103 +224,4 @@ impl QueryTreeNode {
225224

226225
Ok(root_tree_node)
227226
}
228-
229-
fn internal_pretty_print(
230-
&self,
231-
graph: &Graph,
232-
indent_level: usize,
233-
) -> Result<String, std::fmt::Error> {
234-
let mut result = String::new();
235-
let indent = " ".repeat(indent_level);
236-
237-
let edge_index = self
238-
.edge_from_parent
239-
.expect("internal_pretty_print called on a node without a parent edge");
240-
let edge = graph.edge(edge_index).unwrap();
241-
242-
let node = graph.node(self.node_index).unwrap();
243-
let tail_str = format!("{}", node);
244-
245-
let condition_str = match self.condition.as_ref() {
246-
Some(condition) => format!(" {}", condition),
247-
None => "".to_string(),
248-
};
249-
250-
if !self.requirements.is_empty() {
251-
write!(result, "\n{}🧩 [", indent)?;
252-
253-
for req_step in self.requirements.iter() {
254-
write!(result, "{}", req_step.pretty_print(graph, indent_level)?)?;
255-
}
256-
257-
write!(result, "\n{}]", indent)?;
258-
}
259-
260-
match edge {
261-
Edge::EntityMove(_) => {
262-
write!(result, "\n{}🔑 {}", indent, tail_str)
263-
}
264-
Edge::SubgraphEntrypoint { .. } => {
265-
write!(result, "\n{}🚪 ({})", indent, tail_str)
266-
}
267-
Edge::AbstractMove(t) => {
268-
write!(result, "\n{}... on {}{}", indent, t, condition_str)
269-
}
270-
_ => {
271-
let args_str = self
272-
.selection_arguments()
273-
.map(|v| match v.is_empty() {
274-
true => "".to_string(),
275-
false => format!("({})", v),
276-
})
277-
.unwrap_or("".to_string());
278-
write!(
279-
result,
280-
"\n{}{}{} of {}{}",
281-
indent,
282-
edge.display_name(),
283-
args_str,
284-
tail_str,
285-
condition_str
286-
)
287-
}
288-
}?;
289-
290-
for sub_step in self.children.iter() {
291-
write!(
292-
result,
293-
"{}",
294-
sub_step.pretty_print(graph, indent_level + 1)?
295-
)?;
296-
}
297-
298-
Ok(result)
299-
}
300-
301-
pub fn pretty_print(
302-
&self,
303-
graph: &Graph,
304-
indent_level: usize,
305-
) -> Result<String, std::fmt::Error> {
306-
let mut result = String::new();
307-
308-
match self.edge_from_parent {
309-
Some(_) => write!(
310-
result,
311-
"{}",
312-
self.internal_pretty_print(graph, indent_level)?
313-
)?,
314-
None => {
315-
for sub_step in self.children.iter() {
316-
write!(
317-
result,
318-
"{}",
319-
sub_step.pretty_print(graph, indent_level + 1)?
320-
)?;
321-
}
322-
}
323-
};
324-
325-
Ok(result)
326-
}
327227
}

0 commit comments

Comments
 (0)