hir_expand::db

Trait 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§

source

fn proc_macros(&self) -> Arc<ProcMacros>

The proc macros.

source

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.

source

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.

source

fn ast_id_map(&self, file_id: HirFileId) -> Arc<AstIdMap>

source

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.

source

fn parse_macro_expansion( &self, macro_file: MacroFileId, ) -> ExpandResult<(Parse<SyntaxNode>, Arc<ExpansionSpanMap>)>

Implementation for the macro case.

source

fn span_map(&self, file_id: HirFileId) -> SpanMap

source

fn expansion_span_map(&self, file_id: MacroFileId) -> Arc<ExpansionSpanMap>

source

fn real_span_map(&self, file_id: EditionedFileId) -> Arc<RealSpanMap>

source

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.

source

fn lookup_intern_macro_call(&self, key: MacroCallId) -> MacroCallLoc

source

fn intern_syntax_context(&self, ctx: SyntaxContextData) -> SyntaxContextId

source

fn lookup_intern_syntax_context( &self, key: SyntaxContextId, ) -> SyntaxContextData

source

fn setup_syntax_context_root(&self)

source

fn dump_syntax_contexts(&self) -> String

source

fn macro_arg( &self, id: MacroCallId, ) -> (Arc<Subtree>, SyntaxFixupUndoInfo, Span)

👎Deprecated: calling this is incorrect, call macro_arg_considering_derives instead

Lowers syntactic macro call to a token tree representation. That’s a firewall query, only typing in the macro call itself changes the returned subtree.

source

fn macro_arg_considering_derives( &self, id: MacroCallId, kind: &MacroCallKind, ) -> (Arc<Subtree>, SyntaxFixupUndoInfo, Span)

source

fn macro_expander(&self, id: MacroDefId) -> TokenExpander

Fetches the expander for this macro.

source

fn decl_macro_expander( &self, def_crate: CrateId, id: AstId<Macro>, ) -> Arc<DeclarativeMacroExpander>

Fetches (and compiles) the expander of this decl macro.

source

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

source

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.

source

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.

source

fn syntax_context(&self, file: HirFileId) -> SyntaxContextId

Implementors§

source§

impl<DB> ExpandDatabase for DB
where DB: SourceDatabase + Database + HasQueryGroup<ExpandDatabaseStorage>,