aboutsummaryrefslogtreecommitdiff
path: root/crates/base_db
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-12-11 13:24:02 +0000
committerJonas Schievink <[email protected]>2020-12-27 14:29:47 +0000
commit798968e1e3a7d9eafa0c27c857571cdc347c34a7 (patch)
tree79e82b07d8486f2d9b710706e5aacc07f25ddbb9 /crates/base_db
parent0fd75c98ac81c9f6581712ec8802940e547315e3 (diff)
Move TokenExpander to base_db and rename it
It's only used to break the dependency to proc_macro_api
Diffstat (limited to 'crates/base_db')
-rw-r--r--crates/base_db/src/input.rs11
-rw-r--r--crates/base_db/src/lib.rs2
2 files changed, 9 insertions, 4 deletions
diff --git a/crates/base_db/src/input.rs b/crates/base_db/src/input.rs
index cda5e57dc..a693e7f80 100644
--- a/crates/base_db/src/input.rs
+++ b/crates/base_db/src/input.rs
@@ -6,12 +6,12 @@
6//! actual IO. See `vfs` and `project_model` in the `rust-analyzer` crate for how 6//! actual IO. See `vfs` and `project_model` in the `rust-analyzer` crate for how
7//! actual IO is done and lowered to input. 7//! actual IO is done and lowered to input.
8 8
9use std::{fmt, iter::FromIterator, ops, str::FromStr, sync::Arc}; 9use std::{fmt, iter::FromIterator, ops, panic::RefUnwindSafe, str::FromStr, sync::Arc};
10 10
11use cfg::CfgOptions; 11use cfg::CfgOptions;
12use rustc_hash::{FxHashMap, FxHashSet}; 12use rustc_hash::{FxHashMap, FxHashSet};
13use syntax::SmolStr; 13use syntax::SmolStr;
14use tt::TokenExpander; 14use tt::{ExpansionError, Subtree};
15use vfs::{file_set::FileSet, FileId, VfsPath}; 15use vfs::{file_set::FileSet, FileId, VfsPath};
16 16
17/// Files are grouped into source roots. A source root is a directory on the 17/// Files are grouped into source roots. A source root is a directory on the
@@ -150,11 +150,16 @@ pub enum ProcMacroKind {
150 Attr, 150 Attr,
151} 151}
152 152
153pub trait ProcMacroExpander: fmt::Debug + Send + Sync + RefUnwindSafe {
154 fn expand(&self, subtree: &Subtree, attrs: Option<&Subtree>)
155 -> Result<Subtree, ExpansionError>;
156}
157
153#[derive(Debug, Clone)] 158#[derive(Debug, Clone)]
154pub struct ProcMacro { 159pub struct ProcMacro {
155 pub name: SmolStr, 160 pub name: SmolStr,
156 pub kind: ProcMacroKind, 161 pub kind: ProcMacroKind,
157 pub expander: Arc<dyn TokenExpander>, 162 pub expander: Arc<dyn ProcMacroExpander>,
158} 163}
159 164
160impl Eq for ProcMacro {} 165impl Eq for ProcMacro {}
diff --git a/crates/base_db/src/lib.rs b/crates/base_db/src/lib.rs
index 595f28ada..5f77a0b1f 100644
--- a/crates/base_db/src/lib.rs
+++ b/crates/base_db/src/lib.rs
@@ -14,7 +14,7 @@ pub use crate::{
14 change::Change, 14 change::Change,
15 input::{ 15 input::{
16 CrateData, CrateDisplayName, CrateGraph, CrateId, CrateName, Dependency, Edition, Env, 16 CrateData, CrateDisplayName, CrateGraph, CrateId, CrateName, Dependency, Edition, Env,
17 ProcMacro, ProcMacroId, ProcMacroKind, SourceRoot, SourceRootId, 17 ProcMacro, ProcMacroExpander, ProcMacroId, ProcMacroKind, SourceRoot, SourceRootId,
18 }, 18 },
19}; 19};
20pub use salsa; 20pub use salsa;