mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-11 06:08:34 +00:00
Move binding accesses into SemanticModel
method (#5084)
This commit is contained in:
parent
1e497162d1
commit
c74ef77e85
13 changed files with 53 additions and 54 deletions
|
@ -106,6 +106,18 @@ impl<'a> SemanticModel<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Return the [`Binding`] for the given [`BindingId`].
|
||||
#[inline]
|
||||
pub fn binding(&self, id: BindingId) -> &Binding {
|
||||
&self.bindings[id]
|
||||
}
|
||||
|
||||
/// Resolve the [`Reference`] for the given [`ReferenceId`].
|
||||
#[inline]
|
||||
pub fn reference(&self, id: ReferenceId) -> &Reference {
|
||||
&self.references[id]
|
||||
}
|
||||
|
||||
/// Return `true` if the `Expr` is a reference to `typing.${target}`.
|
||||
pub fn match_typing_expr(&self, expr: &Expr, target: &str) -> bool {
|
||||
self.resolve_call_path(expr).map_or(false, |call_path| {
|
||||
|
@ -717,11 +729,6 @@ impl<'a> SemanticModel<'a> {
|
|||
self.bindings[binding_id].references.push(reference_id);
|
||||
}
|
||||
|
||||
/// Resolve a [`ReferenceId`].
|
||||
pub fn reference(&self, reference_id: ReferenceId) -> &Reference {
|
||||
self.references.resolve(reference_id)
|
||||
}
|
||||
|
||||
/// Return the [`ExecutionContext`] of the current scope.
|
||||
pub const fn execution_context(&self) -> ExecutionContext {
|
||||
if self.in_type_checking_block()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue