mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 21:13:37 +00:00
Rename proc-macro-srv::server to server_impl
This commit is contained in:
parent
23b043a622
commit
0b88dfc8b1
9 changed files with 42 additions and 41 deletions
|
@ -2,13 +2,13 @@
|
|||
|
||||
mod version;
|
||||
|
||||
use proc_macro::bridge;
|
||||
use std::{fmt, fs::File, io};
|
||||
|
||||
use libloading::Library;
|
||||
use memmap2::Mmap;
|
||||
use object::Object;
|
||||
use paths::{AbsPath, Utf8Path, Utf8PathBuf};
|
||||
use proc_macro::bridge;
|
||||
use proc_macro_api::ProcMacroKind;
|
||||
|
||||
use crate::ProcMacroSrvSpan;
|
||||
|
|
|
@ -26,7 +26,7 @@ extern crate rustc_lexer;
|
|||
|
||||
mod dylib;
|
||||
mod proc_macros;
|
||||
mod server;
|
||||
mod server_impl;
|
||||
|
||||
use std::{
|
||||
collections::{hash_map::Entry, HashMap},
|
||||
|
@ -46,36 +46,10 @@ use proc_macro_api::{
|
|||
};
|
||||
use span::Span;
|
||||
|
||||
use crate::server::TokenStream;
|
||||
use crate::server_impl::TokenStream;
|
||||
|
||||
pub const RUSTC_VERSION_STRING: &str = env!("RUSTC_VERSION");
|
||||
|
||||
trait ProcMacroSrvSpan: Copy {
|
||||
type Server: proc_macro::bridge::server::Server<TokenStream = TokenStream<Self>>;
|
||||
fn make_server(call_site: Self, def_site: Self, mixed_site: Self) -> Self::Server;
|
||||
}
|
||||
|
||||
impl ProcMacroSrvSpan for TokenId {
|
||||
type Server = server::token_id::TokenIdServer;
|
||||
|
||||
fn make_server(call_site: Self, def_site: Self, mixed_site: Self) -> Self::Server {
|
||||
Self::Server { interner: &server::SYMBOL_INTERNER, call_site, def_site, mixed_site }
|
||||
}
|
||||
}
|
||||
impl ProcMacroSrvSpan for Span {
|
||||
type Server = server::rust_analyzer_span::RaSpanServer;
|
||||
fn make_server(call_site: Self, def_site: Self, mixed_site: Self) -> Self::Server {
|
||||
Self::Server {
|
||||
interner: &server::SYMBOL_INTERNER,
|
||||
call_site,
|
||||
def_site,
|
||||
mixed_site,
|
||||
tracked_env_vars: Default::default(),
|
||||
tracked_paths: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ProcMacroSrv {
|
||||
expanders: HashMap<(Utf8PathBuf, SystemTime), dylib::Expander>,
|
||||
|
@ -167,6 +141,32 @@ impl ProcMacroSrv {
|
|||
}
|
||||
}
|
||||
|
||||
trait ProcMacroSrvSpan: Copy {
|
||||
type Server: proc_macro::bridge::server::Server<TokenStream = TokenStream<Self>>;
|
||||
fn make_server(call_site: Self, def_site: Self, mixed_site: Self) -> Self::Server;
|
||||
}
|
||||
|
||||
impl ProcMacroSrvSpan for TokenId {
|
||||
type Server = server_impl::token_id::TokenIdServer;
|
||||
|
||||
fn make_server(call_site: Self, def_site: Self, mixed_site: Self) -> Self::Server {
|
||||
Self::Server { interner: &server_impl::SYMBOL_INTERNER, call_site, def_site, mixed_site }
|
||||
}
|
||||
}
|
||||
impl ProcMacroSrvSpan for Span {
|
||||
type Server = server_impl::rust_analyzer_span::RaSpanServer;
|
||||
fn make_server(call_site: Self, def_site: Self, mixed_site: Self) -> Self::Server {
|
||||
Self::Server {
|
||||
interner: &server_impl::SYMBOL_INTERNER,
|
||||
call_site,
|
||||
def_site,
|
||||
mixed_site,
|
||||
tracked_env_vars: Default::default(),
|
||||
tracked_paths: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn expand_id(
|
||||
task: msg::ExpandMacro,
|
||||
expander: &dylib::Expander,
|
||||
|
|
|
@ -49,10 +49,11 @@ impl ProcMacros {
|
|||
call_site: S,
|
||||
mixed_site: S,
|
||||
) -> Result<tt::Subtree<S>, crate::PanicMessage> {
|
||||
let parsed_body = crate::server::TokenStream::with_subtree(macro_body);
|
||||
let parsed_body = crate::server_impl::TokenStream::with_subtree(macro_body);
|
||||
|
||||
let parsed_attributes = attributes.map_or_else(crate::server::TokenStream::new, |attr| {
|
||||
crate::server::TokenStream::with_subtree(attr)
|
||||
let parsed_attributes = attributes
|
||||
.map_or_else(crate::server_impl::TokenStream::new, |attr| {
|
||||
crate::server_impl::TokenStream::with_subtree(attr)
|
||||
});
|
||||
|
||||
for proc_macro in &self.exported_macros {
|
||||
|
|
|
@ -14,7 +14,7 @@ use proc_macro::bridge::{self, server};
|
|||
use span::{Span, FIXUP_ERASED_FILE_AST_ID_MARKER};
|
||||
use tt::{TextRange, TextSize};
|
||||
|
||||
use crate::server::{
|
||||
use crate::server_impl::{
|
||||
delim_to_external, delim_to_internal, literal_with_stringify_parts,
|
||||
token_stream::TokenStreamBuilder, Symbol, SymbolInternerRef, SYMBOL_INTERNER,
|
||||
};
|
||||
|
@ -29,7 +29,7 @@ mod tt {
|
|||
pub type Ident = ::tt::Ident<super::Span>;
|
||||
}
|
||||
|
||||
type TokenStream = crate::server::TokenStream<Span>;
|
||||
type TokenStream = crate::server_impl::TokenStream<Span>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SourceFile;
|
|
@ -7,7 +7,7 @@ use std::{
|
|||
|
||||
use proc_macro::bridge::{self, server};
|
||||
|
||||
use crate::server::{
|
||||
use crate::server_impl::{
|
||||
delim_to_external, delim_to_internal, literal_with_stringify_parts,
|
||||
token_stream::TokenStreamBuilder, Symbol, SymbolInternerRef, SYMBOL_INTERNER,
|
||||
};
|
||||
|
@ -31,7 +31,7 @@ type Spacing = tt::Spacing;
|
|||
#[allow(unused)]
|
||||
type Literal = tt::Literal;
|
||||
type Span = tt::TokenId;
|
||||
type TokenStream = crate::server::TokenStream<Span>;
|
||||
type TokenStream = crate::server_impl::TokenStream<Span>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SourceFile;
|
|
@ -7,8 +7,8 @@ use tt::TextRange;
|
|||
|
||||
use crate::{dylib, proc_macro_test_dylib_path, ProcMacroSrv};
|
||||
|
||||
fn parse_string(call_site: TokenId, src: &str) -> crate::server::TokenStream<TokenId> {
|
||||
crate::server::TokenStream::with_subtree(
|
||||
fn parse_string(call_site: TokenId, src: &str) -> crate::server_impl::TokenStream<TokenId> {
|
||||
crate::server_impl::TokenStream::with_subtree(
|
||||
mbe::parse_to_token_tree_static_span(call_site, src).unwrap(),
|
||||
)
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ fn parse_string_spanned(
|
|||
anchor: SpanAnchor,
|
||||
call_site: SyntaxContextId,
|
||||
src: &str,
|
||||
) -> crate::server::TokenStream<Span> {
|
||||
crate::server::TokenStream::with_subtree(
|
||||
) -> crate::server_impl::TokenStream<Span> {
|
||||
crate::server_impl::TokenStream::with_subtree(
|
||||
mbe::parse_to_token_tree(anchor, call_site, src).unwrap(),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue