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
sourceimpl 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.
sourceimpl ParsedSource
impl ParsedSource
sourcepub fn media_type(&self) -> MediaType
pub fn media_type(&self) -> MediaType
Gets the media type of the module.
sourcepub fn source(&self) -> &SourceTextInfo
pub fn source(&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>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn get_leading_comments(&self) -> Vec<Comment>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
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 diagnostics(&self) -> &Vec<Diagnostic>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn diagnostics(&self) -> &Vec<Diagnostic>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Gets extra non-fatal diagnostics found while parsing.
sourceimpl 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-ecma-ast-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-ecma-ast-view
sourceimpl 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
sourceimpl Clone for ParsedSource
impl Clone for ParsedSource
sourcefn clone(&self) -> ParsedSource
fn clone(&self) -> ParsedSource
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for ParsedSource
impl Send for ParsedSource
impl Sync for ParsedSource
impl Unpin for ParsedSource
impl UnwindSafe for ParsedSource
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more