diff --git a/bin/src/modules/rapifier.rs b/bin/src/modules/rapifier.rs index c75d2d85..3f5168e1 100644 --- a/bin/src/modules/rapifier.rs +++ b/bin/src/modules/rapifier.rs @@ -142,7 +142,7 @@ pub fn rapify(path: WorkspacePath, _ctx: &Context) -> (Vec, Result<(), E ))), ); } - let out = if path.filename() == "config.cpp" { + let out = if path.filename().to_lowercase() == "config.cpp" { path.parent().join("config.bin").unwrap() } else { path diff --git a/libs/preprocessor/src/codes/mod.rs b/libs/preprocessor/src/codes/mod.rs index e6950bd9..f6d28405 100644 --- a/libs/preprocessor/src/codes/mod.rs +++ b/libs/preprocessor/src/codes/mod.rs @@ -22,3 +22,4 @@ pub mod pe8_if_undefined; pub mod pe9_function_call_argument_count; pub mod pw1_redefine; +pub mod pw2_invalid_config_case; diff --git a/libs/preprocessor/src/codes/pw2_invalid_config_case.rs b/libs/preprocessor/src/codes/pw2_invalid_config_case.rs new file mode 100644 index 00000000..a6adc0db --- /dev/null +++ b/libs/preprocessor/src/codes/pw2_invalid_config_case.rs @@ -0,0 +1,43 @@ +use ariadne::Fmt; +use hemtt_common::{reporting::Code, workspace::WorkspacePath}; + +#[allow(unused)] +/// Unexpected token +pub struct InvalidConfigCase { + /// The [`WorkspacePath`] that was named with an invalid case + pub(crate) path: WorkspacePath, +} + +impl Code for InvalidConfigCase { + fn ident(&self) -> &'static str { + "PW2" + } + + fn message(&self) -> String { + format!( + "`{}` is not a valid case for a config", + self.path.filename() + ) + } + + fn label_message(&self) -> String { + format!( + "`{}` is not a valid case for a config", + self.path.filename() + ) + } + + fn help(&self) -> Option { + Some(format!("Rename to `{}`", self.path.as_str().to_lowercase())) + } + + fn generate_report(&self) -> Option { + Some(format!( + "{} {}\n {}: {}", + format!("[{}] Warning:", self.ident()).fg(ariadne::Color::Yellow), + self.message(), + "Help".fg(ariadne::Color::Fixed(115)), + self.help().expect("help should be Some") + )) + } +} diff --git a/libs/preprocessor/src/processor/mod.rs b/libs/preprocessor/src/processor/mod.rs index 754cf1d5..c07319a0 100644 --- a/libs/preprocessor/src/processor/mod.rs +++ b/libs/preprocessor/src/processor/mod.rs @@ -8,6 +8,7 @@ use peekmore::{PeekMore, PeekMoreIterator}; use crate::codes::pe18_eoi_ifstate::EoiIfState; use crate::codes::pe2_unexpected_eof::UnexpectedEOF; use crate::codes::pe3_expected_ident::ExpectedIdent; +use crate::codes::pw2_invalid_config_case::InvalidConfigCase; use crate::defines::Defines; use crate::ifstate::IfStates; use crate::Error; @@ -66,6 +67,12 @@ impl Processor { }))); } + if path.filename() == "Config.cpp" { + processor + .warnings + .push(Box::new(InvalidConfigCase { path: path.clone() })); + } + Processed::new( buffer, processor.usage,