mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-11 04:38:49 +00:00
Rollup merge of #111571 - jhpratt:proc-macro-span, r=m-ou-se
Implement proposed API for `proc_macro_span` As proposed in [#54725 (comment)](https://github.com/rust-lang/rust/issues/54725#issuecomment-1546918161). I have omitted the byte-level API as it's already available as [`Span::byte_range`](https://doc.rust-lang.org/nightly/proc_macro/struct.Span.html#method.byte_range). `@rustbot` label +A-proc-macros r? `@m-ou-se`
This commit is contained in:
commit
c770e4154d
2 changed files with 15 additions and 16 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1304,9 +1304,9 @@ version = "0.0.0"
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.56"
|
||||
version = "1.0.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435"
|
||||
checksum = "dec2b086b7a862cf4de201096214fa870344cf922b2b30c167badb3af3195406"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
|
|
@ -8,10 +8,7 @@
|
|||
//!
|
||||
//! FIXME: No span and source file information is implemented yet
|
||||
|
||||
use proc_macro::{
|
||||
bridge::{self, server},
|
||||
LineColumn,
|
||||
};
|
||||
use proc_macro::bridge::{self, server};
|
||||
|
||||
mod token_stream;
|
||||
pub use token_stream::TokenStream;
|
||||
|
@ -304,14 +301,6 @@ impl server::Span for RustAnalyzer {
|
|||
// FIXME handle span
|
||||
Range { start: 0, end: 0 }
|
||||
}
|
||||
fn start(&mut self, _span: Self::Span) -> LineColumn {
|
||||
// FIXME handle span
|
||||
LineColumn { line: 0, column: 0 }
|
||||
}
|
||||
fn end(&mut self, _span: Self::Span) -> LineColumn {
|
||||
// FIXME handle span
|
||||
LineColumn { line: 0, column: 0 }
|
||||
}
|
||||
fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
|
||||
// Just return the first span again, because some macros will unwrap the result.
|
||||
Some(first)
|
||||
|
@ -330,13 +319,23 @@ impl server::Span for RustAnalyzer {
|
|||
tt::TokenId::unspecified()
|
||||
}
|
||||
|
||||
fn after(&mut self, _self_: Self::Span) -> Self::Span {
|
||||
fn end(&mut self, _self_: Self::Span) -> Self::Span {
|
||||
tt::TokenId::unspecified()
|
||||
}
|
||||
|
||||
fn before(&mut self, _self_: Self::Span) -> Self::Span {
|
||||
fn start(&mut self, _self_: Self::Span) -> Self::Span {
|
||||
tt::TokenId::unspecified()
|
||||
}
|
||||
|
||||
fn line(&mut self, _span: Self::Span) -> usize {
|
||||
// FIXME handle line
|
||||
0
|
||||
}
|
||||
|
||||
fn column(&mut self, _span: Self::Span) -> usize {
|
||||
// FIXME handle column
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
impl server::Symbol for RustAnalyzer {
|
||||
|
|
Loading…
Reference in a new issue