Skip to main content

print_object_entry

Function print_object_entry 

Source
pub fn print_object_entry(entry: &TsObjectEntry, depth: usize) -> String
Expand description

Print a single TsObjectEntry on its own, at depth — the object-entry sibling of print_stmt’s own “one fragment, not a whole document” entry point, depth meaning the SAME thing it does for this crate’s own internal multi-line-object renderer: the object’s own depth, so the entry itself lands one level deeper, matching an object built by that renderer exactly. #1337’s own real need: emit_attached_methods (a shared helper spliced into emit_refined_type/emit_record_type/ emit_sum_type’s own still-unconverted &mut String buffers) now returns Vec<TsObjectEntry> instead of writing text directly — each caller renders the returned entries one at a time through this, the same P7.9/#1333 “keep the caller’s own signature, print just the fragment” pattern applied to an object-entry-shaped fragment instead of a whole statement or type.

Review of #1338, finding 3: a TsStmtKind::Raw body statement (e.g. emit_method’s own opaque lower.rs-sourced body, or emit_refined_ type’s own opaque emit_refined_checks-sourced guard body, #1339’s second real use) carries NO indent of its own — its text is captured pre-indented at a fixed absolute depth by its own caller — so it only renders correctly when depth is 0. The guard for this now lives in render_multiline_object_entry itself (a private renderer, so named here in text rather than linked — moved there by review of #1340, finding 1: this function’s own copy missed the TsExpr:: multiline_object_entries/render_expr call path #1339 added, which reaches that renderer directly, never through this one), so it fires for every caller, not just this entry point.