mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
Modify semantic model API to push bindings upon creation (#4846)
This commit is contained in:
parent
14e06f9f8b
commit
3fa4440d87
2 changed files with 54 additions and 54 deletions
|
@ -115,8 +115,8 @@ impl<'a> SemanticModel<'a> {
|
|||
}
|
||||
|
||||
/// Create a new [`Binding`] for a builtin.
|
||||
pub fn builtin_binding(&self) -> Binding<'static> {
|
||||
Binding {
|
||||
pub fn push_builtin(&mut self) -> BindingId {
|
||||
self.bindings.push(Binding {
|
||||
range: TextRange::default(),
|
||||
kind: BindingKind::Builtin,
|
||||
references: Vec::new(),
|
||||
|
@ -124,17 +124,17 @@ impl<'a> SemanticModel<'a> {
|
|||
source: None,
|
||||
context: ExecutionContext::Runtime,
|
||||
exceptions: Exceptions::empty(),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Create a new `Binding` for the given `name` and `range`.
|
||||
pub fn declared_binding(
|
||||
&self,
|
||||
/// Create a new [`Binding`] for the given `name` and `range`.
|
||||
pub fn push_binding(
|
||||
&mut self,
|
||||
range: TextRange,
|
||||
kind: BindingKind<'a>,
|
||||
flags: BindingFlags,
|
||||
) -> Binding<'a> {
|
||||
Binding {
|
||||
) -> BindingId {
|
||||
self.bindings.push(Binding {
|
||||
range,
|
||||
kind,
|
||||
flags,
|
||||
|
@ -142,7 +142,7 @@ impl<'a> SemanticModel<'a> {
|
|||
source: self.stmt_id,
|
||||
context: self.execution_context(),
|
||||
exceptions: self.exceptions(),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Return the current `Binding` for a given `name`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue