Trait ra_ap_hir::db::AstDatabase [−][src]
pub trait AstDatabase: Database + HasQueryGroup<AstDatabaseStorage> + SourceDatabase { fn ast_id_map(&self, key0: HirFileId) -> Arc<AstIdMap>; fn parse_or_expand(
&self,
key0: HirFileId
) -> Option<SyntaxNode<RustLanguage>>; fn parse_macro_expansion(
&self,
key0: MacroFile
) -> ExpandResult<Option<(Parse<SyntaxNode<RustLanguage>>, Arc<TokenMap>)>>; fn intern_macro(&self, key0: MacroCallLoc) -> MacroCallId; fn lookup_intern_macro(&self, key0: MacroCallId) -> MacroCallLoc; fn macro_arg(&self, key0: MacroCallId) -> Option<Arc<(Subtree, TokenMap)>>; fn macro_arg_text(&self, key0: MacroCallId) -> Option<GreenNode>; fn macro_def(&self, key0: MacroDefId) -> Option<Arc<TokenExpander>>; fn macro_expand(
&self,
key0: MacroCallId
) -> ExpandResult<Option<Arc<Subtree>>>; fn expand_proc_macro(
&self,
key0: MacroCallId
) -> Result<Subtree, ExpandError>; fn macro_expand_error(&self, key0: MacroCallId) -> Option<ExpandError>; fn hygiene_frame(&self, key0: HirFileId) -> Arc<HygieneFrame>; }
Required methods
fn ast_id_map(&self, key0: HirFileId) -> Arc<AstIdMap>
fn parse_or_expand(&self, key0: HirFileId) -> Option<SyntaxNode<RustLanguage>>
fn parse_or_expand(&self, key0: HirFileId) -> Option<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,
key0: MacroFile
) -> ExpandResult<Option<(Parse<SyntaxNode<RustLanguage>>, Arc<TokenMap>)>>
fn parse_macro_expansion(
&self,
key0: MacroFile
) -> ExpandResult<Option<(Parse<SyntaxNode<RustLanguage>>, Arc<TokenMap>)>>
Implementation for the macro case.
fn intern_macro(&self, key0: MacroCallLoc) -> MacroCallId
fn intern_macro(&self, key0: 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(&self, key0: MacroCallId) -> MacroCallLoc
Lowers syntactic macro call to a token tree representation.
fn macro_arg_text(&self, key0: MacroCallId) -> Option<GreenNode>
fn macro_arg_text(&self, key0: MacroCallId) -> Option<GreenNode>
Extracts syntax node, corresponding to a macro call. That’s a firewall query, only typing in the macro call itself changes the returned subtree.
fn macro_def(&self, key0: MacroDefId) -> Option<Arc<TokenExpander>>
fn macro_def(&self, key0: MacroDefId) -> Option<Arc<TokenExpander>>
Gets the expander for this macro. This compiles declarative macros, and just fetches procedural ones.
fn macro_expand(&self, key0: MacroCallId) -> ExpandResult<Option<Arc<Subtree>>>
fn macro_expand(&self, key0: MacroCallId) -> ExpandResult<Option<Arc<Subtree>>>
Expand macro call to a token tree. This query is LRUed (we keep 128 or so results in memory)
fn expand_proc_macro(&self, key0: MacroCallId) -> Result<Subtree, ExpandError>
fn expand_proc_macro(&self, key0: MacroCallId) -> Result<Subtree, 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!
fn macro_expand_error(&self, key0: MacroCallId) -> Option<ExpandError>
fn macro_expand_error(&self, key0: MacroCallId) -> Option<ExpandError>
Firewall query that returns the error from the macro_expand
query.
fn hygiene_frame(&self, key0: HirFileId) -> Arc<HygieneFrame>
Implementors
impl<DB> AstDatabase for DB where
DB: SourceDatabase + Database + HasQueryGroup<AstDatabaseStorage>,