Trait hir::db::ExpandDatabase
pub trait ExpandDatabase:
Database
+ HasQueryGroup<ExpandDatabaseStorage>
+ SourceDatabase {
Show 23 methods
// Required methods
fn proc_macros(&self) -> Arc<ProcMacros>;
fn set_proc_macros(&mut self, value__: Arc<ProcMacros>);
fn set_proc_macros_with_durability(
&mut self,
value__: Arc<ProcMacros>,
durability__: Durability,
);
fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>;
fn parse_or_expand(&self, file_id: HirFileId) -> SyntaxNode<RustLanguage>;
fn parse_macro_expansion(
&self,
macro_file: MacroFileId,
) -> ValueResult<(Parse<SyntaxNode<RustLanguage>>, Arc<SpanMap<SyntaxContextId>>), ExpandError>;
fn span_map(&self, file_id: HirFileId) -> SpanMap;
fn expansion_span_map(
&self,
file_id: MacroFileId,
) -> Arc<SpanMap<SyntaxContextId>>;
fn real_span_map(&self, file_id: EditionedFileId) -> Arc<RealSpanMap>;
fn intern_macro_call(&self, macro_call: MacroCallLoc) -> MacroCallId;
fn lookup_intern_macro_call(&self, key: MacroCallId) -> MacroCallLoc;
fn intern_syntax_context(&self, ctx: SyntaxContextData) -> SyntaxContextId;
fn lookup_intern_syntax_context(
&self,
key: SyntaxContextId,
) -> SyntaxContextData;
fn setup_syntax_context_root(&self);
fn dump_syntax_contexts(&self) -> String;
fn macro_arg(
&self,
id: MacroCallId,
) -> (Arc<Subtree<SpanData<SyntaxContextId>>>, SyntaxFixupUndoInfo, SpanData<SyntaxContextId>);
fn macro_arg_considering_derives(
&self,
id: MacroCallId,
kind: &MacroCallKind,
) -> (Arc<Subtree<SpanData<SyntaxContextId>>>, SyntaxFixupUndoInfo, SpanData<SyntaxContextId>);
fn macro_expander(&self, id: MacroDefId) -> TokenExpander;
fn decl_macro_expander(
&self,
def_crate: Idx<CrateData>,
id: InFileWrapper<HirFileId, FileAstId<Macro>>,
) -> Arc<DeclarativeMacroExpander>;
fn expand_proc_macro(
&self,
call: MacroCallId,
) -> ValueResult<Arc<Subtree<SpanData<SyntaxContextId>>>, ExpandError>;
fn proc_macro_span(
&self,
fun: InFileWrapper<HirFileId, FileAstId<Fn>>,
) -> SpanData<SyntaxContextId>;
fn parse_macro_expansion_error(
&self,
macro_call: MacroCallId,
) -> Option<Arc<ValueResult<Arc<[SyntaxError]>, ExpandError>>>;
fn syntax_context(&self, file: HirFileId) -> SyntaxContextId;
}
Required Methods§
fn proc_macros(&self) -> Arc<ProcMacros>
fn proc_macros(&self) -> Arc<ProcMacros>
The proc macros.
fn set_proc_macros(&mut self, value__: Arc<ProcMacros>)
fn set_proc_macros(&mut self, value__: Arc<ProcMacros>)
Set the value of the proc_macros
input.
See proc_macros
for details.
Note: Setting values will trigger cancellation of any ongoing queries; this method blocks until those queries have been cancelled.
fn set_proc_macros_with_durability(
&mut self,
value__: Arc<ProcMacros>,
durability__: Durability,
)
fn set_proc_macros_with_durability( &mut self, value__: Arc<ProcMacros>, durability__: Durability, )
Set the value of the proc_macros
input with a
specific durability instead of the default of
Durability::LOW
. You can use Durability::MAX
to promise that its value will never change again.
See proc_macros
for details.
Note: Setting values will trigger cancellation of any ongoing queries; this method blocks until those queries have been cancelled.
fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>
fn parse_or_expand(&self, file_id: HirFileId) -> SyntaxNode<RustLanguage>
fn parse_or_expand(&self, file_id: HirFileId) -> SyntaxNode<RustLanguage>
Main public API – parses a hir file, not caring whether it’s a real file or a macro expansion.
fn parse_macro_expansion(
&self,
macro_file: MacroFileId,
) -> ValueResult<(Parse<SyntaxNode<RustLanguage>>, Arc<SpanMap<SyntaxContextId>>), ExpandError>
fn parse_macro_expansion( &self, macro_file: MacroFileId, ) -> ValueResult<(Parse<SyntaxNode<RustLanguage>>, Arc<SpanMap<SyntaxContextId>>), ExpandError>
Implementation for the macro case.
fn span_map(&self, file_id: HirFileId) -> SpanMap
fn expansion_span_map( &self, file_id: MacroFileId, ) -> Arc<SpanMap<SyntaxContextId>>
fn real_span_map(&self, file_id: EditionedFileId) -> Arc<RealSpanMap>
fn intern_macro_call(&self, macro_call: MacroCallLoc) -> MacroCallId
fn intern_macro_call(&self, macro_call: MacroCallLoc) -> MacroCallId
Macro ids. That’s probably the tricksiest bit in rust-analyzer, and the reason why we use salsa at all.
We encode macro definitions into ids of macro calls, this what allows us to be incremental.
fn lookup_intern_macro_call(&self, key: MacroCallId) -> MacroCallLoc
fn intern_syntax_context(&self, ctx: SyntaxContextData) -> SyntaxContextId
fn lookup_intern_syntax_context( &self, key: SyntaxContextId, ) -> SyntaxContextData
fn setup_syntax_context_root(&self)
fn dump_syntax_contexts(&self) -> String
fn macro_arg(
&self,
id: MacroCallId,
) -> (Arc<Subtree<SpanData<SyntaxContextId>>>, SyntaxFixupUndoInfo, SpanData<SyntaxContextId>)
👎Deprecated: calling this is incorrect, call macro_arg_considering_derives
instead
fn macro_arg( &self, id: MacroCallId, ) -> (Arc<Subtree<SpanData<SyntaxContextId>>>, SyntaxFixupUndoInfo, SpanData<SyntaxContextId>)
macro_arg_considering_derives
insteadLowers syntactic macro call to a token tree representation. That’s a firewall query, only typing in the macro call itself changes the returned subtree.
fn macro_arg_considering_derives( &self, id: MacroCallId, kind: &MacroCallKind, ) -> (Arc<Subtree<SpanData<SyntaxContextId>>>, SyntaxFixupUndoInfo, SpanData<SyntaxContextId>)
fn macro_expander(&self, id: MacroDefId) -> TokenExpander
fn macro_expander(&self, id: MacroDefId) -> TokenExpander
Fetches the expander for this macro.
fn decl_macro_expander(
&self,
def_crate: Idx<CrateData>,
id: InFileWrapper<HirFileId, FileAstId<Macro>>,
) -> Arc<DeclarativeMacroExpander>
fn decl_macro_expander( &self, def_crate: Idx<CrateData>, id: InFileWrapper<HirFileId, FileAstId<Macro>>, ) -> Arc<DeclarativeMacroExpander>
Fetches (and compiles) the expander of this decl macro.
fn expand_proc_macro(
&self,
call: MacroCallId,
) -> ValueResult<Arc<Subtree<SpanData<SyntaxContextId>>>, ExpandError>
fn expand_proc_macro( &self, call: MacroCallId, ) -> ValueResult<Arc<Subtree<SpanData<SyntaxContextId>>>, ExpandError>
Special case of the previous query for procedural macros. We can’t LRU proc macros, since they are not deterministic in general, and non-determinism breaks salsa in a very, very, very bad way. @edwin0cheng heroically debugged this once! See #4315 for details
fn proc_macro_span(
&self,
fun: InFileWrapper<HirFileId, FileAstId<Fn>>,
) -> SpanData<SyntaxContextId>
fn proc_macro_span( &self, fun: InFileWrapper<HirFileId, FileAstId<Fn>>, ) -> SpanData<SyntaxContextId>
Retrieves the span to be used for a proc-macro expansions spans. This is a firewall query as it requires parsing the file, which we don’t want proc-macros to directly depend on as that would cause to frequent invalidations, mainly because of the parse queries being LRU cached. If they weren’t the invalidations would only happen if the user wrote in the file that defines the proc-macro.
fn parse_macro_expansion_error(
&self,
macro_call: MacroCallId,
) -> Option<Arc<ValueResult<Arc<[SyntaxError]>, ExpandError>>>
fn parse_macro_expansion_error( &self, macro_call: MacroCallId, ) -> Option<Arc<ValueResult<Arc<[SyntaxError]>, ExpandError>>>
Firewall query that returns the errors from the parse_macro_expansion
query.