Remove generics from the user-facing name for the Vector data type

This commit is contained in:
Keavon Chambers 2026-01-01 21:26:02 -08:00
parent fa45efa9e2
commit 2fa958aa79
2 changed files with 19 additions and 16 deletions

View File

@ -233,15 +233,7 @@ pub(crate) fn property_from_type(
widgets.extend_from_slice(&[ widgets.extend_from_slice(&[
Separator::new(SeparatorStyle::Unrelated).widget_instance(), Separator::new(SeparatorStyle::Unrelated).widget_instance(),
TextLabel::new("-") TextLabel::new("-")
.tooltip_label(format!( .tooltip_label(format!("Data Type: {concrete_type}"))
"Data Type: {}",
concrete_type
.alias
.as_deref()
// TODO: Avoid needing to remove spaces here by fixing how `alias` is generated
.map(|s| s.to_string().replace(" ", ""))
.unwrap_or_else(|| graphene_std::format_type(concrete_type.name.as_ref())),
))
.tooltip_description("This data can only be supplied through the node graph because no widget exists for its type.") .tooltip_description("This data can only be supplied through the node graph because no widget exists for its type.")
.widget_instance(), .widget_instance(),
]); ]);
@ -251,7 +243,7 @@ pub(crate) fn property_from_type(
} }
} }
} }
Type::Generic(_) => vec![TextLabel::new("Generic type (not supported)").widget_instance()].into(), Type::Generic(_) => vec![TextLabel::new("Generic Type (Not Supported)").widget_instance()].into(),
Type::Fn(_, out) => return property_from_type(node_id, index, out, number_options, unit, display_decimal_places, step, context), Type::Fn(_, out) => return property_from_type(node_id, index, out, number_options, unit, display_decimal_places, step, context),
Type::Future(out) => return property_from_type(node_id, index, out, number_options, unit, display_decimal_places, step, context), Type::Future(out) => return property_from_type(node_id, index, out, number_options, unit, display_decimal_places, step, context),
}; };

View File

@ -216,6 +216,13 @@ impl std::hash::Hash for TypeDescriptor {
} }
} }
impl std::fmt::Display for TypeDescriptor {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let text = make_type_user_readable(&format_type(&self.name));
write!(f, "{text}")
}
}
impl PartialEq for TypeDescriptor { impl PartialEq for TypeDescriptor {
fn eq(&self, other: &Self) -> bool { fn eq(&self, other: &Self) -> bool {
match (self.id, other.id) { match (self.id, other.id) {
@ -361,9 +368,13 @@ pub fn format_type(ty: &str) -> String {
.join("<") .join("<")
} }
pub fn make_type_user_readable(ty: &str) -> String {
ty.replace("Option<Arc<OwnedContextImpl>>", "Context").replace("Vector<Option<Table<Graphic>>>", "Vector")
}
impl std::fmt::Debug for Type { impl std::fmt::Debug for Type {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let result = match self { let text = match self {
Self::Generic(name) => name.to_string(), Self::Generic(name) => name.to_string(),
#[cfg(feature = "type_id_logging")] #[cfg(feature = "type_id_logging")]
Self::Concrete(ty) => format!("Concrete<{}, {:?}>", ty.name, ty.id), Self::Concrete(ty) => format!("Concrete<{}, {:?}>", ty.name, ty.id),
@ -372,20 +383,20 @@ impl std::fmt::Debug for Type {
Self::Fn(call_arg, return_value) => format!("{return_value:?} called with {call_arg:?}"), Self::Fn(call_arg, return_value) => format!("{return_value:?} called with {call_arg:?}"),
Self::Future(ty) => format!("{ty:?}"), Self::Future(ty) => format!("{ty:?}"),
}; };
let result = result.replace("Option<Arc<OwnedContextImpl>>", "Context"); let text = make_type_user_readable(&text);
write!(f, "{result}") write!(f, "{text}")
} }
} }
impl std::fmt::Display for Type { impl std::fmt::Display for Type {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let result = match self { let text = match self {
Type::Generic(name) => name.to_string(), Type::Generic(name) => name.to_string(),
Type::Concrete(ty) => format_type(&ty.name), Type::Concrete(ty) => format_type(&ty.name),
Type::Fn(call_arg, return_value) => format!("{return_value} called with {call_arg}"), Type::Fn(call_arg, return_value) => format!("{return_value} called with {call_arg}"),
Type::Future(ty) => ty.to_string(), Type::Future(ty) => ty.to_string(),
}; };
let result = result.replace("Option<Arc<OwnedContextImpl>>", "Context"); let text = make_type_user_readable(&text);
write!(f, "{result}") write!(f, "{text}")
} }
} }