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§
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]
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.