mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-16 16:40:19 +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
|
@ -1,6 +1,7 @@
|
|||
use ruff_text_size::TextRange;
|
||||
use std::ops::Deref;
|
||||
|
||||
use ruff_index::{newtype_index, IndexVec};
|
||||
use ruff_index::{newtype_index, IndexSlice, IndexVec};
|
||||
|
||||
use crate::context::ExecutionContext;
|
||||
use crate::scope::ScopeId;
|
||||
|
@ -38,7 +39,7 @@ pub struct ReferenceId;
|
|||
pub struct References(IndexVec<ReferenceId, Reference>);
|
||||
|
||||
impl References {
|
||||
/// Pushes a new read reference and returns its unique id.
|
||||
/// Pushes a new [`Reference`] and returns its [`ReferenceId`].
|
||||
pub fn push(
|
||||
&mut self,
|
||||
scope_id: ScopeId,
|
||||
|
@ -51,9 +52,12 @@ impl References {
|
|||
context,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the [`Reference`] with the given id.
|
||||
pub fn resolve(&self, id: ReferenceId) -> &Reference {
|
||||
&self.0[id]
|
||||
impl Deref for References {
|
||||
type Target = IndexSlice<ReferenceId, Reference>;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue