mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Merge commit '4a8d0f7f56
' into sync-from-ra
This commit is contained in:
parent
e057365301
commit
9e4ecc60a5
96 changed files with 1830 additions and 705 deletions
|
@ -10,16 +10,16 @@ use std::{
|
|||
ops::{Bound, Range},
|
||||
};
|
||||
|
||||
use ::tt::{TextRange, TextSize};
|
||||
use proc_macro::bridge::{self, server};
|
||||
use span::{Span, FIXUP_ERASED_FILE_AST_ID_MARKER};
|
||||
use tt::{TextRange, TextSize};
|
||||
|
||||
use crate::server::{
|
||||
delim_to_external, delim_to_internal, token_stream::TokenStreamBuilder, LiteralFormatter,
|
||||
Symbol, SymbolInternerRef, SYMBOL_INTERNER,
|
||||
};
|
||||
mod tt {
|
||||
pub use ::tt::*;
|
||||
pub use tt::*;
|
||||
|
||||
pub type Subtree = ::tt::Subtree<super::Span>;
|
||||
pub type TokenTree = ::tt::TokenTree<super::Span>;
|
||||
|
@ -97,22 +97,33 @@ impl server::FreeFunctions for RaSpanServer {
|
|||
}
|
||||
|
||||
let TokenKind::Literal { kind, suffix_start } = lit.kind else { return Err(()) };
|
||||
let kind = match kind {
|
||||
LiteralKind::Int { .. } => LitKind::Integer,
|
||||
LiteralKind::Float { .. } => LitKind::Float,
|
||||
LiteralKind::Char { .. } => LitKind::Char,
|
||||
LiteralKind::Byte { .. } => LitKind::Byte,
|
||||
LiteralKind::Str { .. } => LitKind::Str,
|
||||
LiteralKind::ByteStr { .. } => LitKind::ByteStr,
|
||||
LiteralKind::CStr { .. } => LitKind::CStr,
|
||||
LiteralKind::RawStr { n_hashes } => LitKind::StrRaw(n_hashes.unwrap_or_default()),
|
||||
LiteralKind::RawByteStr { n_hashes } => {
|
||||
LitKind::ByteStrRaw(n_hashes.unwrap_or_default())
|
||||
}
|
||||
LiteralKind::RawCStr { n_hashes } => LitKind::CStrRaw(n_hashes.unwrap_or_default()),
|
||||
let (kind, start_offset, end_offset) = match kind {
|
||||
LiteralKind::Int { .. } => (LitKind::Integer, 0, 0),
|
||||
LiteralKind::Float { .. } => (LitKind::Float, 0, 0),
|
||||
LiteralKind::Char { terminated } => (LitKind::Char, 1, terminated as usize),
|
||||
LiteralKind::Byte { terminated } => (LitKind::Byte, 2, terminated as usize),
|
||||
LiteralKind::Str { terminated } => (LitKind::Str, 1, terminated as usize),
|
||||
LiteralKind::ByteStr { terminated } => (LitKind::ByteStr, 2, terminated as usize),
|
||||
LiteralKind::CStr { terminated } => (LitKind::CStr, 2, terminated as usize),
|
||||
LiteralKind::RawStr { n_hashes } => (
|
||||
LitKind::StrRaw(n_hashes.unwrap_or_default()),
|
||||
2 + n_hashes.unwrap_or_default() as usize,
|
||||
1 + n_hashes.unwrap_or_default() as usize,
|
||||
),
|
||||
LiteralKind::RawByteStr { n_hashes } => (
|
||||
LitKind::ByteStrRaw(n_hashes.unwrap_or_default()),
|
||||
3 + n_hashes.unwrap_or_default() as usize,
|
||||
1 + n_hashes.unwrap_or_default() as usize,
|
||||
),
|
||||
LiteralKind::RawCStr { n_hashes } => (
|
||||
LitKind::CStrRaw(n_hashes.unwrap_or_default()),
|
||||
3 + n_hashes.unwrap_or_default() as usize,
|
||||
1 + n_hashes.unwrap_or_default() as usize,
|
||||
),
|
||||
};
|
||||
|
||||
let (lit, suffix) = s.split_at(suffix_start as usize);
|
||||
let lit = &lit[start_offset..lit.len() - end_offset];
|
||||
let suffix = match suffix {
|
||||
"" | "_" => None,
|
||||
suffix => Some(Symbol::intern(self.interner, suffix)),
|
||||
|
@ -248,12 +259,8 @@ impl server::TokenStream for RaSpanServer {
|
|||
}
|
||||
tt::TokenTree::Leaf(tt::Leaf::Literal(lit)) => {
|
||||
bridge::TokenTree::Literal(bridge::Literal {
|
||||
// FIXME: handle literal kinds
|
||||
kind: bridge::LitKind::Integer, // dummy
|
||||
symbol: Symbol::intern(self.interner, &lit.text),
|
||||
// FIXME: handle suffixes
|
||||
suffix: None,
|
||||
span: lit.span,
|
||||
..server::FreeFunctions::literal_from_str(self, &lit.text).unwrap()
|
||||
})
|
||||
}
|
||||
tt::TokenTree::Leaf(tt::Leaf::Punct(punct)) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue