mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
internal: Split out a span crate
This commit is contained in:
parent
cfc959d73a
commit
66e29be1bd
50 changed files with 477 additions and 403 deletions
|
@ -11,13 +11,14 @@ use hir_expand::proc_macro::{
|
|||
};
|
||||
use ide::{AnalysisHost, SourceRoot};
|
||||
use ide_db::{
|
||||
base_db::{span::SpanData, CrateGraph, Env},
|
||||
base_db::{CrateGraph, Env},
|
||||
fixture::Change,
|
||||
FxHashMap,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use proc_macro_api::{MacroDylib, ProcMacroServer};
|
||||
use project_model::{CargoConfig, PackageRoot, ProjectManifest, ProjectWorkspace};
|
||||
use span::Span;
|
||||
use tt::DelimSpan;
|
||||
use vfs::{file_set::FileSetConfig, loader::Handle, AbsPath, AbsPathBuf, VfsPath};
|
||||
|
||||
|
@ -376,13 +377,13 @@ struct Expander(proc_macro_api::ProcMacro);
|
|||
impl ProcMacroExpander for Expander {
|
||||
fn expand(
|
||||
&self,
|
||||
subtree: &tt::Subtree<SpanData>,
|
||||
attrs: Option<&tt::Subtree<SpanData>>,
|
||||
subtree: &tt::Subtree<Span>,
|
||||
attrs: Option<&tt::Subtree<Span>>,
|
||||
env: &Env,
|
||||
def_site: SpanData,
|
||||
call_site: SpanData,
|
||||
mixed_site: SpanData,
|
||||
) -> Result<tt::Subtree<SpanData>, ProcMacroExpansionError> {
|
||||
def_site: Span,
|
||||
call_site: Span,
|
||||
mixed_site: Span,
|
||||
) -> Result<tt::Subtree<Span>, ProcMacroExpansionError> {
|
||||
let env = env.iter().map(|(k, v)| (k.to_string(), v.to_string())).collect();
|
||||
match self.0.expand(subtree, attrs, env, def_site, call_site, mixed_site) {
|
||||
Ok(Ok(subtree)) => Ok(subtree),
|
||||
|
@ -399,13 +400,13 @@ struct IdentityExpander;
|
|||
impl ProcMacroExpander for IdentityExpander {
|
||||
fn expand(
|
||||
&self,
|
||||
subtree: &tt::Subtree<SpanData>,
|
||||
_: Option<&tt::Subtree<SpanData>>,
|
||||
subtree: &tt::Subtree<Span>,
|
||||
_: Option<&tt::Subtree<Span>>,
|
||||
_: &Env,
|
||||
_: SpanData,
|
||||
_: SpanData,
|
||||
_: SpanData,
|
||||
) -> Result<tt::Subtree<SpanData>, ProcMacroExpansionError> {
|
||||
_: Span,
|
||||
_: Span,
|
||||
_: Span,
|
||||
) -> Result<tt::Subtree<Span>, ProcMacroExpansionError> {
|
||||
Ok(subtree.clone())
|
||||
}
|
||||
}
|
||||
|
@ -417,13 +418,13 @@ struct EmptyExpander;
|
|||
impl ProcMacroExpander for EmptyExpander {
|
||||
fn expand(
|
||||
&self,
|
||||
_: &tt::Subtree<SpanData>,
|
||||
_: Option<&tt::Subtree<SpanData>>,
|
||||
_: &tt::Subtree<Span>,
|
||||
_: Option<&tt::Subtree<Span>>,
|
||||
_: &Env,
|
||||
call_site: SpanData,
|
||||
_: SpanData,
|
||||
_: SpanData,
|
||||
) -> Result<tt::Subtree<SpanData>, ProcMacroExpansionError> {
|
||||
call_site: Span,
|
||||
_: Span,
|
||||
_: Span,
|
||||
) -> Result<tt::Subtree<Span>, ProcMacroExpansionError> {
|
||||
Ok(tt::Subtree::empty(DelimSpan { open: call_site, close: call_site }))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue