dprint_swc_ext::common

Trait SourceRangedForSpanned

Source
pub trait SourceRangedForSpanned {
Show 18 methods // Required methods fn start(&self) -> SourcePos; fn end(&self) -> SourcePos; // Provided methods fn range(&self) -> SourceRange { ... } fn byte_width(&self) -> usize { ... } fn start_line_fast<'a, P: SourceTextInfoProvider<'a>>( &self, source: P, ) -> usize { ... } fn end_line_fast<'a, P: SourceTextInfoProvider<'a>>( &self, source: P, ) -> usize { ... } fn start_column_fast<'a, P: SourceTextInfoProvider<'a>>( &self, source: P, ) -> usize { ... } fn end_column_fast<'a, P: SourceTextInfoProvider<'a>>( &self, source: P, ) -> usize { ... } fn column_at_pos<'a, P: SourceTextInfoProvider<'a>>( &self, source: P, pos: SourcePos, ) -> usize { ... } fn char_width_fast<'a, P: SourceTextProvider<'a>>(&self, source: P) -> usize { ... } fn text_fast<'a, P: SourceTextProvider<'a>>(&self, source: P) -> &'a str { ... } fn tokens_fast<'a>(&self, program: impl RootNode<'a>) -> &'a [TokenAndSpan] { ... } fn leading_comments_fast<'a>( &self, program: impl RootNode<'a>, ) -> CommentsIterator<'a> { ... } fn trailing_comments_fast<'a>( &self, program: impl RootNode<'a>, ) -> CommentsIterator<'a> { ... } fn previous_token_fast<'a>( &self, program: impl RootNode<'a>, ) -> Option<&'a TokenAndSpan> { ... } fn next_token_fast<'a>( &self, program: impl RootNode<'a>, ) -> Option<&'a TokenAndSpan> { ... } fn previous_tokens_fast<'a>( &self, program: impl RootNode<'a>, ) -> &'a [TokenAndSpan] { ... } fn next_tokens_fast<'a>( &self, program: impl RootNode<'a>, ) -> &'a [TokenAndSpan] { ... }
}
Expand description

Adds source position helper methods for swc types that implement swc_common::Spanned.

There were conflicts with implementing SourceRanged for &SourceRanged with swc’s Spanned implementation, so this needed to be a separate trait unfortunately and I couldn’t figure out how to combine it with SourceRanged

Required Methods§

Source

fn start(&self) -> SourcePos

Source

fn end(&self) -> SourcePos

Provided Methods§

Source

fn range(&self) -> SourceRange

Source

fn byte_width(&self) -> usize

Source

fn start_line_fast<'a, P: SourceTextInfoProvider<'a>>(&self, source: P) -> usize

Source

fn end_line_fast<'a, P: SourceTextInfoProvider<'a>>(&self, source: P) -> usize

Source

fn start_column_fast<'a, P: SourceTextInfoProvider<'a>>( &self, source: P, ) -> usize

Source

fn end_column_fast<'a, P: SourceTextInfoProvider<'a>>(&self, source: P) -> usize

Source

fn column_at_pos<'a, P: SourceTextInfoProvider<'a>>( &self, source: P, pos: SourcePos, ) -> usize

Source

fn char_width_fast<'a, P: SourceTextProvider<'a>>(&self, source: P) -> usize

Source

fn text_fast<'a, P: SourceTextProvider<'a>>(&self, source: P) -> &'a str

Source

fn tokens_fast<'a>(&self, program: impl RootNode<'a>) -> &'a [TokenAndSpan]

Source

fn leading_comments_fast<'a>( &self, program: impl RootNode<'a>, ) -> CommentsIterator<'a>

Source

fn trailing_comments_fast<'a>( &self, program: impl RootNode<'a>, ) -> CommentsIterator<'a>

Source

fn previous_token_fast<'a>( &self, program: impl RootNode<'a>, ) -> Option<&'a TokenAndSpan>

Source

fn next_token_fast<'a>( &self, program: impl RootNode<'a>, ) -> Option<&'a TokenAndSpan>

Source

fn previous_tokens_fast<'a>( &self, program: impl RootNode<'a>, ) -> &'a [TokenAndSpan]

Source

fn next_tokens_fast<'a>(&self, program: impl RootNode<'a>) -> &'a [TokenAndSpan]

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§