Skip to content

Commit

Permalink
refactoring (dependencies processor)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-huegel committed Dec 22, 2023
1 parent 2ed5841 commit 4a7f44d
Show file tree
Hide file tree
Showing 23 changed files with 1,033 additions and 617 deletions.
86 changes: 67 additions & 19 deletions modules.dot
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,83 @@ label=""
color="#ffffff"
style="filled"
"::app_builder"[label="app_builder",style="filled",fillcolor="#ffffff"]
"::colors"[label="colors",style="filled",fillcolor="#ffffff"]
"::dependencies"[label="dependencies",style="filled",fillcolor="#ffffff"]
"::dependencies_graph"[label="dependencies_graph",style="filled",fillcolor="#ffffff"]
"::dependencies_parser"[label="dependencies_parser",style="filled",fillcolor="#ffffff"]
"::dependency_components"[label="dependency_components",style="filled",fillcolor="#ffffff"]
"::dot_formatter"[label="dot_formatter",style="filled",fillcolor="#ffffff"]
subgraph cluster____dependencies_processor {
label="dependencies_processor"
color="#eeeeee"
style="filled"
"::dependencies_processor::mod"[label="mod",style="filled",fillcolor="#8393eb"]
subgraph cluster____dependencies_processor___rust_processor {
label="rust_processor"
color="#dddddd"
style="filled"
"::dependencies_processor::rust_processor::dependency_expander"[label="dependency_expander",style="filled",fillcolor="#eecad4"]
"::dependencies_processor::rust_processor::mod"[label="mod",style="filled",fillcolor="#eecad4"]
"::dependencies_processor::rust_processor::target_computer"[label="target_computer",style="filled",fillcolor="#eecad4"]
}
}
"::files_reader"[label="files_reader",style="filled",fillcolor="#ffffff"]
subgraph cluster____formatter {
label="formatter"
color="#eeeeee"
style="filled"
"::formatter::colors"[label="colors",style="filled",fillcolor="#dcb0ae"]
"::formatter::dot_formatter"[label="dot_formatter",style="filled",fillcolor="#dcb0ae"]
"::formatter::mod"[label="mod",style="filled",fillcolor="#dcb0ae"]
}
"::lib"[label="lib",style="filled",fillcolor="#ffffff"]
"::main"[label="main",style="filled",fillcolor="#ffffff"]
"::nonempty_vec"[label="nonempty_vec",style="filled",fillcolor="#ffffff"]
subgraph cluster____parser {
label="parser"
color="#eeeeee"
style="filled"
"::parser::mod"[label="mod",style="filled",fillcolor="#aaf6a8"]
"::parser::rust_parser"[label="rust_parser",style="filled",fillcolor="#aaf6a8"]
}
"::trie"[label="trie",style="filled",fillcolor="#ffffff"]
}
"::app_builder" -> "::dependencies_graph"
"::app_builder" -> "::dot_formatter"
"::app_builder" -> "::dependencies_processor::rust_processor::target_computer"
"::app_builder" -> "::files_reader"
"::app_builder" -> "std"
"::dependencies_graph" -> "::dependency_components"
"::app_builder" -> "::formatter::dot_formatter"
"::app_builder" -> "::formatter::mod"
"::app_builder" -> "::parser::rust_parser"
"::app_builder" -> "::std"
"::dependencies_graph" -> "::dependencies"
"::dependencies_graph" -> "::trie"
"::dependencies_parser" -> "::dependency_components"
"::dependencies_parser" -> "lazy_static"
"::dependencies_parser" -> "regex"
"::dependencies_parser" -> "std"
"::dot_formatter" -> "::colors"
"::dot_formatter" -> "::dependencies_graph"
"::dot_formatter" -> "::dependency_components"
"::dot_formatter" -> "std"
"::dependencies_processor::mod" -> "::dependencies"
"::dependencies_processor::mod" -> "::dependencies_graph"
"::dependencies_processor::rust_processor::dependency_expander" -> "::dependencies"
"::dependencies_processor::rust_processor::dependency_expander" -> "::dependencies_processor::rust_processor::mod"
"::dependencies_processor::rust_processor::dependency_expander" -> "::std"
"::dependencies_processor::rust_processor::mod" -> "::dependencies"
"::dependencies_processor::rust_processor::target_computer" -> "::dependencies"
"::dependencies_processor::rust_processor::target_computer" -> "::dependencies_graph"
"::dependencies_processor::rust_processor::target_computer" -> "::dependencies_processor::mod"
"::dependencies_processor::rust_processor::target_computer" -> "::dependencies_processor::rust_processor::dependency_expander"
"::dependencies_processor::rust_processor::target_computer" -> "::dependencies_processor::rust_processor::mod"
"::dependencies_processor::rust_processor::target_computer" -> "::trie"
"::files_reader" -> "::dependencies_graph"
"::files_reader" -> "::dependencies_parser"
"::files_reader" -> "std"
"::files_reader" -> "::parser::mod"
"::files_reader" -> "::std"
"::formatter::dot_formatter" -> "::dependencies"
"::formatter::dot_formatter" -> "::dependencies_graph"
"::formatter::dot_formatter" -> "::dependencies_processor::mod"
"::formatter::dot_formatter" -> "::formatter::colors"
"::formatter::dot_formatter" -> "::formatter::mod"
"::formatter::dot_formatter" -> "::std"
"::formatter::mod" -> "::dependencies_graph"
"::formatter::mod" -> "::dependencies_processor::mod"
"::main" -> "::app_builder"
"::main" -> "std"
"::trie" -> "std"
"::main" -> "::std"
"::parser::mod" -> "::dependencies"
"::parser::rust_parser" -> "::dependencies"
"::parser::rust_parser" -> "::lazy_static"
"::parser::rust_parser" -> "::parser::mod"
"::parser::rust_parser" -> "::regex"
"::parser::rust_parser" -> "::std"
"::trie" -> "::std"
}

