aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-05-11 18:50:01 +0100
committerJonas Schievink <[email protected]>2021-05-11 18:50:01 +0100
commitd1aa6bbe753e50517d568a4b7560f765fbc75bd2 (patch)
tree8f0de96387c0007af24617df9469df9248083c89 /crates/ide
parent5b3af25121b320a8eb66e2688add7883356e138f (diff)
Better node label/shapes
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/view_crate_graph.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/crates/ide/src/view_crate_graph.rs b/crates/ide/src/view_crate_graph.rs
index 527a5ae0d..5e4ba881e 100644
--- a/crates/ide/src/view_crate_graph.rs
+++ b/crates/ide/src/view_crate_graph.rs
@@ -5,7 +5,7 @@ use std::{
5 sync::Arc, 5 sync::Arc,
6}; 6};
7 7
8use dot::Id; 8use dot::{Id, LabelText};
9use ide_db::{ 9use ide_db::{
10 base_db::{CrateGraph, CrateId, Dependency, SourceDatabase, SourceDatabaseExt}, 10 base_db::{CrateGraph, CrateId, Dependency, SourceDatabase, SourceDatabaseExt},
11 RootDatabase, 11 RootDatabase,
@@ -97,7 +97,15 @@ impl<'a> dot::Labeller<'a, CrateId, Edge<'a>> for DotCrateGraph {
97 } 97 }
98 98
99 fn node_id(&'a self, n: &CrateId) -> Id<'a> { 99 fn node_id(&'a self, n: &CrateId) -> Id<'a> {
100 let name = self.graph[*n].display_name.as_ref().map_or("_missing_name_", |name| &*name); 100 Id::new(format!("_{}", n.0)).unwrap()
101 Id::new(format!("{}_{}", name, n.0)).unwrap() 101 }
102
103 fn node_shape(&'a self, _node: &CrateId) -> Option<LabelText<'a>> {
104 Some(LabelText::LabelStr("box".into()))
105 }
106
107 fn node_label(&'a self, n: &CrateId) -> LabelText<'a> {
108 let name = self.graph[*n].display_name.as_ref().map_or("(unnamed crate)", |name| &*name);
109 LabelText::LabelStr(name.into())
102 } 110 }
103} 111}