From 3fdc89417b3e991c883140a821e44ecf45bc1f57 Mon Sep 17 00:00:00 2001 From: Brett Mayson Date: Tue, 22 Oct 2024 07:05:54 +0000 Subject: [PATCH] remove duplicate function --- .../launch/error/bcle1_preset_not_found.rs | 2 +- .../launch/error/bcle2_workshop_not_found.rs | 2 +- .../launch/error/bcle3_workshop_mod_not_found.rs | 2 +- .../commands/launch/error/bcle4_arma_not_found.rs | 2 +- .../launch/error/bcle5_missing_main_prefix.rs | 2 +- .../launch/error/bcle6_launch_config_not_found.rs | 2 +- .../launch/error/bcle7_can_not_quicklaunch.rs | 2 +- .../launch/error/bcle8_mission_not_found.rs | 2 +- .../launch/error/bcle9_mission_absolute.rs | 2 +- bin/src/commands/new/error/bcne1_not_terminal.rs | 2 +- bin/src/commands/new/error/bcne2_folder_exists.rs | 2 +- .../binarize/error/bbe3_binarize_failed.rs | 2 +- .../binarize/error/bbe4_missing_textures.rs | 2 +- .../binarize/error/bbe5_missing_material.rs | 2 +- .../modules/binarize/error/bbe6_missing_pdrive.rs | 2 +- .../modules/binarize/error/bbe7_wine_not_found.rs | 2 +- .../binarize/error/bbw1_tools_not_found.rs | 2 +- .../binarize/error/bbw2_platform_not_supported.rs | 2 +- .../modules/hook/error/bhe1_script_not_found.rs | 2 +- bin/src/modules/hook/error/bhe2_script_fatal.rs | 2 +- bin/src/modules/hook/error/bhe3_parse_error.rs | 2 +- bin/src/modules/hook/error/bhe4_runtime_error.rs | 2 +- bin/src/modules/sign.rs | 2 +- bin/src/modules/sqf.rs | 2 +- libs/workspace/src/lint/mod.rs | 2 +- libs/workspace/src/reporting/diagnostic/mod.rs | 15 --------------- 26 files changed, 25 insertions(+), 40 deletions(-) diff --git a/bin/src/commands/launch/error/bcle1_preset_not_found.rs b/bin/src/commands/launch/error/bcle1_preset_not_found.rs index cfcaa028..e4631a86 100644 --- a/bin/src/commands/launch/error/bcle1_preset_not_found.rs +++ b/bin/src/commands/launch/error/bcle1_preset_not_found.rs @@ -30,7 +30,7 @@ impl Code for PresetNotFound { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/commands/launch/error/bcle2_workshop_not_found.rs b/bin/src/commands/launch/error/bcle2_workshop_not_found.rs index 4d4b4685..c6fb085d 100644 --- a/bin/src/commands/launch/error/bcle2_workshop_not_found.rs +++ b/bin/src/commands/launch/error/bcle2_workshop_not_found.rs @@ -21,7 +21,7 @@ impl Code for WorkshopNotFound { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/commands/launch/error/bcle3_workshop_mod_not_found.rs b/bin/src/commands/launch/error/bcle3_workshop_mod_not_found.rs index bf53ad81..ac4b8927 100644 --- a/bin/src/commands/launch/error/bcle3_workshop_mod_not_found.rs +++ b/bin/src/commands/launch/error/bcle3_workshop_mod_not_found.rs @@ -24,7 +24,7 @@ impl Code for WorkshopModNotFound { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/commands/launch/error/bcle4_arma_not_found.rs b/bin/src/commands/launch/error/bcle4_arma_not_found.rs index 5d9bf56b..afa5dce6 100644 --- a/bin/src/commands/launch/error/bcle4_arma_not_found.rs +++ b/bin/src/commands/launch/error/bcle4_arma_not_found.rs @@ -18,7 +18,7 @@ impl Code for ArmaNotFound { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/commands/launch/error/bcle5_missing_main_prefix.rs b/bin/src/commands/launch/error/bcle5_missing_main_prefix.rs index fb8071b6..ab19492e 100644 --- a/bin/src/commands/launch/error/bcle5_missing_main_prefix.rs +++ b/bin/src/commands/launch/error/bcle5_missing_main_prefix.rs @@ -18,7 +18,7 @@ impl Code for MissingMainPrefix { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/commands/launch/error/bcle6_launch_config_not_found.rs b/bin/src/commands/launch/error/bcle6_launch_config_not_found.rs index e6c954d8..33add922 100644 --- a/bin/src/commands/launch/error/bcle6_launch_config_not_found.rs +++ b/bin/src/commands/launch/error/bcle6_launch_config_not_found.rs @@ -30,7 +30,7 @@ impl Code for LaunchConfigNotFound { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/commands/launch/error/bcle7_can_not_quicklaunch.rs b/bin/src/commands/launch/error/bcle7_can_not_quicklaunch.rs index fe30cfa5..05cddcd0 100644 --- a/bin/src/commands/launch/error/bcle7_can_not_quicklaunch.rs +++ b/bin/src/commands/launch/error/bcle7_can_not_quicklaunch.rs @@ -20,7 +20,7 @@ impl Code for CanNotQuickLaunch { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/commands/launch/error/bcle8_mission_not_found.rs b/bin/src/commands/launch/error/bcle8_mission_not_found.rs index 5251b5dd..303d40c0 100644 --- a/bin/src/commands/launch/error/bcle8_mission_not_found.rs +++ b/bin/src/commands/launch/error/bcle8_mission_not_found.rs @@ -30,7 +30,7 @@ impl Code for MissionNotFound { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/commands/launch/error/bcle9_mission_absolute.rs b/bin/src/commands/launch/error/bcle9_mission_absolute.rs index a2d9cb5e..37f2c0f7 100644 --- a/bin/src/commands/launch/error/bcle9_mission_absolute.rs +++ b/bin/src/commands/launch/error/bcle9_mission_absolute.rs @@ -24,7 +24,7 @@ impl Code for MissionAbsolutePath { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/commands/new/error/bcne1_not_terminal.rs b/bin/src/commands/new/error/bcne1_not_terminal.rs index 3371e43c..0f58903d 100644 --- a/bin/src/commands/new/error/bcne1_not_terminal.rs +++ b/bin/src/commands/new/error/bcne1_not_terminal.rs @@ -14,7 +14,7 @@ impl Code for TerminalNotInput { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/commands/new/error/bcne2_folder_exists.rs b/bin/src/commands/new/error/bcne2_folder_exists.rs index 27429522..3d9c8c1e 100644 --- a/bin/src/commands/new/error/bcne2_folder_exists.rs +++ b/bin/src/commands/new/error/bcne2_folder_exists.rs @@ -16,7 +16,7 @@ impl Code for FolderExists { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/modules/binarize/error/bbe3_binarize_failed.rs b/bin/src/modules/binarize/error/bbe3_binarize_failed.rs index 2e0db6e5..7bdd1501 100644 --- a/bin/src/modules/binarize/error/bbe3_binarize_failed.rs +++ b/bin/src/modules/binarize/error/bbe3_binarize_failed.rs @@ -15,7 +15,7 @@ impl Code for BinarizeFailed { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/modules/binarize/error/bbe4_missing_textures.rs b/bin/src/modules/binarize/error/bbe4_missing_textures.rs index 9a94122f..a76b546e 100644 --- a/bin/src/modules/binarize/error/bbe4_missing_textures.rs +++ b/bin/src/modules/binarize/error/bbe4_missing_textures.rs @@ -31,7 +31,7 @@ impl Code for MissingTextures { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/modules/binarize/error/bbe5_missing_material.rs b/bin/src/modules/binarize/error/bbe5_missing_material.rs index 1b220fab..e89c88fd 100644 --- a/bin/src/modules/binarize/error/bbe5_missing_material.rs +++ b/bin/src/modules/binarize/error/bbe5_missing_material.rs @@ -31,7 +31,7 @@ impl Code for MissingMaterials { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/modules/binarize/error/bbe6_missing_pdrive.rs b/bin/src/modules/binarize/error/bbe6_missing_pdrive.rs index 63f1c614..2df97055 100644 --- a/bin/src/modules/binarize/error/bbe6_missing_pdrive.rs +++ b/bin/src/modules/binarize/error/bbe6_missing_pdrive.rs @@ -13,7 +13,7 @@ impl Code for MissingPDrive { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/modules/binarize/error/bbe7_wine_not_found.rs b/bin/src/modules/binarize/error/bbe7_wine_not_found.rs index 3d8481a8..9a459c61 100644 --- a/bin/src/modules/binarize/error/bbe7_wine_not_found.rs +++ b/bin/src/modules/binarize/error/bbe7_wine_not_found.rs @@ -24,7 +24,7 @@ impl Code for WineNotFound { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/modules/binarize/error/bbw1_tools_not_found.rs b/bin/src/modules/binarize/error/bbw1_tools_not_found.rs index bb67d7c4..04c4cb96 100644 --- a/bin/src/modules/binarize/error/bbw1_tools_not_found.rs +++ b/bin/src/modules/binarize/error/bbw1_tools_not_found.rs @@ -32,7 +32,7 @@ impl Code for ToolsNotFound { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/modules/binarize/error/bbw2_platform_not_supported.rs b/bin/src/modules/binarize/error/bbw2_platform_not_supported.rs index 8e5c7619..dc84ce8c 100644 --- a/bin/src/modules/binarize/error/bbw2_platform_not_supported.rs +++ b/bin/src/modules/binarize/error/bbw2_platform_not_supported.rs @@ -22,7 +22,7 @@ impl Code for PlatformNotSupported { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/modules/hook/error/bhe1_script_not_found.rs b/bin/src/modules/hook/error/bhe1_script_not_found.rs index b9bcbb26..ced50f5d 100644 --- a/bin/src/modules/hook/error/bhe1_script_not_found.rs +++ b/bin/src/modules/hook/error/bhe1_script_not_found.rs @@ -35,7 +35,7 @@ impl Code for ScriptNotFound { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/modules/hook/error/bhe2_script_fatal.rs b/bin/src/modules/hook/error/bhe2_script_fatal.rs index c890c2ce..38ba2afe 100644 --- a/bin/src/modules/hook/error/bhe2_script_fatal.rs +++ b/bin/src/modules/hook/error/bhe2_script_fatal.rs @@ -16,7 +16,7 @@ impl Code for ScriptFatal { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/modules/hook/error/bhe3_parse_error.rs b/bin/src/modules/hook/error/bhe3_parse_error.rs index 2514b6b8..26780959 100644 --- a/bin/src/modules/hook/error/bhe3_parse_error.rs +++ b/bin/src/modules/hook/error/bhe3_parse_error.rs @@ -26,7 +26,7 @@ impl Code for RhaiParseError { fn diagnostic(&self) -> Option { let content = self.script.read_to_string().ok()?; Some( - Diagnostic::simple(self).with_label( + Diagnostic::from_code(self).with_label( Label::primary( self.script.clone(), get_offset(&content, self.location)..get_offset(&content, self.location), diff --git a/bin/src/modules/hook/error/bhe4_runtime_error.rs b/bin/src/modules/hook/error/bhe4_runtime_error.rs index 16432abe..7e0d52e8 100644 --- a/bin/src/modules/hook/error/bhe4_runtime_error.rs +++ b/bin/src/modules/hook/error/bhe4_runtime_error.rs @@ -26,7 +26,7 @@ impl Code for RuntimeError { fn diagnostic(&self) -> Option { let content = self.script.read_to_string().ok()?; Some( - Diagnostic::simple(self).with_label( + Diagnostic::from_code(self).with_label( Label::primary( self.script.clone(), get_offset(&content, self.location)..get_offset(&content, self.location), diff --git a/bin/src/modules/sign.rs b/bin/src/modules/sign.rs index 4252f631..70bcb0c6 100644 --- a/bin/src/modules/sign.rs +++ b/bin/src/modules/sign.rs @@ -172,7 +172,7 @@ impl Code for EmptyAddon { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/bin/src/modules/sqf.rs b/bin/src/modules/sqf.rs index a018fd43..72788635 100644 --- a/bin/src/modules/sqf.rs +++ b/bin/src/modules/sqf.rs @@ -196,7 +196,7 @@ impl Code for RequiresFutureVersion { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/libs/workspace/src/lint/mod.rs b/libs/workspace/src/lint/mod.rs index 0ef1e1ee..d397170c 100644 --- a/libs/workspace/src/lint/mod.rs +++ b/libs/workspace/src/lint/mod.rs @@ -260,7 +260,7 @@ impl Code for InvalidLintConfig { } fn diagnostic(&self) -> Option { - Some(Diagnostic::simple(self)) + Some(Diagnostic::from_code(self)) } } diff --git a/libs/workspace/src/reporting/diagnostic/mod.rs b/libs/workspace/src/reporting/diagnostic/mod.rs index 7db04677..1c6088e0 100644 --- a/libs/workspace/src/reporting/diagnostic/mod.rs +++ b/libs/workspace/src/reporting/diagnostic/mod.rs @@ -93,21 +93,6 @@ impl Diagnostic { Some(diag) } - pub fn simple(code: &impl Code) -> Self { - let mut diag = Self::new(code.ident(), code.message()).set_severity(code.severity()); - diag.link = code.link().map(std::string::ToString::to_string); - if let Some(note) = code.note() { - diag.notes.push(note); - } - if let Some(help) = code.help() { - diag.help.push(help); - } - if let Some(suggestion) = code.suggestion() { - diag.suggestions.push(suggestion); - } - diag - } - #[must_use] pub const fn set_severity(mut self, severity: Severity) -> Self { self.severity = severity;