Binary file modified modules.pdf
Binary file not shown.
Binary file modified modules.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 11 additions & 6 deletions src/app_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,22 @@
* This file is part of Cargo Graphmod.
* SPDX-License-Identifier: GPL-3.0-only
*/

use std::path::Path;

use crate::{dependencies_graph::DependenciesGraph, files_reader, dot_formatter};
use crate::{
dependencies_graph::DependenciesGraph,
dependencies_processor::rust_processor::target_computer::RustDependencyProcessor,
files_reader,
formatter::{dot_formatter::DotFormatter, Formatter},
parser::rust_parser::RustParser,
};

pub fn run_app(directory: &str, pkg_name: &str) -> String {
let path = Path::new(directory);
let skip_length = path.iter().count();
let mut trie = DependenciesGraph::new();
files_reader::read_files(path, &mut trie, skip_length, pkg_name).expect(
"Unable to read ./src; please consider changing to the root directory of your package."
files_reader::build_dependencies_trie::<RustParser>(path, &mut trie, skip_length).expect(
"Unable to read ./src; please consider changing to the root directory of your package.",
);
dot_formatter::show(&trie)
}
DotFormatter::show::<RustDependencyProcessor>(&trie, pkg_name)
}
16 changes: 16 additions & 0 deletions src/dependencies.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright 2023 Thomas Hügel.
* This file is part of Cargo Graphmod.
* SPDX-License-Identifier: GPL-3.0-only
*/

#[derive(Clone, Debug, PartialEq)]
pub struct FilePath(pub Vec<String>);

#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct DependencyPath(pub Vec<String>);

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Dependencies {
pub dependencies: Vec<DependencyPath>,
}
8 changes: 6 additions & 2 deletions src/dependencies_graph.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use crate::{dependencies::DependencyPath, trie::Trie};

/**
* Copyright 2023 Thomas Hügel.
* This file is part of Cargo Graphmod.
* SPDX-License-Identifier: GPL-3.0-only
*/
use crate::{dependency_components::DependencyComponents, trie::Trie};

pub type DependenciesGraph = Trie<String, Vec<DependencyComponents>>;
/**
* At each node, the value represents the full path from the root, and the dependencies read at this node.
*/
pub type DependenciesGraph = Trie<String, Vec<DependencyPath>>;
Loading

0 comments on commit 4a7f44d

Please sign in to comment.