Skip to content

Commit 2fa958a

Browse files
committed
Remove generics from the user-facing name for the Vector data type
1 parent fa45efa commit 2fa958a

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

editor/src/messages/portfolio/document/node_graph/node_properties.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,7 @@ pub(crate) fn property_from_type(
233233
widgets.extend_from_slice(&[
234234
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
235235
TextLabel::new("-")
236-
.tooltip_label(format!(
237-
"Data Type: {}",
238-
concrete_type
239-
.alias
240-
.as_deref()
241-
// TODO: Avoid needing to remove spaces here by fixing how `alias` is generated
242-
.map(|s| s.to_string().replace(" ", ""))
243-
.unwrap_or_else(|| graphene_std::format_type(concrete_type.name.as_ref())),
244-
))
236+
.tooltip_label(format!("Data Type: {concrete_type}"))
245237
.tooltip_description("This data can only be supplied through the node graph because no widget exists for its type.")
246238
.widget_instance(),
247239
]);
@@ -251,7 +243,7 @@ pub(crate) fn property_from_type(
251243
}
252244
}
253245
}
254-
Type::Generic(_) => vec![TextLabel::new("Generic type (not supported)").widget_instance()].into(),
246+
Type::Generic(_) => vec![TextLabel::new("Generic Type (Not Supported)").widget_instance()].into(),
255247
Type::Fn(_, out) => return property_from_type(node_id, index, out, number_options, unit, display_decimal_places, step, context),
256248
Type::Future(out) => return property_from_type(node_id, index, out, number_options, unit, display_decimal_places, step, context),
257249
};

node-graph/libraries/core-types/src/types.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,13 @@ impl std::hash::Hash for TypeDescriptor {
216216
}
217217
}
218218

219+
impl std::fmt::Display for TypeDescriptor {
220+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
221+
let text = make_type_user_readable(&format_type(&self.name));
222+
write!(f, "{text}")
223+
}
224+
}
225+
219226
impl PartialEq for TypeDescriptor {
220227
fn eq(&self, other: &Self) -> bool {
221228
match (self.id, other.id) {
@@ -361,9 +368,13 @@ pub fn format_type(ty: &str) -> String {
361368
.join("<")
362369
}
363370

371+
pub fn make_type_user_readable(ty: &str) -> String {
372+
ty.replace("Option<Arc<OwnedContextImpl>>", "Context").replace("Vector<Option<Table<Graphic>>>", "Vector")
373+
}
374+
364375
impl std::fmt::Debug for Type {
365376
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
366-
let result = match self {
377+
let text = match self {
367378
Self::Generic(name) => name.to_string(),
368379
#[cfg(feature = "type_id_logging")]
369380
Self::Concrete(ty) => format!("Concrete<{}, {:?}>", ty.name, ty.id),
@@ -372,20 +383,20 @@ impl std::fmt::Debug for Type {
372383
Self::Fn(call_arg, return_value) => format!("{return_value:?} called with {call_arg:?}"),
373384
Self::Future(ty) => format!("{ty:?}"),
374385
};
375-
let result = result.replace("Option<Arc<OwnedContextImpl>>", "Context");
376-
write!(f, "{result}")
386+
let text = make_type_user_readable(&text);
387+
write!(f, "{text}")
377388
}
378389
}
379390

380391
impl std::fmt::Display for Type {
381392
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
382-
let result = match self {
393+
let text = match self {
383394
Type::Generic(name) => name.to_string(),
384395
Type::Concrete(ty) => format_type(&ty.name),
385396
Type::Fn(call_arg, return_value) => format!("{return_value} called with {call_arg}"),
386397
Type::Future(ty) => ty.to_string(),
387398
};
388-
let result = result.replace("Option<Arc<OwnedContextImpl>>", "Context");
389-
write!(f, "{result}")
399+
let text = make_type_user_readable(&text);
400+
write!(f, "{text}")
390401
}
391402
}

0 commit comments

Comments
 (0)