mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 13:33:31 +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;
|
mod version;
|
||||||
|
|
||||||
|
use proc_macro::bridge;
|
||||||
use std::{fmt, fs::File, io};
|
use std::{fmt, fs::File, io};
|
||||||
|
|
||||||
use libloading::Library;
|
use libloading::Library;
|
||||||
use memmap2::Mmap;
|
use memmap2::Mmap;
|
||||||
use object::Object;
|
use object::Object;
|
||||||
use paths::{AbsPath, Utf8Path, Utf8PathBuf};
|
use paths::{AbsPath, Utf8Path, Utf8PathBuf};
|
||||||
use proc_macro::bridge;
|
|
||||||
use proc_macro_api::ProcMacroKind;
|
use proc_macro_api::ProcMacroKind;
|
||||||
|
|
||||||
use crate::ProcMacroSrvSpan;
|
use crate::ProcMacroSrvSpan;
|
||||||
|
|
|
@ -26,7 +26,7 @@ extern crate rustc_lexer;
|
||||||
|
|
||||||
mod dylib;
|
mod dylib;
|
||||||
mod proc_macros;
|
mod proc_macros;
|
||||||
mod server;
|
mod server_impl;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::{hash_map::Entry, HashMap},
|
collections::{hash_map::Entry, HashMap},
|
||||||
|
@ -46,36 +46,10 @@ use proc_macro_api::{
|
||||||
};
|
};
|
||||||
use span::Span;
|
use span::Span;
|
||||||
|
|
||||||
use crate::server::TokenStream;
|
use crate::server_impl::TokenStream;
|
||||||
|
|
||||||
pub const RUSTC_VERSION_STRING: &str = env!("RUSTC_VERSION");
|
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)]
|
#[derive(Default)]
|
||||||
pub struct ProcMacroSrv {
|
pub struct ProcMacroSrv {
|
||||||
expanders: HashMap<(Utf8PathBuf, SystemTime), dylib::Expander>,
|
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(
|
fn expand_id(
|
||||||
task: msg::ExpandMacro,
|
task: msg::ExpandMacro,
|
||||||
expander: &dylib::Expander,
|
expander: &dylib::Expander,
|
||||||
|
|
|
@ -49,10 +49,11 @@ impl ProcMacros {
|
||||||
call_site: S,
|
call_site: S,
|
||||||
mixed_site: S,
|
mixed_site: S,
|
||||||
) -> Result<tt::Subtree<S>, crate::PanicMessage> {
|
) -> 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| {
|
let parsed_attributes = attributes
|
||||||
crate::server::TokenStream::with_subtree(attr)
|
.map_or_else(crate::server_impl::TokenStream::new, |attr| {
|
||||||
|
crate::server_impl::TokenStream::with_subtree(attr)
|
||||||
});
|
});
|
||||||
|
|
||||||
for proc_macro in &self.exported_macros {
|
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 span::{Span, FIXUP_ERASED_FILE_AST_ID_MARKER};
|
||||||
use tt::{TextRange, TextSize};
|
use tt::{TextRange, TextSize};
|
||||||
|
|
||||||
use crate::server::{
|
use crate::server_impl::{
|
||||||
delim_to_external, delim_to_internal, literal_with_stringify_parts,
|
delim_to_external, delim_to_internal, literal_with_stringify_parts,
|
||||||
token_stream::TokenStreamBuilder, Symbol, SymbolInternerRef, SYMBOL_INTERNER,
|
token_stream::TokenStreamBuilder, Symbol, SymbolInternerRef, SYMBOL_INTERNER,
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,7 @@ mod tt {
|
||||||
pub type Ident = ::tt::Ident<super::Span>;
|
pub type Ident = ::tt::Ident<super::Span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
type TokenStream = crate::server::TokenStream<Span>;
|
type TokenStream = crate::server_impl::TokenStream<Span>;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct SourceFile;
|
pub struct SourceFile;
|
|
@ -7,7 +7,7 @@ use std::{
|
||||||
|
|
||||||
use proc_macro::bridge::{self, server};
|
use proc_macro::bridge::{self, server};
|
||||||
|
|
||||||
use crate::server::{
|
use crate::server_impl::{
|
||||||
delim_to_external, delim_to_internal, literal_with_stringify_parts,
|
delim_to_external, delim_to_internal, literal_with_stringify_parts,
|
||||||
token_stream::TokenStreamBuilder, Symbol, SymbolInternerRef, SYMBOL_INTERNER,
|
token_stream::TokenStreamBuilder, Symbol, SymbolInternerRef, SYMBOL_INTERNER,
|
||||||
};
|
};
|
||||||
|
@ -31,7 +31,7 @@ type Spacing = tt::Spacing;
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
type Literal = tt::Literal;
|
type Literal = tt::Literal;
|
||||||
type Span = tt::TokenId;
|
type Span = tt::TokenId;
|
||||||
type TokenStream = crate::server::TokenStream<Span>;
|
type TokenStream = crate::server_impl::TokenStream<Span>;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct SourceFile;
|
pub struct SourceFile;
|
|
@ -7,8 +7,8 @@ use tt::TextRange;
|
||||||
|
|
||||||
use crate::{dylib, proc_macro_test_dylib_path, ProcMacroSrv};
|
use crate::{dylib, proc_macro_test_dylib_path, ProcMacroSrv};
|
||||||
|
|
||||||
fn parse_string(call_site: TokenId, src: &str) -> crate::server::TokenStream<TokenId> {
|
fn parse_string(call_site: TokenId, src: &str) -> crate::server_impl::TokenStream<TokenId> {
|
||||||
crate::server::TokenStream::with_subtree(
|
crate::server_impl::TokenStream::with_subtree(
|
||||||
mbe::parse_to_token_tree_static_span(call_site, src).unwrap(),
|
mbe::parse_to_token_tree_static_span(call_site, src).unwrap(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@ fn parse_string_spanned(
|
||||||
anchor: SpanAnchor,
|
anchor: SpanAnchor,
|
||||||
call_site: SyntaxContextId,
|
call_site: SyntaxContextId,
|
||||||
src: &str,
|
src: &str,
|
||||||
) -> crate::server::TokenStream<Span> {
|
) -> crate::server_impl::TokenStream<Span> {
|
||||||
crate::server::TokenStream::with_subtree(
|
crate::server_impl::TokenStream::with_subtree(
|
||||||
mbe::parse_to_token_tree(anchor, call_site, src).unwrap(),
|
mbe::parse_to_token_tree(anchor, call_site, src).unwrap(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue