mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Handle raw identifiers in proc macro server
This commit is contained in:
parent
04a2ac2de2
commit
de591f08d6
5 changed files with 27 additions and 12 deletions
|
@ -86,10 +86,20 @@ pub enum Spacing {
|
|||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Ident {
|
||||
/// Identifier or keyword. Unlike rustc, we keep "r#" prefix when it represents a raw identifier.
|
||||
pub text: SmolStr,
|
||||
pub id: TokenId,
|
||||
}
|
||||
|
||||
impl Ident {
|
||||
/// Constructor intended to be used only by proc macro server. `text` should not contain raw
|
||||
/// identifier prefix.
|
||||
pub fn new_with_is_raw(text: SmolStr, id: TokenId, is_raw: bool) -> Self {
|
||||
let text = if is_raw { SmolStr::from_iter(["r#", &text]) } else { text };
|
||||
Ident { text, id }
|
||||
}
|
||||
}
|
||||
|
||||
impl Leaf {
|
||||
pub fn id(&self) -> TokenId {
|
||||
match self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue