Rename parse_macro to parse_macro_expansion

This does not parse macros, it expands a macro and parses the *result*
This commit is contained in:
Jonas Schievink 2020-11-24 21:57:51 +01:00
parent f9d0d51101
commit 9559bce311
6 changed files with 9 additions and 9 deletions

View file

@ -11,7 +11,7 @@ pub use hir_def::db::{
}; };
pub use hir_expand::db::{ pub use hir_expand::db::{
AstDatabase, AstDatabaseStorage, AstIdMapQuery, InternEagerExpansionQuery, InternMacroQuery, AstDatabase, AstDatabaseStorage, AstIdMapQuery, InternEagerExpansionQuery, InternMacroQuery,
MacroArgTextQuery, MacroDefQuery, MacroExpandQuery, ParseMacroQuery, MacroArgTextQuery, MacroDefQuery, MacroExpandQuery, ParseMacroExpansionQuery,
}; };
pub use hir_ty::db::*; pub use hir_ty::db::*;

View file

@ -88,7 +88,7 @@ pub trait AstDatabase: SourceDatabase {
#[salsa::transparent] #[salsa::transparent]
fn macro_arg(&self, id: MacroCallId) -> Option<Arc<(tt::Subtree, mbe::TokenMap)>>; fn macro_arg(&self, id: MacroCallId) -> Option<Arc<(tt::Subtree, mbe::TokenMap)>>;
fn macro_def(&self, id: MacroDefId) -> Option<Arc<(TokenExpander, mbe::TokenMap)>>; fn macro_def(&self, id: MacroDefId) -> Option<Arc<(TokenExpander, mbe::TokenMap)>>;
fn parse_macro( fn parse_macro_expansion(
&self, &self,
macro_file: MacroFile, macro_file: MacroFile,
) -> MacroResult<(Parse<SyntaxNode>, Arc<mbe::TokenMap>)>; ) -> MacroResult<(Parse<SyntaxNode>, Arc<mbe::TokenMap>)>;
@ -283,12 +283,12 @@ fn parse_or_expand(db: &dyn AstDatabase, file_id: HirFileId) -> Option<SyntaxNod
match file_id.0 { match file_id.0 {
HirFileIdRepr::FileId(file_id) => Some(db.parse(file_id).tree().syntax().clone()), HirFileIdRepr::FileId(file_id) => Some(db.parse(file_id).tree().syntax().clone()),
HirFileIdRepr::MacroFile(macro_file) => { HirFileIdRepr::MacroFile(macro_file) => {
db.parse_macro(macro_file).map(|(it, _)| it.syntax_node()).value db.parse_macro_expansion(macro_file).map(|(it, _)| it.syntax_node()).value
} }
} }
} }
fn parse_macro( fn parse_macro_expansion(
db: &dyn AstDatabase, db: &dyn AstDatabase,
macro_file: MacroFile, macro_file: MacroFile,
) -> MacroResult<(Parse<SyntaxNode>, Arc<mbe::TokenMap>)> { ) -> MacroResult<(Parse<SyntaxNode>, Arc<mbe::TokenMap>)> {

View file

@ -144,7 +144,7 @@ impl HirFileId {
let def_tt = loc.def.ast_id?.to_node(db).token_tree()?; let def_tt = loc.def.ast_id?.to_node(db).token_tree()?;
let macro_def = db.macro_def(loc.def)?; let macro_def = db.macro_def(loc.def)?;
let (parse, exp_map) = db.parse_macro(macro_file).value?; let (parse, exp_map) = db.parse_macro_expansion(macro_file).value?;
let macro_arg = db.macro_arg(macro_file.macro_call_id)?; let macro_arg = db.macro_arg(macro_file.macro_call_id)?;
Some(ExpansionInfo { Some(ExpansionInfo {

View file

@ -19,7 +19,7 @@ fn syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats {
ide_db::base_db::ParseQuery.in_db(db).entries::<SyntaxTreeStats>() ide_db::base_db::ParseQuery.in_db(db).entries::<SyntaxTreeStats>()
} }
fn macro_syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats { fn macro_syntax_tree_stats(db: &RootDatabase) -> SyntaxTreeStats {
hir::db::ParseMacroQuery.in_db(db).entries::<SyntaxTreeStats>() hir::db::ParseMacroExpansionQuery.in_db(db).entries::<SyntaxTreeStats>()
} }
// Feature: Status // Feature: Status

View file

@ -76,7 +76,7 @@ impl RootDatabase {
let sweep = SweepStrategy::default().discard_values().sweep_all_revisions(); let sweep = SweepStrategy::default().discard_values().sweep_all_revisions();
base_db::ParseQuery.in_db(self).sweep(sweep); base_db::ParseQuery.in_db(self).sweep(sweep);
hir::db::ParseMacroQuery.in_db(self).sweep(sweep); hir::db::ParseMacroExpansionQuery.in_db(self).sweep(sweep);
// Macros do take significant space, but less then the syntax trees // Macros do take significant space, but less then the syntax trees
// self.query(hir::db::MacroDefQuery).sweep(sweep); // self.query(hir::db::MacroDefQuery).sweep(sweep);
@ -143,7 +143,7 @@ impl RootDatabase {
hir::db::AstIdMapQuery hir::db::AstIdMapQuery
hir::db::MacroArgTextQuery hir::db::MacroArgTextQuery
hir::db::MacroDefQuery hir::db::MacroDefQuery
hir::db::ParseMacroQuery hir::db::ParseMacroExpansionQuery
hir::db::MacroExpandQuery hir::db::MacroExpandQuery
// DefDatabase // DefDatabase

View file

@ -113,7 +113,7 @@ impl RootDatabase {
pub fn update_lru_capacity(&mut self, lru_capacity: Option<usize>) { pub fn update_lru_capacity(&mut self, lru_capacity: Option<usize>) {
let lru_capacity = lru_capacity.unwrap_or(base_db::DEFAULT_LRU_CAP); let lru_capacity = lru_capacity.unwrap_or(base_db::DEFAULT_LRU_CAP);
base_db::ParseQuery.in_db_mut(self).set_lru_capacity(lru_capacity); base_db::ParseQuery.in_db_mut(self).set_lru_capacity(lru_capacity);
hir::db::ParseMacroQuery.in_db_mut(self).set_lru_capacity(lru_capacity); hir::db::ParseMacroExpansionQuery.in_db_mut(self).set_lru_capacity(lru_capacity);
hir::db::MacroExpandQuery.in_db_mut(self).set_lru_capacity(lru_capacity); hir::db::MacroExpandQuery.in_db_mut(self).set_lru_capacity(lru_capacity);
} }
} }