From 2e7c1433b3eb3a974b1274263493ee937829147f Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Tue, 2 Mar 2021 10:25:42 +0800 Subject: [PATCH] refactor: fix naming issue for struct --- core_model/src/coco_settings.rs | 4 ++-- plugins/coco_struct/Cargo.toml | 2 +- plugins/coco_struct/src/lib.rs | 6 +++--- .../src/{struct_analysis.rs => struct_plugin.rs} | 4 ++-- src/app/visual/output_static.rs | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) rename plugins/coco_struct/src/{struct_analysis.rs => struct_plugin.rs} (96%) diff --git a/core_model/src/coco_settings.rs b/core_model/src/coco_settings.rs index 7dd503b4..e0690da8 100644 --- a/core_model/src/coco_settings.rs +++ b/core_model/src/coco_settings.rs @@ -65,7 +65,7 @@ impl Settings { Settings::reporter(Some("framework")) } - pub fn struct_analysis() -> PathBuf { - Settings::reporter(Some("struct_analysis")) + pub fn struct_dir() -> PathBuf { + Settings::reporter(Some("struct")) } } diff --git a/plugins/coco_struct/Cargo.toml b/plugins/coco_struct/Cargo.toml index 87310863..7192ba54 100644 --- a/plugins/coco_struct/Cargo.toml +++ b/plugins/coco_struct/Cargo.toml @@ -35,5 +35,5 @@ path = "../../core_model" path = "../../plugin_interface" [lib] -name = "coco_struct_analysis" +name = "coco_struct" crate-type = ["cdylib"] diff --git a/plugins/coco_struct/src/lib.rs b/plugins/coco_struct/src/lib.rs index d3409bb7..5c89d69d 100644 --- a/plugins/coco_struct/src/lib.rs +++ b/plugins/coco_struct/src/lib.rs @@ -12,7 +12,7 @@ pub mod coco_struct; pub mod ctags_opt; pub mod ctags_parser; pub mod plantuml_render; -pub mod struct_analysis; +pub mod struct_plugin; pub struct CocoStructAnalysis {} @@ -34,7 +34,7 @@ impl PluginInterface for CocoStructAnalysis { fn on_plugin_unload(&self) {} fn execute(&self, config: CocoConfig) { - struct_analysis::execute(config); + struct_plugin::execute(config); } } @@ -85,7 +85,7 @@ pub fn plugin() -> Box { #[cfg(test)] mod tests { use crate::coco_struct::ClassInfo; - use crate::struct_analysis::execute; + use crate::struct_plugin::execute; use core_model::{CocoConfig, RepoConfig}; use std::fs::File; use std::io::Read; diff --git a/plugins/coco_struct/src/struct_analysis.rs b/plugins/coco_struct/src/struct_plugin.rs similarity index 96% rename from plugins/coco_struct/src/struct_analysis.rs rename to plugins/coco_struct/src/struct_plugin.rs index 8b62f657..24d5e09e 100644 --- a/plugins/coco_struct/src/struct_analysis.rs +++ b/plugins/coco_struct/src/struct_plugin.rs @@ -53,13 +53,13 @@ fn count_thread(origin_files: &Vec) -> usize { fn write_to_json_file(url_str: &str, result: &String) { let file_name = url_format::json_filename(url_str); - let output_file = Settings::struct_analysis().join(file_name); + let output_file = Settings::struct_dir().join(file_name); fs::write(output_file, result).expect("cannot write file"); } fn write_to_puml_file(url_str: &str, classes: &Vec) { let file_name = url_format::puml_filename(url_str); - let output_file = Settings::struct_analysis().join(file_name); + let output_file = Settings::struct_dir().join(file_name); let result = PlantUmlRender::render(classes); fs::write(output_file, result).expect("cannot write file"); } diff --git a/src/app/visual/output_static.rs b/src/app/visual/output_static.rs index 7373f1fa..98e67247 100644 --- a/src/app/visual/output_static.rs +++ b/src/app/visual/output_static.rs @@ -40,6 +40,6 @@ fn export_reporter>(path: &P, project: String) { let _ = fs::copy(cloc, &data_dir.join("cloc.json")); // struct analysis - let structs = Settings::struct_analysis().join(format!("{}.json", project)); + let structs = Settings::struct_dir().join(format!("{}.json", project)); let _ = fs::copy(structs, &data_dir.join("struct-analysis.json")); }