Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/proc-macro-srv/src/lib.rs')
| -rw-r--r-- | crates/proc-macro-srv/src/lib.rs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/crates/proc-macro-srv/src/lib.rs b/crates/proc-macro-srv/src/lib.rs index 705ac930ed..ff5623f39e 100644 --- a/crates/proc-macro-srv/src/lib.rs +++ b/crates/proc-macro-srv/src/lib.rs @@ -47,7 +47,7 @@ use std::{ }; use paths::{Utf8Path, Utf8PathBuf}; -use span::{EditionedFileId, Span}; +use span::Span; use temp_dir::TempDir; pub use crate::server_impl::token_id::SpanId; @@ -91,14 +91,10 @@ impl<'env> ProcMacroSrv<'env> { } } -pub type SubCallback = Box<dyn Fn(SubRequest) -> SubResponse + Send + Sync + 'static>; +pub type ProcMacroClientHandle = Box<dyn ProcMacroClientInterface + Send>; -pub enum SubRequest { - SourceText { file_id: EditionedFileId, start: u32, end: u32 }, -} - -pub enum SubResponse { - SourceTextResult { text: Option<String> }, +pub trait ProcMacroClientInterface { + fn source_text(&self, file_id: u32, start: u32, end: u32) -> Option<String>; } const EXPANDER_STACK_SIZE: usize = 8 * 1024 * 1024; @@ -115,7 +111,7 @@ impl ProcMacroSrv<'_> { def_site: S, call_site: S, mixed_site: S, - callback: Option<SubCallback>, + callback: Option<ProcMacroClientHandle>, ) -> Result<token_stream::TokenStream<S>, PanicMessage> { let snapped_env = self.env; let expander = self.expander(lib.as_ref()).map_err(|err| PanicMessage { @@ -187,7 +183,7 @@ pub trait ProcMacroSrvSpan: Copy + Send + Sync { call_site: Self, def_site: Self, mixed_site: Self, - callback: Option<SubCallback>, + callback: Option<ProcMacroClientHandle>, ) -> Self::Server; } @@ -198,7 +194,7 @@ impl ProcMacroSrvSpan for SpanId { call_site: Self, def_site: Self, mixed_site: Self, - callback: Option<SubCallback>, + callback: Option<ProcMacroClientHandle>, ) -> Self::Server { Self::Server { call_site, @@ -217,7 +213,7 @@ impl ProcMacroSrvSpan for Span { call_site: Self, def_site: Self, mixed_site: Self, - callback: Option<SubCallback>, + callback: Option<ProcMacroClientHandle>, ) -> Self::Server { Self::Server { call_site, |