mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-10 05:39:12 +00:00
Move Binding
initialization into SemanticModel
(#4819)
This commit is contained in:
parent
935094c2ff
commit
c14896b42c
2 changed files with 117 additions and 189 deletions
|
@ -114,6 +114,37 @@ impl<'a> SemanticModel<'a> {
|
|||
false
|
||||
}
|
||||
|
||||
/// Create a new [`Binding`] for a builtin.
|
||||
pub fn builtin_binding(&self) -> Binding<'static> {
|
||||
Binding {
|
||||
range: TextRange::default(),
|
||||
kind: BindingKind::Builtin,
|
||||
references: Vec::new(),
|
||||
flags: BindingFlags::empty(),
|
||||
source: None,
|
||||
context: ExecutionContext::Runtime,
|
||||
exceptions: Exceptions::empty(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new `Binding` for the given `name` and `range`.
|
||||
pub fn declared_binding(
|
||||
&self,
|
||||
range: TextRange,
|
||||
kind: BindingKind<'a>,
|
||||
flags: BindingFlags,
|
||||
) -> Binding<'a> {
|
||||
Binding {
|
||||
range,
|
||||
kind,
|
||||
flags,
|
||||
references: Vec::new(),
|
||||
source: self.stmt_id,
|
||||
context: self.execution_context(),
|
||||
exceptions: self.exceptions(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the current `Binding` for a given `name`.
|
||||
pub fn find_binding(&self, member: &str) -> Option<&Binding> {
|
||||
self.scopes()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue