pub struct ParsedFile { /* private fields */ }Expand description
A parsed .bynk file: its source, AST, and the two path forms it needs.
Slice 0: source_path and identity_path are different things, and
conflating them is what made a two-root project’s file identity ambiguous.
They coincide for a single-root project, which is why one field sufficed
until include could hold two entries.
P4.0 (#1113, [DECISION B]): fields are crate-private now that ParsedFile
lives in bynk-project — bynk-emit’s symbols/validate read them
through the accessors below instead of the direct field pokes a
same-crate pub(crate) allowed before the move.
Implementations§
Source§impl ParsedFile
impl ParsedFile
Sourcepub fn synthetic(
identity_path: PathBuf,
source_path: PathBuf,
source: String,
unit: SourceUnit,
kind: UnitKind,
) -> Self
pub fn synthetic( identity_path: PathBuf, source_path: PathBuf, source: String, unit: SourceUnit, kind: UnitKind, ) -> Self
Construct directly — used by bynk-emit’s first-party synthetic-unit
injection (firstparty_parsed), which builds a ParsedFile for a
toolchain-supplied source (bynk.bynk, bynk.cloudflare, …) that
never went through parse_sources’s discovery-driven path.
Sourcepub fn new(
source_path: PathBuf,
identity_path: PathBuf,
abs_path: Option<PathBuf>,
source: String,
unit: SourceUnit,
kind: UnitKind,
synthetic: bool,
) -> Self
pub fn new( source_path: PathBuf, identity_path: PathBuf, abs_path: Option<PathBuf>, source: String, unit: SourceUnit, kind: UnitKind, synthetic: bool, ) -> Self
General constructor — bynk-emit’s own tests use this to build a
hand-rolled ParsedFile fixture (a specific source_path/
identity_path pair, a non-synthetic unit) that neither
Self::synthetic (forces source_path == identity_path,
synthetic: true) nor parse_sources (needs a real token stream)
fits.
Sourcepub fn source_path(&self) -> PathBuf
pub fn source_path(&self) -> PathBuf
The path relative to the include root that contains this file.
Sourcepub fn identity_path(&self) -> PathBuf
pub fn identity_path(&self) -> PathBuf
The path relative to the project root — this file’s identity,
unique across include roots. See the field’s own doc for why this
and Self::source_path must not be conflated.
Sourcepub fn abs_path(&self) -> Option<PathBuf>
pub fn abs_path(&self) -> Option<PathBuf>
The absolute path this file was read from, when it has one — None
for toolchain-injected synthetic units.
pub fn kind(&self) -> UnitKind
Sourcepub fn set_kind(&mut self, kind: UnitKind)
pub fn set_kind(&mut self, kind: UnitKind)
Override the discovered kind — bynk-emit’s own tests use this to
build a scenario’s intermediate unit as a commons regardless of what
AST shape (context_using, …) constructed it, without needing a
second builder per kind.
Sourcepub fn is_synthetic(&self) -> bool
pub fn is_synthetic(&self) -> bool
True for toolchain-injected units (the bynk surface).
pub fn unit(&self) -> &SourceUnit
Sourcepub fn unit_mut(&mut self) -> &mut SourceUnit
pub fn unit_mut(&mut self) -> &mut SourceUnit
Mutable access to the parsed unit — bynk-emit’s
normalize_service_defaults (service by/given default injection)
is the one caller that rewrites a unit’s items in place, ahead of
grouping/checking.
Sourcepub fn map_source_name(&self) -> String
pub fn map_source_name(&self) -> String
v0.72: the source-map sources entry for this file — the absolute path
the compiler read it from (forward slashes), so an editor breakpoint set
on the real .bynk resolves to the same path the debugger loads. A
project-relative name would resolve against the emitted .ts’s directory,
which is the wrong place. Synthetic units (no on-disk source) fall back to
their relative path.
pub fn items(&self) -> &Vec<CommonsItem>
pub fn uses(&self) -> &Vec<UsesDecl>
pub fn consumes(&self) -> &[ConsumesDecl]
Sourcepub fn exports(&self) -> &[ExportsDecl]
pub fn exports(&self) -> &[ExportsDecl]
exports clauses, for the unit kinds that have them (contexts and
adapters). Empty for commons/tests.
pub fn adapter(&self) -> Option<&AdapterDecl>
pub fn test(&self) -> Option<&SuiteDecl>
Sourcepub fn integration(&self) -> Option<&SuiteDecl>
pub fn integration(&self) -> Option<&SuiteDecl>
v0.118: a suite whose effective tier is system is emitted through
the wired cross-Worker machinery (the retired standalone integration
path, now re-driven from tiers). Returns the underlying SuiteDecl
when this file is such a suite.
Sourcepub fn as_synthetic_commons(&self, items: Vec<CommonsItem>) -> Commons
pub fn as_synthetic_commons(&self, items: Vec<CommonsItem>) -> Commons
Build a synthetic Commons AST node carrying the given items, so the existing resolver/checker pipeline can be driven uniformly.
Trait Implementations§
Source§impl Clone for ParsedFile
impl Clone for ParsedFile
Source§fn clone(&self) -> ParsedFile
fn clone(&self) -> ParsedFile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ParsedFile
impl RefUnwindSafe for ParsedFile
impl Send for ParsedFile
impl Sync for ParsedFile
impl Unpin for ParsedFile
impl UnsafeUnpin for ParsedFile
impl UnwindSafe for ParsedFile
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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);