Skip to content

Commit

Permalink
Use en-us locale for typos (#16037)
Browse files Browse the repository at this point in the history
# Objective

Bevy seems to want to standardize on "American English" spellings. Not
sure if this is laid out anywhere in writing, but see also #15947.

While perusing the docs for `typos`, I noticed that it has a `locale`
config option and tried it out.

## Solution

Switch to `en-us` locale in the `typos` config and run `typos -w`

## Migration Guide

The following methods or fields have been renamed from `*dependants*` to
`*dependents*`.

- `ProcessorAssetInfo::dependants`
- `ProcessorAssetInfos::add_dependant`
- `ProcessorAssetInfos::non_existent_dependants`
- `AssetInfo::dependants_waiting_on_load`
- `AssetInfo::dependants_waiting_on_recursive_dep_load`
- `AssetInfos::loader_dependants`
- `AssetInfos::remove_dependants_and_labels`
  • Loading branch information
rparrett authored Oct 20, 2024
1 parent 472bbaa commit 30d8451
Show file tree
Hide file tree
Showing 58 changed files with 191 additions and 190 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3327,11 +3327,11 @@ doc-scrape-examples = true
hidden = true

[[example]]
name = "minimising"
path = "tests/window/minimising.rs"
name = "minimizing"
path = "tests/window/minimizing.rs"
doc-scrape-examples = true

[package.metadata.example.minimising]
[package.metadata.example.minimizing]
hidden = true

[[example]]
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_animation/src/animation_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) fn trigger_animation_event(

/// An event that can be used with animations.
/// It can be derived to trigger as an observer event,
/// if you need more complex behaviour, consider
/// if you need more complex behavior, consider
/// a manual implementation.
///
/// # Example
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/io/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn js_value_to_err(context: &str) -> impl FnOnce(JsValue) -> std::io::Error + '_

impl HttpWasmAssetReader {
async fn fetch_bytes<'a>(&self, path: PathBuf) -> Result<impl Reader, AssetReaderError> {
// The JS global scope includes a self-reference via a specialising name, which can be used to determine the type of global context available.
// The JS global scope includes a self-reference via a specializing name, which can be used to determine the type of global context available.
let global: Global = js_sys::global().unchecked_into();
let promise = if !global.window().is_undefined() {
let window: web_sys::Window = global.unchecked_into();
Expand Down
92 changes: 46 additions & 46 deletions crates/bevy_asset/src/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ impl AssetProcessor {
}

for dependency in dependencies {
asset_infos.add_dependant(&dependency, asset_path.clone());
asset_infos.add_dependent(&dependency, asset_path.clone());
}
}
}
Expand Down Expand Up @@ -1137,7 +1137,7 @@ pub enum ProcessStatus {
pub(crate) struct ProcessorAssetInfo {
processed_info: Option<ProcessedInfo>,
/// Paths of assets that depend on this asset when they are being processed.
dependants: HashSet<AssetPath<'static>>,
dependents: HashSet<AssetPath<'static>>,
status: Option<ProcessStatus>,
/// A lock that controls read/write access to processed asset files. The lock is shared for both the asset bytes and the meta bytes.
/// _This lock must be locked whenever a read or write to processed assets occurs_
Expand All @@ -1161,7 +1161,7 @@ impl Default for ProcessorAssetInfo {
status_sender.set_overflow(true);
Self {
processed_info: Default::default(),
dependants: Default::default(),
dependents: Default::default(),
file_transaction_lock: Default::default(),
status: None,
status_sender,
Expand All @@ -1187,23 +1187,23 @@ pub struct ProcessorAssetInfos {
/// The "current" in memory view of the asset space. During processing, if path does not exist in this, it should
/// be considered non-existent.
/// NOTE: YOU MUST USE `Self::get_or_insert` or `Self::insert` TO ADD ITEMS TO THIS COLLECTION TO ENSURE
/// `non_existent_dependants` DATA IS CONSUMED
/// `non_existent_dependents` DATA IS CONSUMED
infos: HashMap<AssetPath<'static>, ProcessorAssetInfo>,
/// Dependants for assets that don't exist. This exists to track "dangling" asset references due to deleted / missing files.
/// If the dependant asset is added, it can "resolve" these dependencies and re-compute those assets.
/// Dependents for assets that don't exist. This exists to track "dangling" asset references due to deleted / missing files.
/// If the dependent asset is added, it can "resolve" these dependencies and re-compute those assets.
/// Therefore this _must_ always be consistent with the `infos` data. If a new asset is added to `infos`, it should
/// check this maps for dependencies and add them. If an asset is removed, it should update the dependants here.
non_existent_dependants: HashMap<AssetPath<'static>, HashSet<AssetPath<'static>>>,
/// check this maps for dependencies and add them. If an asset is removed, it should update the dependents here.
non_existent_dependents: HashMap<AssetPath<'static>, HashSet<AssetPath<'static>>>,
check_reprocess_queue: VecDeque<AssetPath<'static>>,
}

impl ProcessorAssetInfos {
fn get_or_insert(&mut self, asset_path: AssetPath<'static>) -> &mut ProcessorAssetInfo {
self.infos.entry(asset_path.clone()).or_insert_with(|| {
let mut info = ProcessorAssetInfo::default();
// track existing dependants by resolving existing "hanging" dependants.
if let Some(dependants) = self.non_existent_dependants.remove(&asset_path) {
info.dependants = dependants;
// track existing dependents by resolving existing "hanging" dependents.
if let Some(dependents) = self.non_existent_dependents.remove(&asset_path) {
info.dependents = dependents;
}
info
})
Expand All @@ -1217,15 +1217,15 @@ impl ProcessorAssetInfos {
self.infos.get_mut(asset_path)
}

fn add_dependant(&mut self, asset_path: &AssetPath<'static>, dependant: AssetPath<'static>) {
fn add_dependent(&mut self, asset_path: &AssetPath<'static>, dependent: AssetPath<'static>) {
if let Some(info) = self.get_mut(asset_path) {
info.dependants.insert(dependant);
info.dependents.insert(dependent);
} else {
let dependants = self
.non_existent_dependants
let dependents = self
.non_existent_dependents
.entry(asset_path.clone())
.or_default();
dependants.insert(dependant);
dependents.insert(dependent);
}
}

Expand All @@ -1238,7 +1238,7 @@ impl ProcessorAssetInfos {
match result {
Ok(ProcessResult::Processed(processed_info)) => {
debug!("Finished processing \"{:?}\"", asset_path);
// clean up old dependants
// clean up old dependents
let old_processed_info = self
.infos
.get_mut(&asset_path)
Expand All @@ -1247,15 +1247,15 @@ impl ProcessorAssetInfos {
self.clear_dependencies(&asset_path, old_processed_info);
}

// populate new dependants
// populate new dependents
for process_dependency_info in &processed_info.process_dependencies {
self.add_dependant(&process_dependency_info.path, asset_path.to_owned());
self.add_dependent(&process_dependency_info.path, asset_path.to_owned());
}
let info = self.get_or_insert(asset_path);
info.processed_info = Some(processed_info);
info.update_status(ProcessStatus::Processed).await;
let dependants = info.dependants.iter().cloned().collect::<Vec<_>>();
for path in dependants {
let dependents = info.dependents.iter().cloned().collect::<Vec<_>>();
for path in dependents {
self.check_reprocess_queue.push_back(path);
}
}
Expand Down Expand Up @@ -1298,7 +1298,7 @@ impl ProcessorAssetInfos {
full_hash: AssetHash::default(),
process_dependencies: vec![],
});
self.add_dependant(dependency.path(), asset_path.to_owned());
self.add_dependent(dependency.path(), asset_path.to_owned());
}

let info = self.get_mut(&asset_path).expect("info should exist");
Expand All @@ -1319,13 +1319,13 @@ impl ProcessorAssetInfos {
.broadcast(ProcessStatus::NonExistent)
.await
.unwrap();
if !info.dependants.is_empty() {
if !info.dependents.is_empty() {
error!(
"The asset at {asset_path} was removed, but it had assets that depend on it to be processed. Consider updating the path in the following assets: {:?}",
info.dependants
info.dependents
);
self.non_existent_dependants
.insert(asset_path.clone(), info.dependants);
self.non_existent_dependents
.insert(asset_path.clone(), info.dependents);
}
}
}
Expand All @@ -1334,31 +1334,31 @@ impl ProcessorAssetInfos {
async fn rename(&mut self, old: &AssetPath<'static>, new: &AssetPath<'static>) {
let info = self.infos.remove(old);
if let Some(mut info) = info {
if !info.dependants.is_empty() {
if !info.dependents.is_empty() {
// TODO: We can't currently ensure "moved" folders with relative paths aren't broken because AssetPath
// doesn't distinguish between absolute and relative paths. We have "erased" relativeness. In the short term,
// we could do "remove everything in a folder and re-add", but that requires full rebuilds / destroying the cache.
// If processors / loaders could enumerate dependencies, we could check if the new deps line up with a rename.
// If deps encoded "relativeness" as part of loading, that would also work (this seems like the right call).
// TODO: it would be nice to log an error here for dependants that aren't also being moved + fixed.
// TODO: it would be nice to log an error here for dependents that aren't also being moved + fixed.
// (see the remove impl).
error!(
"The asset at {old} was removed, but it had assets that depend on it to be processed. Consider updating the path in the following assets: {:?}",
info.dependants
info.dependents
);
self.non_existent_dependants
.insert(old.clone(), core::mem::take(&mut info.dependants));
self.non_existent_dependents
.insert(old.clone(), core::mem::take(&mut info.dependents));
}
if let Some(processed_info) = &info.processed_info {
// Update "dependant" lists for this asset's "process dependencies" to use new path.
// Update "dependent" lists for this asset's "process dependencies" to use new path.
for dep in &processed_info.process_dependencies {
if let Some(info) = self.infos.get_mut(&dep.path) {
info.dependants.remove(old);
info.dependants.insert(new.clone());
} else if let Some(dependants) = self.non_existent_dependants.get_mut(&dep.path)
info.dependents.remove(old);
info.dependents.insert(new.clone());
} else if let Some(dependents) = self.non_existent_dependents.get_mut(&dep.path)
{
dependants.remove(old);
dependants.insert(new.clone());
dependents.remove(old);
dependents.insert(new.clone());
}
}
}
Expand All @@ -1367,33 +1367,33 @@ impl ProcessorAssetInfos {
.broadcast(ProcessStatus::NonExistent)
.await
.unwrap();
let dependants: Vec<AssetPath<'static>> = {
let dependents: Vec<AssetPath<'static>> = {
let new_info = self.get_or_insert(new.clone());
new_info.processed_info = info.processed_info;
new_info.status = info.status;
// Ensure things waiting on the new path are informed of the status of this asset
if let Some(status) = new_info.status {
new_info.status_sender.broadcast(status).await.unwrap();
}
new_info.dependants.iter().cloned().collect()
new_info.dependents.iter().cloned().collect()
};
// Queue the asset for a reprocess check, in case it needs new meta.
self.check_reprocess_queue.push_back(new.clone());
for dependant in dependants {
// Queue dependants for reprocessing because they might have been waiting for this asset.
self.check_reprocess_queue.push_back(dependant);
for dependent in dependents {
// Queue dependents for reprocessing because they might have been waiting for this asset.
self.check_reprocess_queue.push_back(dependent);
}
}
}

fn clear_dependencies(&mut self, asset_path: &AssetPath<'static>, removed_info: ProcessedInfo) {
for old_load_dep in removed_info.process_dependencies {
if let Some(info) = self.infos.get_mut(&old_load_dep.path) {
info.dependants.remove(asset_path);
} else if let Some(dependants) =
self.non_existent_dependants.get_mut(&old_load_dep.path)
info.dependents.remove(asset_path);
} else if let Some(dependents) =
self.non_existent_dependents.get_mut(&old_load_dep.path)
{
dependants.remove(asset_path);
dependents.remove(asset_path);
}
}
}
Expand Down
Loading

0 comments on commit 30d8451

Please sign in to comment.