pub struct TsProgram {
pub stmts: Vec<TsStmt>,
}Expand description
A whole generated TypeScript module, as an ordered sequence of top-level
statements. Vec<TsStmt>, plain — no richer container yet (P7.6’s own
Artefacts { docs: BTreeMap<PathBuf, Document> } is where a project’s
documents get keyed; this is one document’s own tree).
Fields§
§stmts: Vec<TsStmt>Implementations§
Source§impl TsProgram
impl TsProgram
pub fn new() -> Self
pub fn push(&mut self, stmt: TsStmt)
Sourcepub fn verbatim_content(&self) -> Vec<(VerbatimOrigin, &str)>
pub fn verbatim_content(&self) -> Vec<(VerbatimOrigin, &str)>
Every TsStmtKind::Verbatim/TsExpr::VerbatimExpr leaf’s own
text, tagged by its VerbatimOrigin — found by walking every
statement/expression container in the tree, not just the top level.
#1538’s own real gap: nothing before this walked a whole TsProgram
to find every opaque leaf nested inside real structured content (a
Verbatim inside an if branch, a VerbatimExpr inside a Call’s
arguments, …) — the only prior way to inspect a Verbatim’s content
was scanning the whole printed document text
(crate::verbatim_violations doesn’t distinguish opaque text from
a real node’s own printed output), which also flags real, structured
nodes that happen to print the substring any (TsType::named("any")
residue, tracked separately by xtask’s own ts_any probe) — a
false positive for this check, whose whole point is the opaque
escape hatch specifically. TsStmtKind is pub(crate), so only code
inside this crate can walk it directly; this method is the public
surface a caller outside bynk-ts (bynkc’s own
tests/tsc_verify.rs) uses instead.
Every container is walked exhaustively (match, no wildcard arm) so
a future TsStmt/TsExpr variant fails to compile here until this
walker accounts for it — the same “compile-time construct, not a
grep” discipline VerbatimOrigin’s own doc already states for
itself. TsStmtKind::Raw is deliberately not walked into any
deeper than skipped: it carries no VerbatimOrigin at all (ADR
arc-c-lower-rs-permanent-exclusion’s own permanent exclusion, a
different bucket from Verbatim’s temporary conversion residue), so
it has nothing this method could report. TsType positions are
never walked — no TsType variant can hold a Verbatim/
VerbatimExpr leaf, so there is nothing to find there.
A real gap this walker exposed (#1538): no VerbatimOrigin::Emit
leaf can currently reach a TsProgram returned from bynk-emit at
all. Every real bynk-emit/src/emitter/emit.rs construction site
builds a TsExpr::VerbatimExpr, immediately prints it
(crate::print_expr/crate::print_stmt), and splices the resulting
text into a plain String a caller further up wraps in
TsStmtKind::Raw — not tagged with a VerbatimOrigin at all, and
so invisible to this walker by design (see TsStmtKind::Raw’s own
doc). VerbatimExpr’s own doc promises this content is “visible to
crate::verbatim_violations”; today that’s only true at the instant
of construction, not once the surrounding document is returned —
closing it needs a real Arc C conversion slice, not a change here.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TsProgram
impl RefUnwindSafe for TsProgram
impl Send for TsProgram
impl Sync for TsProgram
impl Unpin for TsProgram
impl UnsafeUnpin for TsProgram
impl UnwindSafe for TsProgram
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);