mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-17 00:50:16 +00:00
Remove separate ReferenceContext
enum (#4631)
This commit is contained in:
parent
86ced3516b
commit
fcdc7bdd33
7 changed files with 30 additions and 61 deletions
|
@ -2,6 +2,7 @@ use ruff_text_size::TextRange;
|
|||
|
||||
use ruff_index::{newtype_index, IndexVec};
|
||||
|
||||
use crate::context::ExecutionContext;
|
||||
use crate::scope::ScopeId;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -11,7 +12,7 @@ pub struct Reference {
|
|||
/// The range of the reference in the source code.
|
||||
range: TextRange,
|
||||
/// The context in which the reference occurs.
|
||||
context: ReferenceContext,
|
||||
context: ExecutionContext,
|
||||
}
|
||||
|
||||
impl Reference {
|
||||
|
@ -23,19 +24,11 @@ impl Reference {
|
|||
self.range
|
||||
}
|
||||
|
||||
pub const fn context(&self) -> &ReferenceContext {
|
||||
pub const fn context(&self) -> &ExecutionContext {
|
||||
&self.context
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, is_macro::Is)]
|
||||
pub enum ReferenceContext {
|
||||
/// The reference occurs in a runtime context.
|
||||
Runtime,
|
||||
/// The reference occurs in a typing-only context.
|
||||
Typing,
|
||||
}
|
||||
|
||||
/// Id uniquely identifying a read reference in a program.
|
||||
#[newtype_index]
|
||||
pub struct ReferenceId;
|
||||
|
@ -50,7 +43,7 @@ impl References {
|
|||
&mut self,
|
||||
scope_id: ScopeId,
|
||||
range: TextRange,
|
||||
context: ReferenceContext,
|
||||
context: ExecutionContext,
|
||||
) -> ReferenceId {
|
||||
self.0.push(Reference {
|
||||
scope_id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue