-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
84 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use crate::project_structure_analyzer::StructureAnalyzer; | ||
use crate::psa_project::Project; | ||
|
||
pub struct JvmProjectStructureAnalyzer {} | ||
|
||
impl Default for JvmProjectStructureAnalyzer { | ||
fn default() -> Self { | ||
JvmProjectStructureAnalyzer {} | ||
} | ||
} | ||
|
||
impl StructureAnalyzer for JvmProjectStructureAnalyzer { | ||
fn analysis(&self, _project_path: &str) -> Project { | ||
Project::new("test", "test/path") | ||
} | ||
|
||
fn is_related(&self) -> bool { | ||
true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod jvm_psa; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
pub mod pas_content_root; | ||
pub mod project_structure_analyzer; | ||
pub mod psa_facet; | ||
pub mod psa_library; | ||
pub mod psa_module; | ||
pub mod psa_project; | ||
|
||
pub mod jvm; | ||
|
||
pub use pas_content_root::ContentRoot; | ||
pub use project_structure_analyzer::ProjectAnalyzer; | ||
pub use psa_facet::Facet; | ||
pub use psa_library::Library; | ||
pub use psa_library::LibraryScope; | ||
pub use psa_module::Module; | ||
pub use psa_project::Project; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::jvm::jvm_psa::JvmProjectStructureAnalyzer; | ||
use crate::psa_project::Project; | ||
|
||
pub trait StructureAnalyzer { | ||
fn analysis(&self, project_path: &str) -> Project; | ||
fn is_related(&self) -> bool; | ||
} | ||
|
||
pub struct ProjectAnalyzer { | ||
analyzers: Vec<Box<dyn StructureAnalyzer>>, | ||
} | ||
|
||
impl ProjectAnalyzer { | ||
pub fn run(&self, path: &str) -> Vec<Project> { | ||
let mut projects = Vec::new(); | ||
for analyzer in self.analyzers.iter() { | ||
match analyzer.is_related() { | ||
true => projects.push(analyzer.analysis(path)), | ||
_ => continue, | ||
} | ||
} | ||
projects | ||
} | ||
} | ||
|
||
impl Default for ProjectAnalyzer { | ||
fn default() -> Self { | ||
ProjectAnalyzer { | ||
analyzers: vec![Box::new(JvmProjectStructureAnalyzer::default())], | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::ProjectAnalyzer; | ||
|
||
#[test] | ||
fn should_run_analyzer() { | ||
let analyzer = ProjectAnalyzer::default(); | ||
|
||
let projects = analyzer.run(""); | ||
|
||
assert_eq!(projects.len(), 1); | ||
assert_eq!(projects.get(0).unwrap().name, "test".to_string()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters