Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ambiguousname committed Oct 25, 2024
1 parent 19f44b6 commit 0366be1
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions tool/src/demo_gen/terminus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct MethodDependency {
params: Vec<ParamInfo>,

/// The type name that this method belongs to. Currently used by [`OutParam`] for better default parameter names.
owning_type : String,
owning_type: String,
}

pub(super) struct RenderTerminusContext<'ctx, 'tcx> {
Expand All @@ -63,7 +63,7 @@ impl MethodDependency {
MethodDependency {
method_js,
params: Vec::new(),
owning_type
owning_type,
}
}
}
Expand Down Expand Up @@ -159,8 +159,10 @@ impl<'ctx, 'tcx> RenderTerminusContext<'ctx, 'tcx> {

// Not making this as part of the RenderTerminusContext because we want each evaluation to have a specific node,
// which I find easier easier to represent as a parameter to each function than something like an updating the current node in the struct.
let mut root =
MethodDependency::new(self.get_constructor_js(type_name.clone(), method), type_name.clone());
let mut root = MethodDependency::new(
self.get_constructor_js(type_name.clone(), method),
type_name.clone(),
);

// And then we just treat the terminus as a regular constructor method:
self.terminus_info.node_call_stack = self.evaluate_constructor(method, &mut root);
Expand Down Expand Up @@ -193,7 +195,12 @@ impl<'ctx, 'tcx> RenderTerminusContext<'ctx, 'tcx> {
let attrs_default = attrs.unwrap_or_default();
// This only works for enums, since otherwise we break the type into its component parts.
let label = if attrs_default.input_cfg.label.is_empty() {
format!("{}:{}", heck::AsUpperCamelCase(node.owning_type.clone()), heck::AsUpperCamelCase(param_name.clone())).to_string()
format!(
"{}:{}",
heck::AsUpperCamelCase(node.owning_type.clone()),
heck::AsUpperCamelCase(param_name.clone())
)
.to_string()
} else {
attrs_default.input_cfg.label
};
Expand Down Expand Up @@ -371,8 +378,10 @@ impl<'ctx, 'tcx> RenderTerminusContext<'ctx, 'tcx> {
self.relative_import_path.clone(),
));

let mut child =
MethodDependency::new(self.get_constructor_js(type_name.to_string(), method), type_name);
let mut child = MethodDependency::new(
self.get_constructor_js(type_name.to_string(), method),
type_name,
);

let call = self.evaluate_constructor(method, &mut child);
node.params.push(ParamInfo { js: call });
Expand Down

0 comments on commit 0366be1

Please sign in to comment.