mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Add rust-analyzer-span server feature equivalent to the ID server
This commit is contained in:
parent
3ce35931db
commit
a892237ed4
17 changed files with 1159 additions and 558 deletions
|
@ -2,9 +2,9 @@
|
|||
|
||||
use libloading::Library;
|
||||
use proc_macro::bridge;
|
||||
use proc_macro_api::{msg::TokenId, ProcMacroKind, RustCInfo};
|
||||
use proc_macro_api::{ProcMacroKind, RustCInfo};
|
||||
|
||||
use crate::{dylib::LoadProcMacroDylibError, server::SYMBOL_INTERNER, tt};
|
||||
use crate::{dylib::LoadProcMacroDylibError, ProcMacroSrvSpan};
|
||||
|
||||
pub(crate) struct ProcMacros {
|
||||
exported_macros: Vec<bridge::client::ProcMacro>,
|
||||
|
@ -40,19 +40,19 @@ impl ProcMacros {
|
|||
Err(LoadProcMacroDylibError::AbiMismatch(info.version_string))
|
||||
}
|
||||
|
||||
pub(crate) fn expand(
|
||||
pub(crate) fn expand<S: ProcMacroSrvSpan>(
|
||||
&self,
|
||||
macro_name: &str,
|
||||
macro_body: &tt::Subtree,
|
||||
attributes: Option<&tt::Subtree>,
|
||||
def_site: TokenId,
|
||||
call_site: TokenId,
|
||||
mixed_site: TokenId,
|
||||
) -> Result<tt::Subtree, crate::PanicMessage> {
|
||||
let parsed_body = crate::server::TokenStream::with_subtree(macro_body.clone());
|
||||
macro_body: tt::Subtree<S>,
|
||||
attributes: Option<tt::Subtree<S>>,
|
||||
def_site: S,
|
||||
call_site: S,
|
||||
mixed_site: S,
|
||||
) -> Result<tt::Subtree<S>, crate::PanicMessage> {
|
||||
let parsed_body = crate::server::TokenStream::with_subtree(macro_body);
|
||||
|
||||
let parsed_attributes = attributes.map_or(crate::server::TokenStream::new(), |attr| {
|
||||
crate::server::TokenStream::with_subtree(attr.clone())
|
||||
let parsed_attributes = attributes.map_or_else(crate::server::TokenStream::new, |attr| {
|
||||
crate::server::TokenStream::with_subtree(attr)
|
||||
});
|
||||
|
||||
for proc_macro in &self.exported_macros {
|
||||
|
@ -62,12 +62,7 @@ impl ProcMacros {
|
|||
{
|
||||
let res = client.run(
|
||||
&bridge::server::SameThread,
|
||||
crate::server::RustAnalyzer {
|
||||
interner: &SYMBOL_INTERNER,
|
||||
call_site,
|
||||
def_site,
|
||||
mixed_site,
|
||||
},
|
||||
S::make_server(call_site, def_site, mixed_site),
|
||||
parsed_body,
|
||||
false,
|
||||
);
|
||||
|
@ -78,12 +73,7 @@ impl ProcMacros {
|
|||
bridge::client::ProcMacro::Bang { name, client } if *name == macro_name => {
|
||||
let res = client.run(
|
||||
&bridge::server::SameThread,
|
||||
crate::server::RustAnalyzer {
|
||||
interner: &SYMBOL_INTERNER,
|
||||
call_site,
|
||||
def_site,
|
||||
mixed_site,
|
||||
},
|
||||
S::make_server(call_site, def_site, mixed_site),
|
||||
parsed_body,
|
||||
false,
|
||||
);
|
||||
|
@ -94,13 +84,7 @@ impl ProcMacros {
|
|||
bridge::client::ProcMacro::Attr { name, client } if *name == macro_name => {
|
||||
let res = client.run(
|
||||
&bridge::server::SameThread,
|
||||
crate::server::RustAnalyzer {
|
||||
interner: &SYMBOL_INTERNER,
|
||||
|
||||
call_site,
|
||||
def_site,
|
||||
mixed_site,
|
||||
},
|
||||
S::make_server(call_site, def_site, mixed_site),
|
||||
parsed_attributes,
|
||||
parsed_body,
|
||||
false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue