mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-17 00:50:16 +00:00
Track unresolved references in the semantic model (#5902)
## Summary As part of my continued quest to separate semantic model-building from diagnostic emission, this PR moves our unresolved-reference rules to a deferred pass. So, rather than emitting diagnostics as we encounter unresolved references, we now track those unresolved references on the semantic model (just like resolved references), and after traversal, emit the relevant rules for any unresolved references.
This commit is contained in:
parent
23cde4d1f5
commit
963f240e46
11 changed files with 261 additions and 202 deletions
|
@ -10,7 +10,7 @@ use ruff_python_ast::source_code::Locator;
|
|||
use crate::context::ExecutionContext;
|
||||
use crate::model::SemanticModel;
|
||||
use crate::node::NodeId;
|
||||
use crate::reference::ReferenceId;
|
||||
use crate::reference::ResolvedReferenceId;
|
||||
use crate::ScopeId;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -24,7 +24,7 @@ pub struct Binding<'a> {
|
|||
/// The statement in which the [`Binding`] was defined.
|
||||
pub source: Option<NodeId>,
|
||||
/// The references to the [`Binding`].
|
||||
pub references: Vec<ReferenceId>,
|
||||
pub references: Vec<ResolvedReferenceId>,
|
||||
/// The exceptions that were handled when the [`Binding`] was defined.
|
||||
pub exceptions: Exceptions,
|
||||
/// Flags for the [`Binding`].
|
||||
|
@ -38,7 +38,7 @@ impl<'a> Binding<'a> {
|
|||
}
|
||||
|
||||
/// Returns an iterator over all references for the current [`Binding`].
|
||||
pub fn references(&self) -> impl Iterator<Item = ReferenceId> + '_ {
|
||||
pub fn references(&self) -> impl Iterator<Item = ResolvedReferenceId> + '_ {
|
||||
self.references.iter().copied()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue