Turn macro_expand from query to normal function

This commit is contained in:
Lukas Wirth 2023-11-28 16:50:05 +01:00
parent b98597f06d
commit 7a8c4c001b
12 changed files with 15 additions and 36 deletions

View file

@ -146,9 +146,6 @@ pub trait ExpandDatabase: SourceDatabase {
id: AstId<ast::Macro>,
) -> Arc<DeclarativeMacroExpander>;
/// Expand macro call to a token tree.
// This query is LRU cached
fn macro_expand(&self, macro_call: MacroCallId) -> ExpandResult<Arc<tt::Subtree>>;
#[salsa::invoke(crate::builtin_fn_macro::include_arg_to_tt)]
fn include_expand(
&self,
@ -315,7 +312,7 @@ fn parse_macro_expansion(
macro_file: MacroFileId,
) -> ExpandResult<(Parse<SyntaxNode>, Arc<ExpansionSpanMap>)> {
let _p = profile::span("parse_macro_expansion");
let mbe::ValueResult { value: tt, err } = db.macro_expand(macro_file.macro_call_id);
let mbe::ValueResult { value: tt, err } = macro_expand(db, macro_file.macro_call_id);
let expand_to = macro_expand_to(db, macro_file.macro_call_id);

View file

@ -1,3 +1,4 @@
//! Things to wrap other things in file ids.
use std::iter;
use base_db::{

View file

@ -52,7 +52,7 @@ pub(crate) fn fixup_syntax(node: &SyntaxNode) -> SyntaxFixups {
while let Some(event) = preorder.next() {
let syntax::WalkEvent::Enter(node) = event else { continue };
/* TODO
/*
if can_handle_error(&node) && has_error_to_handle(&node) {
// the node contains an error node, we have to completely replace it by something valid
let (original_tree, new_tmap, new_next_id) =
@ -295,7 +295,7 @@ pub(crate) fn reverse_fixups(tt: &mut Subtree, undo_info: &SyntaxFixupUndoInfo)
tt::TokenTree::Leaf(leaf) => leaf.span().ctx != SyntaxContextId::FAKE,
tt::TokenTree::Subtree(st) => st.delimiter.open.ctx != SyntaxContextId::FAKE,
})
// .flat_map(|tt| match tt { TODO
// .flat_map(|tt| match tt {
// tt::TokenTree::Subtree(mut tt) => {
// reverse_fixups(&mut tt, undo_info);
// SmallVec::from_const([tt.into()])

View file

@ -1,3 +1,5 @@
//! Spanmaps allow turning absolute ranges into relative ranges for incrementality purposes as well
//! as associating spans with text ranges in a particular file.
use base_db::{
span::{ErasedFileAstId, SpanAnchor, SpanData, SyntaxContextId, ROOT_ERASED_FILE_AST_ID},
FileId,