feat(common): list formatting

This commit is contained in:
PoiScript 2023-12-21 04:47:49 +08:00
parent 2e9de16e90
commit de4ff9aa61
No known key found for this signature in database
GPG key ID: 22C2B1249D99985E
6 changed files with 337 additions and 133 deletions

View file

@ -76,6 +76,22 @@ pub fn filter_token(
#[derive(Default, Eq)]
pub struct Token(pub(crate) Option<SyntaxToken>);
impl Token {
pub fn start(&self) -> u32 {
match &self.0 {
Some(t) => t.text_range().start().into(),
None => 0,
}
}
pub fn end(&self) -> u32 {
match &self.0 {
Some(t) => t.text_range().end().into(),
None => 0,
}
}
}
impl AsRef<str> for Token {
fn as_ref(&self) -> &str {
match &self.0 {