mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Split float literal tokens at the .
This commit is contained in:
parent
502c519e7d
commit
1bc3305d95
23 changed files with 157 additions and 72 deletions
|
@ -1090,9 +1090,10 @@ pub struct FloatLiteral {
|
|||
pub(crate) syntax: SyntaxNode,
|
||||
}
|
||||
impl FloatLiteral {
|
||||
pub fn float_number_token(&self) -> Option<SyntaxToken> {
|
||||
support::token(&self.syntax, T![float_number])
|
||||
pub fn float_number_part_token(&self) -> Option<SyntaxToken> {
|
||||
support::token(&self.syntax, T![float_number_part])
|
||||
}
|
||||
pub fn dot_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![.]) }
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -112,16 +112,16 @@ impl AstToken for IntNumber {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct FloatNumber {
|
||||
pub struct FloatNumberPart {
|
||||
pub(crate) syntax: SyntaxToken,
|
||||
}
|
||||
impl std::fmt::Display for FloatNumber {
|
||||
impl std::fmt::Display for FloatNumberPart {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
std::fmt::Display::fmt(&self.syntax, f)
|
||||
}
|
||||
}
|
||||
impl AstToken for FloatNumber {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == FLOAT_NUMBER }
|
||||
impl AstToken for FloatNumberPart {
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == FLOAT_NUMBER_PART }
|
||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) {
|
||||
Some(Self { syntax })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue