pub struct Semantics<'db, DB> {
pub db: &'db DB,
/* private fields */
}
Expand description
Primary API to get semantic information, like types, from syntax trees.
Fields§
§db: &'db DB
Implementations§
source§impl<'db, DB> Semantics<'db, DB>where
DB: HirDatabase,
impl<'db, DB> Semantics<'db, DB>where DB: HirDatabase,
pub fn new(db: &DB) -> Semantics<'_, DB>
pub fn hir_file_for(&self, syntax_node: &SyntaxNode<RustLanguage>) -> HirFileId
pub fn token_ancestors_with_macros( &self, token: SyntaxToken<RustLanguage> ) -> impl Iterator<Item = SyntaxNode<RustLanguage>>
sourcepub fn find_node_at_offset_with_macros<N>(
&self,
node: &SyntaxNode<RustLanguage>,
offset: TextSize
) -> Option<N>where
N: AstNode,
pub fn find_node_at_offset_with_macros<N>( &self, node: &SyntaxNode<RustLanguage>, offset: TextSize ) -> Option<N>where N: AstNode,
Find an AstNode by offset inside SyntaxNode, if it is inside Macrofile, search up until it is of the target AstNode type
sourcepub fn find_node_at_offset_with_descend<N>(
&self,
node: &SyntaxNode<RustLanguage>,
offset: TextSize
) -> Option<N>where
N: AstNode,
pub fn find_node_at_offset_with_descend<N>( &self, node: &SyntaxNode<RustLanguage>, offset: TextSize ) -> Option<N>where N: AstNode,
Find an AstNode by offset inside SyntaxNode, if it is inside MacroCall, descend it and find again
sourcepub fn find_nodes_at_offset_with_descend<'slf, N>(
&'slf self,
node: &SyntaxNode<RustLanguage>,
offset: TextSize
) -> impl Iterator<Item = N> + 'slfwhere
N: AstNode + 'slf,
pub fn find_nodes_at_offset_with_descend<'slf, N>( &'slf self, node: &SyntaxNode<RustLanguage>, offset: TextSize ) -> impl Iterator<Item = N> + 'slfwhere N: AstNode + 'slf,
Find an AstNode by offset inside SyntaxNode, if it is inside MacroCall, descend it and find again
pub fn resolve_method_call(&self, call: &MethodCallExpr) -> Option<Function>
sourcepub fn resolve_method_call_field_fallback(
&self,
call: &MethodCallExpr
) -> Option<Either<Function, Field>>
pub fn resolve_method_call_field_fallback( &self, call: &MethodCallExpr ) -> Option<Either<Function, Field>>
Attempts to resolve this call expression as a method call falling back to resolving it as a field.
pub fn resolve_await_to_poll(&self, await_expr: &AwaitExpr) -> Option<Function>
pub fn resolve_prefix_expr(&self, prefix_expr: &PrefixExpr) -> Option<Function>
pub fn resolve_index_expr(&self, index_expr: &IndexExpr) -> Option<Function>
pub fn resolve_bin_expr(&self, bin_expr: &BinExpr) -> Option<Function>
pub fn resolve_try_expr(&self, try_expr: &TryExpr) -> Option<Function>
pub fn resolve_variant(&self, record_lit: RecordExpr) -> Option<VariantDef>
pub fn to_module_def(&self, file: FileId) -> Option<Module>
pub fn to_module_defs(&self, file: FileId) -> impl Iterator<Item = Module>
Trait Implementations§
Auto Trait Implementations§
impl<'db, DB> !RefUnwindSafe for Semantics<'db, DB>
impl<'db, DB> !Send for Semantics<'db, DB>
impl<'db, DB> !Sync for Semantics<'db, DB>
impl<'db, DB> Unpin for Semantics<'db, DB>
impl<'db, DB> !UnwindSafe for Semantics<'db, DB>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more