From d1aa6bbe753e50517d568a4b7560f765fbc75bd2 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 11 May 2021 19:50:01 +0200 Subject: Better node label/shapes --- crates/ide/src/view_crate_graph.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'crates') 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::{ sync::Arc, }; -use dot::Id; +use dot::{Id, LabelText}; use ide_db::{ base_db::{CrateGraph, CrateId, Dependency, SourceDatabase, SourceDatabaseExt}, RootDatabase, @@ -97,7 +97,15 @@ impl<'a> dot::Labeller<'a, CrateId, Edge<'a>> for DotCrateGraph { } fn node_id(&'a self, n: &CrateId) -> Id<'a> { - let name = self.graph[*n].display_name.as_ref().map_or("_missing_name_", |name| &*name); - Id::new(format!("{}_{}", name, n.0)).unwrap() + Id::new(format!("_{}", n.0)).unwrap() + } + + fn node_shape(&'a self, _node: &CrateId) -> Option> { + Some(LabelText::LabelStr("box".into())) + } + + fn node_label(&'a self, n: &CrateId) -> LabelText<'a> { + let name = self.graph[*n].display_name.as_ref().map_or("(unnamed crate)", |name| &*name); + LabelText::LabelStr(name.into()) } } -- cgit v1.2.3