Modify semantic model API to push bindings upon creation (#4846)

This commit is contained in:
Charlie Marsh 2023-06-03 22:28:25 -04:00 committed by GitHub
parent 14e06f9f8b
commit 3fa4440d87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 54 deletions

View file

@ -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`.