Skip to content

Commit 76ea982

Browse files
committed
rename handler's to be context specific
1 parent 91b5c3c commit 76ea982

6 files changed

Lines changed: 18 additions & 18 deletions

File tree

crates/proc-macro-srv-cli/src/main_loop.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@ fn handle_expand_id<W: std::io::Write, C: Codec>(
169169
send_response::<_, C>(stdout, bidirectional::Response::ExpandMacro(res))
170170
}
171171

172-
struct BidirectionalProxy {
172+
struct ProcMacroClientHandle {
173173
subreq_tx: mpsc::Sender<bidirectional::SubRequest>,
174174
subresp_rx: mpsc::Receiver<bidirectional::SubResponse>,
175175
}
176176

177-
impl proc_macro_srv::BidirectionalHandler for BidirectionalProxy {
177+
impl proc_macro_srv::ProcMacroClientInterface for ProcMacroClientHandle {
178178
fn source_text(&mut self, file_id: u32, start: u32, end: u32) -> Option<String> {
179179
self.subreq_tx.send(bidirectional::SubRequest::SourceText { file_id, start, end }).ok()?;
180180

@@ -228,7 +228,7 @@ fn handle_expand_ra<W: io::Write, R: io::BufRead, C: Codec>(
228228

229229
std::thread::scope(|s| {
230230
s.spawn(|| {
231-
let callback = BidirectionalProxy { subreq_tx, subresp_rx };
231+
let callback = ProcMacroClientHandle { subreq_tx, subresp_rx };
232232

233233
let res = srv
234234
.expand(

crates/proc-macro-srv/src/dylib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use object::Object;
1212
use paths::{Utf8Path, Utf8PathBuf};
1313

1414
use crate::{
15-
PanicMessage, ProcMacroKind, ProcMacroSrvSpan, SubCallback, dylib::proc_macros::ProcMacros,
16-
token_stream::TokenStream,
15+
PanicMessage, ProcMacroClientHandle, ProcMacroKind, ProcMacroSrvSpan,
16+
dylib::proc_macros::ProcMacros, token_stream::TokenStream,
1717
};
1818

1919
pub(crate) struct Expander {
@@ -45,7 +45,7 @@ impl Expander {
4545
def_site: S,
4646
call_site: S,
4747
mixed_site: S,
48-
callback: Option<SubCallback>,
48+
callback: Option<ProcMacroClientHandle>,
4949
) -> Result<TokenStream<S>, PanicMessage>
5050
where
5151
<S::Server as bridge::server::Types>::TokenStream: Default,

crates/proc-macro-srv/src/dylib/proc_macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Proc macro ABI
2-
use crate::{ProcMacroKind, ProcMacroSrvSpan, SubCallback, token_stream::TokenStream};
2+
use crate::{ProcMacroClientHandle, ProcMacroKind, ProcMacroSrvSpan, token_stream::TokenStream};
33
use proc_macro::bridge;
44

55
#[repr(transparent)]
@@ -20,7 +20,7 @@ impl ProcMacros {
2020
def_site: S,
2121
call_site: S,
2222
mixed_site: S,
23-
callback: Option<SubCallback>,
23+
callback: Option<ProcMacroClientHandle>,
2424
) -> Result<TokenStream<S>, crate::PanicMessage> {
2525
let parsed_attributes = attribute.unwrap_or_default();
2626

crates/proc-macro-srv/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ impl<'env> ProcMacroSrv<'env> {
9191
}
9292
}
9393

94-
pub type SubCallback = Box<dyn BidirectionalHandler + Send>;
94+
pub type ProcMacroClientHandle = Box<dyn ProcMacroClientInterface + Send>;
9595

96-
pub trait BidirectionalHandler {
96+
pub trait ProcMacroClientInterface {
9797
fn source_text(&mut self, file_id: u32, start: u32, end: u32) -> Option<String>;
9898
}
9999

@@ -111,7 +111,7 @@ impl ProcMacroSrv<'_> {
111111
def_site: S,
112112
call_site: S,
113113
mixed_site: S,
114-
callback: Option<SubCallback>,
114+
callback: Option<ProcMacroClientHandle>,
115115
) -> Result<token_stream::TokenStream<S>, PanicMessage> {
116116
let snapped_env = self.env;
117117
let expander = self.expander(lib.as_ref()).map_err(|err| PanicMessage {
@@ -183,7 +183,7 @@ pub trait ProcMacroSrvSpan: Copy + Send + Sync {
183183
call_site: Self,
184184
def_site: Self,
185185
mixed_site: Self,
186-
callback: Option<SubCallback>,
186+
callback: Option<ProcMacroClientHandle>,
187187
) -> Self::Server;
188188
}
189189

@@ -194,7 +194,7 @@ impl ProcMacroSrvSpan for SpanId {
194194
call_site: Self,
195195
def_site: Self,
196196
mixed_site: Self,
197-
callback: Option<SubCallback>,
197+
callback: Option<ProcMacroClientHandle>,
198198
) -> Self::Server {
199199
Self::Server {
200200
call_site,
@@ -213,7 +213,7 @@ impl ProcMacroSrvSpan for Span {
213213
call_site: Self,
214214
def_site: Self,
215215
mixed_site: Self,
216-
callback: Option<SubCallback>,
216+
callback: Option<ProcMacroClientHandle>,
217217
) -> Self::Server {
218218
Self::Server {
219219
call_site,

crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use proc_macro::bridge::server;
1414
use span::{FIXUP_ERASED_FILE_AST_ID_MARKER, Span, TextRange, TextSize};
1515

1616
use crate::{
17-
SubCallback,
17+
ProcMacroClientHandle,
1818
bridge::{Diagnostic, ExpnGlobals, Literal, TokenTree},
1919
server_impl::literal_from_str,
2020
};
@@ -29,7 +29,7 @@ pub struct RaSpanServer {
2929
pub call_site: Span,
3030
pub def_site: Span,
3131
pub mixed_site: Span,
32-
pub callback: Option<SubCallback>,
32+
pub callback: Option<ProcMacroClientHandle>,
3333
}
3434

3535
impl server::Types for RaSpanServer {

crates/proc-macro-srv/src/server_impl/token_id.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use intern::Symbol;
99
use proc_macro::bridge::server;
1010

1111
use crate::{
12-
SubCallback,
12+
ProcMacroClientHandle,
1313
bridge::{Diagnostic, ExpnGlobals, Literal, TokenTree},
1414
server_impl::literal_from_str,
1515
};
@@ -35,7 +35,7 @@ pub struct SpanIdServer {
3535
pub call_site: Span,
3636
pub def_site: Span,
3737
pub mixed_site: Span,
38-
pub callback: Option<SubCallback>,
38+
pub callback: Option<ProcMacroClientHandle>,
3939
}
4040

4141
impl server::Types for SpanIdServer {

0 commit comments

Comments
 (0)