Skip to main content

print_stmt_with_spans

Function print_stmt_with_spans 

Source
pub fn print_stmt_with_spans(
    stmt: &TsStmt,
    depth: usize,
) -> (String, Vec<(usize, Span)>)
Expand description

print_stmt, also reporting where each statement that carries a TsStmt::span starts in the printed text (back-half paydown 1A.11, Decision C of #3712). The offset is a byte offset into the returned text, at the start of the statement’s own line, so before its indentation; an inline if/else branch (no braces, same line as its if) starts after the space that separates it. The statement itself, then every statement nested in it, is reported in the order printed; a statement with no span is not reported.

It is the mechanism S5 of the statement-emitter design note (#3708) moves source-map recording onto, applied one statement at a time: the adapter in bynk-emit adds the indentation it writes before each line and records the adjusted offsets, which is what a nested checkpoint needs.