From 110d198fedcd07df0f593fd072e36a9575b19a1d Mon Sep 17 00:00:00 2001 From: nerodesu017 <46645625+nerodesu017@users.noreply.github.com> Date: Fri, 5 Dec 2025 14:59:04 +0200 Subject: [PATCH 1/3] change visibility on structs/methods --- src/frontend/configuration.rs | 2 +- src/lib.rs | 1 + src/rules/mod.rs | 2 +- src/rules/require/mod.rs | 4 ++-- src/rules/require/path_locator.rs | 4 ++-- src/rules/require/path_require_mode.rs | 2 +- src/utils/mod.rs | 2 +- src/utils/scoped_hash_map.rs | 10 +++++----- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/frontend/configuration.rs b/src/frontend/configuration.rs index 31b170ff..e26ce3ee 100644 --- a/src/frontend/configuration.rs +++ b/src/frontend/configuration.rs @@ -122,7 +122,7 @@ impl Configuration { } #[inline] - pub(crate) fn location(&self) -> Option<&Path> { + pub fn location(&self) -> Option<&Path> { self.location.as_deref() } } diff --git a/src/lib.rs b/src/lib.rs index d469338c..e9dd5e82 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,3 +67,4 @@ pub use frontend::{ Options, Resources, WorkerTree, }; pub use parser::{Parser, ParserError}; +pub use utils::ScopedHashMap; \ No newline at end of file diff --git a/src/rules/mod.rs b/src/rules/mod.rs index 54a1dfb5..9998061e 100644 --- a/src/rules/mod.rs +++ b/src/rules/mod.rs @@ -72,7 +72,7 @@ pub use remove_types::*; pub use remove_unused_variable::*; pub use rename_variables::*; pub(crate) use replace_referenced_tokens::*; -pub use require::PathRequireMode; +pub use require::{PathRequireMode, RequirePathLocator, PathLocator}; pub use rule_property::*; pub(crate) use shift_token_line::*; pub use unused_if_branch::*; diff --git a/src/rules/require/mod.rs b/src/rules/require/mod.rs index 8feb1990..f581eb86 100644 --- a/src/rules/require/mod.rs +++ b/src/rules/require/mod.rs @@ -11,12 +11,12 @@ use std::path::{Path, PathBuf}; pub(crate) use luau_path_locator::LuauPathLocator; pub use luau_require_mode::LuauRequireMode; pub(crate) use match_require::{is_require_call, match_path_require_call}; -pub(crate) use path_locator::RequirePathLocator; +pub use path_locator::RequirePathLocator; pub use path_require_mode::PathRequireMode; use crate::DarkluaError; -pub(crate) trait PathLocator { +pub trait PathLocator { fn find_require_path( &self, path: impl Into, diff --git a/src/rules/require/path_locator.rs b/src/rules/require/path_locator.rs index f7a5d6ee..04cceb6a 100644 --- a/src/rules/require/path_locator.rs +++ b/src/rules/require/path_locator.rs @@ -4,14 +4,14 @@ use super::{path_iterator, PathRequireMode}; use crate::{rules::require::path_utils::is_require_relative, utils, DarkluaError, Resources}; #[derive(Debug)] -pub(crate) struct RequirePathLocator<'a, 'b, 'resources> { +pub struct RequirePathLocator<'a, 'b, 'resources> { path_require_mode: &'a PathRequireMode, extra_module_relative_location: &'b Path, resources: &'resources Resources, } impl<'a, 'b, 'c> RequirePathLocator<'a, 'b, 'c> { - pub(crate) fn new( + pub fn new( path_require_mode: &'a PathRequireMode, extra_module_relative_location: &'b Path, resources: &'c Resources, diff --git a/src/rules/require/path_require_mode.rs b/src/rules/require/path_require_mode.rs index 093a7917..a0af41f5 100644 --- a/src/rules/require/path_require_mode.rs +++ b/src/rules/require/path_require_mode.rs @@ -68,7 +68,7 @@ impl PathRequireMode { } } - pub(crate) fn initialize(&mut self, context: &Context) -> Result<(), DarkluaError> { + pub fn initialize(&mut self, context: &Context) -> Result<(), DarkluaError> { if !self.use_luau_configuration { self.luau_rc_aliases.take(); return Ok(()); diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 548c775d..36d3a169 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -9,7 +9,7 @@ mod timer; pub(crate) use expressions_as_statement::{expressions_as_expression, expressions_as_statement}; pub(crate) use luau_config::{clear_luau_configuration_cache, find_luau_configuration}; pub(crate) use preserve_arguments_side_effects::preserve_arguments_side_effects; -pub(crate) use scoped_hash_map::ScopedHashMap; +pub use scoped_hash_map::ScopedHashMap; pub(crate) use serde_string_or_struct::string_or_struct; use std::{ ffi::OsStr, diff --git a/src/utils/scoped_hash_map.rs b/src/utils/scoped_hash_map.rs index 065e7bab..8390e942 100644 --- a/src/utils/scoped_hash_map.rs +++ b/src/utils/scoped_hash_map.rs @@ -2,16 +2,16 @@ use std::collections::HashMap; use std::hash::Hash; #[derive(Debug, Default, Clone)] -pub(crate) struct ScopedHashMap { +pub struct ScopedHashMap { stack: Vec>, } impl ScopedHashMap { - pub(crate) fn get(&self, key: &Key) -> Option<&Value> { + pub fn get(&self, key: &Key) -> Option<&Value> { self.stack.iter().rev().find_map(|map| map.get(key)) } - pub(crate) fn insert(&mut self, key: Key, value: Value) { + pub fn insert(&mut self, key: Key, value: Value) { if let Some(hash_map) = self.stack.last_mut() { hash_map.insert(key, value); } else { @@ -21,11 +21,11 @@ impl ScopedHashMap { } } - pub(crate) fn push(&mut self) { + pub fn push(&mut self) { self.stack.push(Default::default()) } - pub(crate) fn pop(&mut self) { + pub fn pop(&mut self) { self.stack.pop(); } } From 3f58528e9e60a86c5d6ef2125022e1f2a67dc10f Mon Sep 17 00:00:00 2001 From: nerodesu017 <46645625+nerodesu017@users.noreply.github.com> Date: Fri, 5 Dec 2025 15:23:21 +0200 Subject: [PATCH 2/3] update changelog --- CHANGELOG.md | 7 +++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c36ff5f..eb80023f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 0.17.4 + +* make `Configuration::location()` public +* export `ScopedHashMap` from the library +* make `RequirePathLocator` and `PathLocator` public +* make `PathRequireMode::initialize()` public + ## 0.17.3 * fix `inject_global_value` rule to not override environment values with the default value when they're defined ([#324](https://github.com/seaofvoices/darklua/pull/324)) diff --git a/Cargo.lock b/Cargo.lock index eeef51d9..270a28d7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -384,7 +384,7 @@ dependencies = [ [[package]] name = "darklua" -version = "0.17.3" +version = "0.17.4" dependencies = [ "anstyle", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index 78bfec51..48742133 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "darklua" -version = "0.17.3" +version = "0.17.4" authors = ["jeparlefrancais "] edition = "2018" readme = "README.md" From d776ee18be7a226f02f1ebe722c0c6e34c4ed391 Mon Sep 17 00:00:00 2001 From: Adrian Date: Thu, 11 Dec 2025 02:20:11 +0200 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: jeparlefrancais <35781636+jeparlefrancais@users.noreply.github.com> --- CHANGELOG.md | 7 ++----- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb80023f..c6f468fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,8 @@ # Changelog -## 0.17.4 +## Unreleased changes -* make `Configuration::location()` public -* export `ScopedHashMap` from the library -* make `RequirePathLocator` and `PathLocator` public -* make `PathRequireMode::initialize()` public +* mark some internal functionality public for the darklua library (`Configuration::location()`) ([#328](https://github.com/seaofvoices/darklua/pull/328)) ## 0.17.3 diff --git a/Cargo.toml b/Cargo.toml index 48742133..78bfec51 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "darklua" -version = "0.17.4" +version = "0.17.3" authors = ["jeparlefrancais "] edition = "2018" readme = "README.md"