Rename semantic model methods to use current_* prefix (#6347)

## Summary

This PR attempts to draw a clearer divide between "methods that take
(e.g.) an expression or statement as input" and "methods that rely on
the _current_ expression or statement" in the semantic model, by
renaming methods like `stmt()` to `current_statement()`.

This had led to confusion in the past. For example, prior to this PR, we
had `scope()` (which returns the current scope), and `parent_scope`,
which returns the parent _of a scope that's passed in_. Now, the API is
clearer: `current_scope` returns the current scope, and `parent_scope`
takes a scope as argument and returns its parent.

Per above, I also changed `stmt` to `statement` and `expr` to
`expression`.
This commit is contained in:
Charlie Marsh 2023-08-07 10:44:49 -04:00 committed by GitHub
parent b763973357
commit bae87fa016
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 331 additions and 290 deletions

View file

@ -185,7 +185,7 @@ impl<'a> Binding<'a> {
/// Returns the range of the binding's parent.
pub fn parent_range(&self, semantic: &SemanticModel) -> Option<TextRange> {
self.source
.map(|node_id| semantic.stmts[node_id])
.map(|node_id| semantic.statements[node_id])
.and_then(|parent| {
if parent.is_import_from_stmt() {
Some(parent.range())