mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Remove deps on tt_mbe
This commit is contained in:
parent
72e68d0caf
commit
db162df264
10 changed files with 58 additions and 49 deletions
|
@ -5,56 +5,29 @@
|
|||
//! is used to provide basic infrastructure for communication between two
|
||||
//! processes: Client (RA itself), Server (the external program)
|
||||
|
||||
use ra_mbe::ExpandError;
|
||||
use ra_tt::Subtree;
|
||||
use ra_tt::{SmolStr, Subtree};
|
||||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
trait ProcMacroExpander: std::fmt::Debug + Send + Sync + std::panic::RefUnwindSafe {
|
||||
fn custom_derive(&self, subtree: &Subtree, derive_name: &str) -> Result<Subtree, ExpandError>;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ProcMacroProcessExpander {
|
||||
process: Arc<ProcMacroProcessSrv>,
|
||||
name: SmolStr,
|
||||
}
|
||||
|
||||
impl ProcMacroExpander for ProcMacroProcessExpander {
|
||||
fn custom_derive(
|
||||
impl ra_tt::TokenExpander for ProcMacroProcessExpander {
|
||||
fn expand(
|
||||
&self,
|
||||
_subtree: &Subtree,
|
||||
_derive_name: &str,
|
||||
) -> Result<Subtree, ExpandError> {
|
||||
_attr: Option<&Subtree>,
|
||||
) -> Result<Subtree, ra_tt::ExpansionError> {
|
||||
// FIXME: do nothing for now
|
||||
Ok(Subtree::default())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ProcMacro {
|
||||
expander: Arc<dyn ProcMacroExpander>,
|
||||
name: String,
|
||||
}
|
||||
|
||||
impl Eq for ProcMacro {}
|
||||
impl PartialEq for ProcMacro {
|
||||
fn eq(&self, other: &ProcMacro) -> bool {
|
||||
self.name == other.name && Arc::ptr_eq(&self.expander, &other.expander)
|
||||
}
|
||||
}
|
||||
|
||||
impl ProcMacro {
|
||||
pub fn name(&self) -> String {
|
||||
self.name.clone()
|
||||
}
|
||||
|
||||
pub fn custom_derive(&self, subtree: &Subtree) -> Result<Subtree, ExpandError> {
|
||||
self.expander.custom_derive(subtree, &self.name)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ProcMacroProcessSrv {
|
||||
path: PathBuf,
|
||||
|
@ -76,7 +49,10 @@ impl ProcMacroClient {
|
|||
ProcMacroClient::Dummy
|
||||
}
|
||||
|
||||
pub fn by_dylib_path(&self, _dylib_path: &Path) -> Vec<ProcMacro> {
|
||||
pub fn by_dylib_path(
|
||||
&self,
|
||||
_dylib_path: &Path,
|
||||
) -> Vec<(SmolStr, Arc<dyn ra_tt::TokenExpander>)> {
|
||||
// FIXME: return empty for now
|
||||
vec![]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue