pub struct AdmittedProgram<'p, 'a> { /* private fields */ }Expand description
A short immutable borrow minted only by a clean original observation.
The owner borrow cannot be replaced with an arbitrary Program:
use oxc_parser::{AdmittedProgram, ProgramObservation};
fn forge<'p, 'a>(observation: &'p ProgramObservation<'a>) -> AdmittedProgram<'p, 'a> {
AdmittedProgram { observation }
}A live capability exposes only shared syntax:
use oxc_ast::ast::Program;
use oxc_parser::AdmittedProgram;
fn mutate<'p, 'a>(admitted: &'p AdmittedProgram<'p, 'a>) -> &'p mut Program<'a> {
admitted.program()
}Implementations§
Source§impl<'p, 'a> AdmittedProgram<'p, 'a>
impl<'p, 'a> AdmittedProgram<'p, 'a>
Sourcepub fn sole_default_export(&self) -> Option<OriginalDefaultExport<'p, 'a>>
pub fn sole_default_export(&self) -> Option<OriginalDefaultExport<'p, 'a>>
Project one existing original local Default entry in constant time. Syntax admission remains separate from the entry’s semantic consumers.
Source§impl<'p, 'a> AdmittedProgram<'p, 'a>
impl<'p, 'a> AdmittedProgram<'p, 'a>
pub fn program(&self) -> &'p Program<'a>
Sourcepub fn has_legacy_literals(&self) -> bool
pub fn has_legacy_literals(&self) -> bool
Whether the original lexer decoded a legacy numeric literal or string escape forbidden in a strict module. This does not certify semantics. Syntax diagnostics and ordinary parser output remain unchanged.
Examples found in repository?
41fn packets(source: &str) {
42 for source_type in [
43 SourceType::ts(),
44 SourceType::tsx(),
45 SourceType::jsx(),
46 SourceType::ts().with_script(true),
47 SourceType::ts().with_unambiguous(true),
48 ] {
49 for tokens in [false, true] {
50 for parse_regular_expression in [false, true] {
51 let options = ParseOptions { parse_regular_expression, ..ParseOptions::default() };
52 let allocator = Allocator::default();
53 let result = Parser::new(&allocator, source, source_type)
54 .with_config(RuntimeParserConfig::new(tokens))
55 .with_options(options)
56 .parse();
57 println!(
58 "program {source_type:?} tokens={tokens} regexp={parse_regular_expression}: {:?}\n{:?}\n{:?}\n{:?}\n{:?}\n{:?}",
59 result.program,
60 result.diagnostics,
61 result.tokens,
62 result.module_record,
63 result.irregular_whitespaces,
64 (result.panicked, result.is_flow_language),
65 );
66 let allocator = Allocator::default();
67 let observation = Parser::new(&allocator, source, source_type)
68 .with_config(RuntimeParserConfig::new(tokens))
69 .with_options(options)
70 .parse_observed();
71 let facts = observation.admitted().map(|admitted| {
72 (admitted.has_legacy_literals(), admitted.has_jsdoc_comments())
73 });
74 println!("original admitted source facts: {facts:?}");
75 let allocator = Allocator::default();
76 let result = Parser::new(&allocator, source, source_type)
77 .with_config(RuntimeParserConfig::new(tokens))
78 .with_options(options)
79 .parse_expression();
80 println!(
81 "expression {source_type:?} tokens={tokens} regexp={parse_regular_expression}: {result:?}"
82 );
83 }
84 }
85 }
86}Sourcepub fn has_jsdoc_comments(&self) -> bool
pub fn has_jsdoc_comments(&self) -> bool
Whether the original trivia classifier observed JSDoc or legal JSDoc. This is presence only; it grants no effective type or binding semantics. Checkpoints restore speculation, while committed reparses retain the fact.
Examples found in repository?
41fn packets(source: &str) {
42 for source_type in [
43 SourceType::ts(),
44 SourceType::tsx(),
45 SourceType::jsx(),
46 SourceType::ts().with_script(true),
47 SourceType::ts().with_unambiguous(true),
48 ] {
49 for tokens in [false, true] {
50 for parse_regular_expression in [false, true] {
51 let options = ParseOptions { parse_regular_expression, ..ParseOptions::default() };
52 let allocator = Allocator::default();
53 let result = Parser::new(&allocator, source, source_type)
54 .with_config(RuntimeParserConfig::new(tokens))
55 .with_options(options)
56 .parse();
57 println!(
58 "program {source_type:?} tokens={tokens} regexp={parse_regular_expression}: {:?}\n{:?}\n{:?}\n{:?}\n{:?}\n{:?}",
59 result.program,
60 result.diagnostics,
61 result.tokens,
62 result.module_record,
63 result.irregular_whitespaces,
64 (result.panicked, result.is_flow_language),
65 );
66 let allocator = Allocator::default();
67 let observation = Parser::new(&allocator, source, source_type)
68 .with_config(RuntimeParserConfig::new(tokens))
69 .with_options(options)
70 .parse_observed();
71 let facts = observation.admitted().map(|admitted| {
72 (admitted.has_legacy_literals(), admitted.has_jsdoc_comments())
73 });
74 println!("original admitted source facts: {facts:?}");
75 let allocator = Allocator::default();
76 let result = Parser::new(&allocator, source, source_type)
77 .with_config(RuntimeParserConfig::new(tokens))
78 .with_options(options)
79 .parse_expression();
80 println!(
81 "expression {source_type:?} tokens={tokens} regexp={parse_regular_expression}: {result:?}"
82 );
83 }
84 }
85 }
86}Sourcepub fn source_type(&self) -> SourceType
pub fn source_type(&self) -> SourceType
Original requested profile, before any Unambiguous inference.
Sourcepub fn options(&self) -> ParseOptions
pub fn options(&self) -> ParseOptions
Actual parser options; admission does not imply default compiler options.
Auto Trait Implementations§
impl<'p, 'a> !RefUnwindSafe for AdmittedProgram<'p, 'a>
impl<'p, 'a> !Send for AdmittedProgram<'p, 'a>
impl<'p, 'a> !Sync for AdmittedProgram<'p, 'a>
impl<'p, 'a> !UnwindSafe for AdmittedProgram<'p, 'a>
impl<'p, 'a> Freeze for AdmittedProgram<'p, 'a>
impl<'p, 'a> Unpin for AdmittedProgram<'p, 'a>
impl<'p, 'a> UnsafeUnpin for AdmittedProgram<'p, '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
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more