Skip to content

Commit d1aa6bb

Browse files
Better node label/shapes
1 parent 5b3af25 commit d1aa6bb

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

crates/ide/src/view_crate_graph.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
sync::Arc,
66
};
77

8-
use dot::Id;
8+
use dot::{Id, LabelText};
99
use ide_db::{
1010
base_db::{CrateGraph, CrateId, Dependency, SourceDatabase, SourceDatabaseExt},
1111
RootDatabase,
@@ -97,7 +97,15 @@ impl<'a> dot::Labeller<'a, CrateId, Edge<'a>> for DotCrateGraph {
9797
}
9898

9999
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);
101-
Id::new(format!("{}_{}", name, n.0)).unwrap()
100+
Id::new(format!("_{}", 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())
102110
}
103111
}

0 commit comments

Comments
 (0)