Skip to content

Commit

Permalink
Move command-specific code into crate::command module
Browse files Browse the repository at this point in the history
  • Loading branch information
regexident committed Dec 13, 2023
1 parent 53165d3 commit 7b75315
Show file tree
Hide file tree
Showing 30 changed files with 59 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/configs/skywalking-eyes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ header:
paths:
- "src/**/*.rs"
paths-ignore:
- "src/dependencies/cycles/tri_color.rs"
- "src/command/dependencies/cycles/tri_color.rs"
12 changes: 9 additions & 3 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ use clap::Parser;

use crate::{
analyzer::{load_workspace, LoadOptions},
dependencies::command::Command as DependenciesCommand,
options::{general::Options as GeneralOptions, project::Options as ProjectOptions},
orphans::command::Command as OrphansCommand,
structure::command::Command as StructureCommand,
};

use self::{
dependencies::command::Command as DependenciesCommand,
orphans::command::Command as OrphansCommand, structure::command::Command as StructureCommand,
};

pub mod dependencies;
pub mod orphans;
pub mod structure;

#[derive(Parser, Clone, PartialEq, Eq, Debug)]
#[command(
name = "cargo-modules",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ use ra_ap_hir_ty::{self as hir_ty, db::HirDatabase as _, TyExt as _};
use ra_ap_ide_db::{self as ide_db};
use scopeguard::defer;

use crate::{
dependencies::{
graph::{Edge, EdgeKind, Graph, Node},
options::Options,
},
item::Item,
use crate::item::Item;

use super::{
graph::{Edge, EdgeKind, Graph, Node},
options::Options,
};

#[derive(Debug, Hash, Eq, PartialEq)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ use petgraph::graph::NodeIndex;
use ra_ap_hir as hir;
use ra_ap_ide::RootDatabase;

use crate::{
analyzer::LoadOptions,
dependencies::{
builder::Builder,
cycles::tri_color::{CycleDetector, TriColorDepthFirstSearch},
filter::Filter,
graph::Graph,
options::{LayoutAlgorithm, Options},
printer::Printer,
},
use crate::analyzer::LoadOptions;

use super::{
builder::Builder,
cycles::tri_color::{CycleDetector, TriColorDepthFirstSearch},
filter::Filter,
graph::Graph,
options::{LayoutAlgorithm, Options},
printer::Printer,
};

#[derive(Parser, Clone, PartialEq, Eq, Debug)]
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::{marker::PhantomData, ops::ControlFlow};
use bitvec::vec::BitVec;
use petgraph::graph::{IndexType, NodeIndex};

use crate::dependencies::graph::Graph as G;
use super::super::graph::Graph as G;

struct BitSet<T> {
vec: BitVec,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ use ra_ap_hir::{self as hir};
use ra_ap_ide_db::RootDatabase;
use ra_ap_syntax::ast;

use crate::{
analyzer,
dependencies::{
graph::{Edge, EdgeKind, Graph},
options::Options,
walker::GraphWalker,
},
use crate::analyzer;

use super::{
graph::{Edge, EdgeKind, Graph},
options::Options,
walker::GraphWalker,
};

#[derive(Debug)]
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ use petgraph::{
use ra_ap_hir as hir;
use ra_ap_ide::RootDatabase;

use crate::{
analyzer,
dependencies::{
graph::{Edge, EdgeKind, Graph, Node},
options::Options,
theme::{edge_styles, node_styles},
},
item::visibility::ItemVisibility,
use crate::{analyzer, item::visibility::ItemVisibility};

use super::{
graph::{Edge, EdgeKind, Graph, Node},
options::Options,
theme::{edge_styles, node_styles},
};

const INDENTATION: &str = " ";
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions src/orphans/command.rs → src/command/orphans/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ use ra_ap_hir as hir;
use ra_ap_ide::RootDatabase;
use ra_ap_vfs::Vfs;

use crate::{
analyzer::{self, LoadOptions},
orphans::{options::Options, printer::Printer},
};
use crate::analyzer::{self, LoadOptions};

use super::{options::Options, printer::Printer};

use super::scanner::Scanner;

Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 1 addition & 4 deletions src/orphans/printer.rs → src/command/orphans/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
use ra_ap_ide::RootDatabase;

use crate::{
orphans::orphan::Orphan,
orphans::{options::Options, theme::styles},
};
use super::{options::Options, orphan::Orphan, theme::styles};

pub struct Printer<'a> {
#[allow(dead_code)]
Expand Down
4 changes: 3 additions & 1 deletion src/orphans/scanner.rs → src/command/orphans/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ use ra_ap_hir::{self as hir, Crate};
use ra_ap_ide_db::RootDatabase;
use ra_ap_vfs::Vfs;

use crate::{analyzer, orphans::orphan::Orphan};
use crate::analyzer;

use super::orphan::Orphan;

#[derive(Debug)]
pub struct Scanner<'a> {
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions src/structure/builder.rs → src/command/structure/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ use ra_ap_hir::{self as hir, Crate};
use ra_ap_ide_db::RootDatabase;
use scopeguard::defer;

use crate::{
item::Item,
structure::{options::Options, tree::Tree},
};
use crate::item::Item;

use super::{options::Options, tree::Tree};

#[derive(Debug)]
pub struct Builder<'a> {
Expand Down
7 changes: 3 additions & 4 deletions src/structure/command.rs → src/command/structure/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ use log::trace;
use ra_ap_hir as hir;
use ra_ap_ide::RootDatabase;

use crate::{
analyzer::LoadOptions,
structure::{builder::Builder, filter::Filter, options::Options, printer::Printer},
};
use crate::analyzer::LoadOptions;

use super::{builder::Builder, filter::Filter, options::Options, printer::Printer};

#[derive(Parser, Clone, PartialEq, Eq, Debug)]
pub struct Command {
Expand Down
7 changes: 3 additions & 4 deletions src/structure/filter.rs → src/command/structure/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ use ra_ap_hir::{self as hir};
use ra_ap_ide_db::RootDatabase;
use ra_ap_syntax::ast;

use crate::{
analyzer,
structure::{options::Options, tree::Tree},
};
use crate::analyzer;

use super::{options::Options, tree::Tree};

#[derive(Debug)]
pub struct Filter<'a> {
Expand Down
File renamed without changes.
14 changes: 6 additions & 8 deletions src/structure/printer.rs → src/command/structure/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ use std::fmt;

use ra_ap_ide::RootDatabase;

use crate::{
analyzer,
item::visibility::ItemVisibility,
structure::{
options::{Options, SortBy},
theme::styles,
tree::Tree,
},
use crate::{analyzer, item::visibility::ItemVisibility};

use super::{
options::{Options, SortBy},
theme::styles,
tree::Tree,
};

#[derive(Debug)]
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
pub mod command;
pub mod options;

pub mod dependencies;
pub mod orphans;
pub mod structure;

pub(crate) mod analyzer;
pub(crate) mod colors;
pub(crate) mod item;

0 comments on commit 7b75315

Please sign in to comment.