Move Binding initialization into SemanticModel (#4819)

This commit is contained in:
Charlie Marsh 2023-06-03 15:26:55 -04:00 committed by GitHub
parent 935094c2ff
commit c14896b42c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 117 additions and 189 deletions

View file

@ -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()