From 50053f60f36c63b8b7475a9fa48216d37a7bf040 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 30 May 2023 17:53:36 -0400 Subject: [PATCH] Rename top-of-file to start-of-file (#4735) --- crates/ruff/src/importer/insertion.rs | 6 +++--- crates/ruff/src/importer/mod.rs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/ruff/src/importer/insertion.rs b/crates/ruff/src/importer/insertion.rs index ca715a1d0d..6ebd3d6028 100644 --- a/crates/ruff/src/importer/insertion.rs +++ b/crates/ruff/src/importer/insertion.rs @@ -66,7 +66,7 @@ impl Insertion { /// /// The insertion returned will begin at the start of the `import os` statement, and will /// include a trailing newline suffix. - pub(super) fn top_of_file(body: &[Stmt], locator: &Locator, stylist: &Stylist) -> Insertion { + pub(super) fn start_of_file(body: &[Stmt], locator: &Locator, stylist: &Stylist) -> Insertion { // Skip over any docstrings. let mut location = if let Some(location) = match_docstring_end(body) { // If the first token after the docstring is a semicolon, insert after the semicolon as an @@ -152,11 +152,11 @@ mod tests { let tokens: Vec = ruff_rustpython::tokenize(contents); let locator = Locator::new(contents); let stylist = Stylist::from_tokens(&tokens, &locator); - Ok(Insertion::top_of_file(&program, &locator, &stylist)) + Ok(Insertion::start_of_file(&program, &locator, &stylist)) } #[test] - fn top_of_file() -> Result<()> { + fn start_of_file() -> Result<()> { let contents = ""; assert_eq!( insert(contents)?, diff --git a/crates/ruff/src/importer/mod.rs b/crates/ruff/src/importer/mod.rs index 57a5b9b9e5..df980012b6 100644 --- a/crates/ruff/src/importer/mod.rs +++ b/crates/ruff/src/importer/mod.rs @@ -67,8 +67,8 @@ impl<'a> Importer<'a> { Insertion::end_of_statement(stmt, self.locator, self.stylist) .into_edit(&required_import) } else { - // Insert at the top of the file. - Insertion::top_of_file(self.python_ast, self.locator, self.stylist) + // Insert at the start of the file. + Insertion::start_of_file(self.python_ast, self.locator, self.stylist) .into_edit(&required_import) } } @@ -105,7 +105,7 @@ impl<'a> Importer<'a> { // could be defined in the module scope, but after the function definition. In this case, // it's unclear whether we can use the symbol (the function could be called between the // import and the current location, and thus the symbol would not be available). It's also - // unclear whether should add an import statement at the top of the file, since it could + // unclear whether should add an import statement at the start of the file, since it could // be shadowed between the import and the current location. if imported_name.range().start() > at { return Some(Err(ResolutionError::ImportAfterUsage)); @@ -144,7 +144,7 @@ impl<'a> Importer<'a> { /// the symbol available in the current scope along with the bound name of the symbol. /// /// For example, assuming `module` is `"functools"` and `member` is `"lru_cache"`, this function - /// could return an [`Edit`] to add `import functools` to the top of the file, alongside with + /// could return an [`Edit`] to add `import functools` to the start of the file, alongside with /// the name on which the `lru_cache` symbol would be made available (`"functools.lru_cache"`). fn import_symbol( &self,