Trait hir_expand::db::ExpandDatabase
source · 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;
fn parse_macro_expansion(
&self,
macro_file: MacroFileId,
) -> ExpandResult<(Parse<SyntaxNode>, Arc<ExpansionSpanMap>)>;
fn span_map(&self, file_id: HirFileId) -> SpanMap;
fn expansion_span_map(&self, file_id: MacroFileId) -> Arc<ExpansionSpanMap>;
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>, SyntaxFixupUndoInfo, Span);
fn macro_arg_considering_derives(
&self,
id: MacroCallId,
kind: &MacroCallKind,
) -> (Arc<Subtree>, SyntaxFixupUndoInfo, Span);
fn macro_expander(&self, id: MacroDefId) -> TokenExpander;
fn decl_macro_expander(
&self,
def_crate: CrateId,
id: AstId<Macro>,
) -> Arc<DeclarativeMacroExpander>;
fn expand_proc_macro(&self, call: MacroCallId) -> ExpandResult<Arc<Subtree>>;
fn proc_macro_span(&self, fun: AstId<Fn>) -> Span;
fn parse_macro_expansion_error(
&self,
macro_call: MacroCallId,
) -> Option<Arc<ExpandResult<Arc<[SyntaxError]>>>>;
fn syntax_context(&self, file: HirFileId) -> SyntaxContextId;
}
Required Methods§
sourcefn proc_macros(&self) -> Arc<ProcMacros>
fn proc_macros(&self) -> Arc<ProcMacros>
The proc macros.
sourcefn 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.
sourcefn 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>
sourcefn parse_or_expand(&self, file_id: HirFileId) -> SyntaxNode
fn parse_or_expand(&self, file_id: HirFileId) -> SyntaxNode
Main public API – parses a hir file, not caring whether it’s a real file or a macro expansion.
sourcefn parse_macro_expansion(
&self,
macro_file: MacroFileId,
) -> ExpandResult<(Parse<SyntaxNode>, Arc<ExpansionSpanMap>)>
fn parse_macro_expansion( &self, macro_file: MacroFileId, ) -> ExpandResult<(Parse<SyntaxNode>, Arc<ExpansionSpanMap>)>
Implementation for the macro case.
fn span_map(&self, file_id: HirFileId) -> SpanMap
fn expansion_span_map(&self, file_id: MacroFileId) -> Arc<ExpansionSpanMap>
fn real_span_map(&self, file_id: EditionedFileId) -> Arc<RealSpanMap>
sourcefn 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
sourcefn macro_arg(
&self,
id: MacroCallId,
) -> (Arc<Subtree>, SyntaxFixupUndoInfo, Span)
👎Deprecated: calling this is incorrect, call macro_arg_considering_derives
instead
fn macro_arg( &self, id: MacroCallId, ) -> (Arc<Subtree>, SyntaxFixupUndoInfo, Span)
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>, SyntaxFixupUndoInfo, Span)
sourcefn macro_expander(&self, id: MacroDefId) -> TokenExpander
fn macro_expander(&self, id: MacroDefId) -> TokenExpander
Fetches the expander for this macro.
sourcefn decl_macro_expander(
&self,
def_crate: CrateId,
id: AstId<Macro>,
) -> Arc<DeclarativeMacroExpander>
fn decl_macro_expander( &self, def_crate: CrateId, id: AstId<Macro>, ) -> Arc<DeclarativeMacroExpander>
Fetches (and compiles) the expander of this decl macro.
sourcefn expand_proc_macro(&self, call: MacroCallId) -> ExpandResult<Arc<Subtree>>
fn expand_proc_macro(&self, call: MacroCallId) -> ExpandResult<Arc<Subtree>>
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
sourcefn proc_macro_span(&self, fun: AstId<Fn>) -> Span
fn proc_macro_span(&self, fun: AstId<Fn>) -> Span
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.
sourcefn parse_macro_expansion_error(
&self,
macro_call: MacroCallId,
) -> Option<Arc<ExpandResult<Arc<[SyntaxError]>>>>
fn parse_macro_expansion_error( &self, macro_call: MacroCallId, ) -> Option<Arc<ExpandResult<Arc<[SyntaxError]>>>>
Firewall query that returns the errors from the parse_macro_expansion
query.