Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/proc-macro-srv/src/server/rust_analyzer_span.rs')
-rw-r--r--crates/proc-macro-srv/src/server/rust_analyzer_span.rs35
1 files changed, 23 insertions, 12 deletions
diff --git a/crates/proc-macro-srv/src/server/rust_analyzer_span.rs b/crates/proc-macro-srv/src/server/rust_analyzer_span.rs
index 15d260d518..0350bde412 100644
--- a/crates/proc-macro-srv/src/server/rust_analyzer_span.rs
+++ b/crates/proc-macro-srv/src/server/rust_analyzer_span.rs
@@ -15,8 +15,8 @@ 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,
+ delim_to_external, delim_to_internal, literal_with_stringify_parts,
+ token_stream::TokenStreamBuilder, Symbol, SymbolInternerRef, SYMBOL_INTERNER,
};
mod tt {
pub use tt::*;
@@ -180,12 +180,11 @@ impl server::TokenStream for RaSpanServer {
}
bridge::TokenTree::Literal(literal) => {
- let literal = LiteralFormatter(literal);
- let text = literal.with_stringify_parts(self.interner, |parts| {
+ let text = literal_with_stringify_parts(&literal, self.interner, |parts| {
::tt::SmolStr::from_iter(parts.iter().copied())
});
- let literal = tt::Literal { text, span: literal.0.span };
+ let literal = tt::Literal { text, span: literal.span };
let leaf: tt::Leaf = tt::Leaf::from(literal);
let tree = tt::TokenTree::from(leaf);
Self::TokenStream::from_iter(iter::once(tree))
@@ -251,10 +250,17 @@ impl server::TokenStream for RaSpanServer {
.into_iter()
.map(|tree| match tree {
tt::TokenTree::Leaf(tt::Leaf::Ident(ident)) => {
- bridge::TokenTree::Ident(bridge::Ident {
- sym: Symbol::intern(self.interner, ident.text.trim_start_matches("r#")),
- is_raw: ident.text.starts_with("r#"),
- span: ident.span,
+ bridge::TokenTree::Ident(match ident.text.strip_prefix("r#") {
+ Some(text) => bridge::Ident {
+ sym: Symbol::intern(self.interner, text),
+ is_raw: true,
+ span: ident.span,
+ },
+ None => bridge::Ident {
+ sym: Symbol::intern(self.interner, &ident.text),
+ is_raw: false,
+ span: ident.span,
+ },
})
}
tt::TokenTree::Leaf(tt::Leaf::Literal(lit)) => {
@@ -285,11 +291,12 @@ impl server::TokenStream for RaSpanServer {
}
impl server::SourceFile for RaSpanServer {
- // FIXME these are all stubs
fn eq(&mut self, _file1: &Self::SourceFile, _file2: &Self::SourceFile) -> bool {
+ // FIXME
true
}
fn path(&mut self, _file: &Self::SourceFile) -> String {
+ // FIXME
String::new()
}
fn is_real(&mut self, _file: &Self::SourceFile) -> bool {
@@ -306,11 +313,15 @@ impl server::Span for RaSpanServer {
SourceFile {}
}
fn save_span(&mut self, _span: Self::Span) -> usize {
- // FIXME stub, requires builtin quote! implementation
+ // FIXME, quote is incompatible with third-party tools
+ // This is called by the quote proc-macro which is expanded when the proc-macro is compiled
+ // As such, r-a will never observe this
0
}
fn recover_proc_macro_span(&mut self, _id: usize) -> Self::Span {
- // FIXME stub, requires builtin quote! implementation
+ // FIXME, quote is incompatible with third-party tools
+ // This is called by the expansion of quote!, r-a will observe this, but we don't have
+ // access to the spans that were encoded
self.call_site
}
/// Recent feature, not yet in the proc_macro