Struct deno_ast::ParsedSource
source · pub struct ParsedSource { /* private fields */ }
Expand description
A parsed source containing an AST, comments, and possibly tokens.
Note: This struct is cheap to clone.
Implementations§
source§impl ParsedSource
impl ParsedSource
sourcepub fn analyze_cjs(&self) -> CjsAnalysis
pub fn analyze_cjs(&self) -> CjsAnalysis
Analyzes the script for CommonJS exports and re-exports based on similar functionality to cjs-module-lexer (https://github.com/nodejs/cjs-module-lexer).
Note: This will panic if called on a non-script.
source§impl ParsedSource
impl ParsedSource
sourcepub fn media_type(&self) -> MediaType
pub fn media_type(&self) -> MediaType
Gets the media type of the module.
sourcepub fn text_info(&self) -> &SourceTextInfo
pub fn text_info(&self) -> &SourceTextInfo
Gets the text content of the module.
sourcepub fn program_ref(&self) -> &Program
pub fn program_ref(&self) -> &Program
Gets the parsed program as a reference.
sourcepub fn module(&self) -> &Module
pub fn module(&self) -> &Module
Gets the parsed module.
This will panic if the source is not a module.
sourcepub fn script(&self) -> &Script
pub fn script(&self) -> &Script
Gets the parsed script.
This will panic if the source is not a script.
sourcepub fn comments(&self) -> &MultiThreadedComments
pub fn comments(&self) -> &MultiThreadedComments
Gets the comments found in the source file.
sourcepub fn get_leading_comments(&self) -> Vec<Comment>
pub fn get_leading_comments(&self) -> Vec<Comment>
Get the source’s leading comments, where triple slash directives might be located.
sourcepub fn tokens(&self) -> &[TokenAndSpan]
pub fn tokens(&self) -> &[TokenAndSpan]
Gets the tokens found in the source file.
This will panic if tokens were not captured during parsing.
sourcepub fn top_level_context(&self) -> SyntaxContext
pub fn top_level_context(&self) -> SyntaxContext
Gets the top level context used when parsing with scope analysis.
This will panic if the source was not parsed with scope analysis.
sourcepub fn unresolved_context(&self) -> SyntaxContext
pub fn unresolved_context(&self) -> SyntaxContext
Gets the unresolved context used when parsing with scope analysis.
This will panic if the source was not parsed with scope analysis.
sourcepub fn diagnostics(&self) -> &Vec<Diagnostic>
pub fn diagnostics(&self) -> &Vec<Diagnostic>
Gets extra non-fatal diagnostics found while parsing.
source§impl ParsedSource
impl ParsedSource
sourcepub fn with_view<'a, T>(&self, with_view: impl FnOnce(Program<'a>) -> T) -> T
pub fn with_view<'a, T>(&self, with_view: impl FnOnce(Program<'a>) -> T) -> T
Gets a dprint-swc-ext view of the module.
This provides a closure to examine an “ast view” of the swc AST which has more helper methods and allows for going up the ancestors of a node.
Read more: https://github.com/dprint/dprint-swc-ext
source§impl ParsedSource
impl ParsedSource
sourcepub fn transpile(&self, options: &EmitOptions) -> Result<TranspiledSource>
pub fn transpile(&self, options: &EmitOptions) -> Result<TranspiledSource>
Transform a TypeScript file into a JavaScript file.
Trait Implementations§
source§impl Clone for ParsedSource
impl Clone for ParsedSource
source§fn clone(&self) -> ParsedSource
fn clone(&self) -> ParsedSource
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more