Refactor ide handling for paths in derive inputs

This commit is contained in:
Lukas Wirth 2021-10-28 16:13:37 +02:00
parent f4ba64ee2a
commit 3018ffd85e
15 changed files with 142 additions and 77 deletions

View file

@ -131,3 +131,24 @@ impl AstToken for FloatNumber {
}
fn syntax(&self) -> &SyntaxToken { &self.syntax }
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Ident {
pub(crate) syntax: SyntaxToken,
}
impl std::fmt::Display for Ident {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.syntax, f)
}
}
impl AstToken for Ident {
fn can_cast(kind: SyntaxKind) -> bool { kind == IDENT }
fn cast(syntax: SyntaxToken) -> Option<Self> {
if Self::can_cast(syntax.kind()) {
Some(Self { syntax })
} else {
None
}
}
fn syntax(&self) -> &SyntaxToken { &self.syntax }
}