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
If item has an attribute macro attached to it, expands it.
pub fn speculative_expand(
&self,
actual_macro_call: &MacroCall,
speculative_args: &TokenTree,
token_to_map: SyntaxToken
) -> Option<(SyntaxNode, SyntaxToken)>
pub fn speculative_expand_attr_macro(
&self,
actual_macro_call: &Item,
speculative_args: &Item,
token_to_map: SyntaxToken
) -> Option<(SyntaxNode, SyntaxToken)>
Descend the token into macrocalls to its first mapped counterpart.
Descend the token into macrocalls to all its mapped counterparts.
Maps a node down by mapping its first and last token down.
Search for a definition’s source and cache its syntax tree
pub fn token_ancestors_with_macros(
&self,
token: SyntaxToken
) -> impl Iterator<Item = SyntaxNode> + '_
pub fn ancestors_with_macros(
&self,
node: SyntaxNode
) -> impl Iterator<Item = SyntaxNode> + '_
pub fn ancestors_with_macros(
&self,
node: SyntaxNode
) -> impl Iterator<Item = SyntaxNode> + '_
Iterates the ancestors of the given node, climbing up macro expansions while doing so.
pub fn ancestors_at_offset_with_macros(
&self,
node: &SyntaxNode,
offset: TextSize
) -> impl Iterator<Item = SyntaxNode> + '_
pub 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
pub 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
pub 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_record_field(
&self,
field: &RecordExprField
) -> Option<(Field, Option<Local>, Type)>
Trait Implementations
Auto Trait Implementations
impl<'db, DB> !RefUnwindSafe for Semantics<'db, DB>
impl<'db, DB> !UnwindSafe for Semantics<'db, DB>
Blanket Implementations
Mutably borrows from an owned value. Read more
fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U where
Self: CastTo<U>,
U: HasInterner,
fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U where
Self: CastTo<U>,
U: HasInterner,
Cast a value to type U using CastTo.
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more