pub struct Semantics<'db> {
pub db: &'db dyn HirDatabase,
/* private fields */
}
Expand description
The primary API to get semantic information, like types, from syntax trees. Exposes the database
it was created with through the db
field.
Fields§
§db: &'db dyn HirDatabase
Implementations§
source§impl<'db> Semantics<'db>
impl<'db> Semantics<'db>
sourcepub fn new(db: &'db dyn HirDatabase) -> Self
pub fn new(db: &'db dyn HirDatabase) -> Self
Constructs a new Semantics
instance with the given database.
sourcepub fn parse(&self, file_id: FileId) -> SourceFile
pub fn parse(&self, file_id: FileId) -> SourceFile
Returns the Concrete Syntax Tree for the file with the given file_id
.
sourcepub fn scope_at_offset(
&self,
node: &SyntaxNode,
offset: TextSize
) -> SemanticsScope<'db>
pub fn scope_at_offset(
&self,
node: &SyntaxNode,
offset: TextSize
) -> SemanticsScope<'db>
Computes the SemanticScope
at the given position in a CST.
sourcepub fn type_of_expr(&self, expr: &Expr) -> Option<Ty>
pub fn type_of_expr(&self, expr: &Expr) -> Option<Ty>
Returns the type of the given expression