pub struct ExtraCallerContext<'a> {
pub extra_callers: &'a [ExtraCallerConfig],
pub dictionary_mode_map: &'a BTreeMap<String, String>,
pub import_mode: ImportKind,
pub use_dynamic_helpers: bool,
}Expand description
Everything the optimize transform needs to rewrite an extra-caller call
site, gathered so no adapter-specific decision is taken in optimize.rs.
A build with no extraCallers configured never constructs one — the
optimize transform holds Option<ExtraCallerContext> and skips every branch
guarded by it, so the base intlayer rewrite is untouched by the adapters.
Fields§
§extra_callers: &'a [ExtraCallerConfig]Descriptors injected by the compat packages’ bundler plugins.
dictionary_mode_map: &'a BTreeMap<String, String>Per-dictionary import mode overrides.
import_mode: ImportKindThe file’s global import mode.
use_dynamic_helpers: boolFile-level dynamic decision: one import specifier serves every call, so a global dynamic/fetch mode or any per-dictionary override flips all rewritten compat calls to the dynamic helper.
Implementations§
Source§impl<'a> ExtraCallerContext<'a>
impl<'a> ExtraCallerContext<'a>
Sourcepub fn import_kind(&self, dictionary_key: &str) -> ImportKind
pub fn import_kind(&self, dictionary_key: &str) -> ImportKind
Import kind an extra-caller call site resolves to for dictionary_key.
Sourcepub fn rewrite_call(
&self,
call: &mut CallExpr,
extra_index: usize,
imports: &mut InjectedImports,
)
pub fn rewrite_call( &self, call: &mut CallExpr, extra_index: usize, imports: &mut InjectedImports, )
Rewrites an extra-caller call site: the namespace is replaced by (or prefixed with) a pre-imported dictionary, plus the dictionary key and nested key prefix the helper needs.
Sourcepub fn owns_import_source(&self, package_specifier: &str) -> bool
pub fn owns_import_source(&self, package_specifier: &str) -> bool
Whether package_specifier exports at least one extra caller, so the
optimize transform knows the import is worth inspecting even though it
is not a native intlayer package.
Sourcepub fn rewrite_import_specifier(
&self,
named: &mut ImportNamedSpecifier,
package_specifier: &str,
caller_map: &CallerMap,
)
pub fn rewrite_import_specifier( &self, named: &mut ImportNamedSpecifier, package_specifier: &str, caller_map: &CallerMap, )
Re-points one import specifier at the dictionary-accepting replacement its descriptor declares, keeping the local alias so call sites read unchanged. Specifiers whose local name is not a registered extra caller — dropped by the pre-pass because a call site was unresolvable — keep their original import.
Auto Trait Implementations§
impl<'a> Freeze for ExtraCallerContext<'a>
impl<'a> RefUnwindSafe for ExtraCallerContext<'a>
impl<'a> Send for ExtraCallerContext<'a>
impl<'a> Sync for ExtraCallerContext<'a>
impl<'a> Unpin for ExtraCallerContext<'a>
impl<'a> UnsafeUnpin for ExtraCallerContext<'a>
impl<'a> UnwindSafe for ExtraCallerContext<'a>
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> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more