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 DBImplementations§
source§impl<'db, DB: HirDatabase> Semantics<'db, DB>
impl<'db, DB: HirDatabase> Semantics<'db, DB>
pub fn new(db: &DB) -> Semantics<'_, DB>
pub fn hir_file_for(&self, syntax_node: &SyntaxNode) -> HirFileId
pub fn token_ancestors_with_macros( &self, token: SyntaxToken ) -> impl Iterator<Item = SyntaxNode> + '_
sourcepub fn find_node_at_offset_with_macros<N: AstNode>(
&self,
node: &SyntaxNode,
offset: TextSize
) -> Option<N>
pub fn find_node_at_offset_with_macros<N: AstNode>( &self, node: &SyntaxNode, offset: TextSize ) -> Option<N>
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: AstNode>(
&self,
node: &SyntaxNode,
offset: TextSize
) -> Option<N>
pub fn find_node_at_offset_with_descend<N: AstNode>( &self, node: &SyntaxNode, offset: TextSize ) -> Option<N>
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: AstNode + 'slf>(
&'slf self,
node: &SyntaxNode,
offset: TextSize
) -> impl Iterator<Item = N> + 'slf
pub fn find_nodes_at_offset_with_descend<'slf, N: AstNode + 'slf>( &'slf self, node: &SyntaxNode, offset: TextSize ) -> impl Iterator<Item = N> + '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