Skip to content

Commit

Permalink
Extract modules crate::command::structure::{tree,builder} to `crate…
Browse files Browse the repository at this point in the history
…::tree`
  • Loading branch information
regexident committed Dec 13, 2023
1 parent 7b75315 commit 90fdb23
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
2 changes: 0 additions & 2 deletions src/command/structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

pub mod options;

pub(crate) mod builder;
pub(super) mod command;
pub(super) mod filter;
pub(crate) mod printer;
pub(super) mod theme;
pub(super) mod tree;
6 changes: 3 additions & 3 deletions src/command/structure/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use log::trace;
use ra_ap_hir as hir;
use ra_ap_ide::RootDatabase;

use crate::analyzer::LoadOptions;
use crate::{analyzer::LoadOptions, tree::TreeBuilder};

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

#[derive(Parser, Clone, PartialEq, Eq, Debug)]
pub struct Command {
Expand All @@ -30,7 +30,7 @@ impl Command {
pub fn run(self, krate: hir::Crate, db: &RootDatabase) -> anyhow::Result<()> {
trace!("Building tree ...");

let builder = Builder::new(&self.options, db, krate);
let builder = TreeBuilder::new(db, krate);
let tree = builder.build()?;

trace!("Filtering tree ...");
Expand Down
4 changes: 2 additions & 2 deletions src/command/structure/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use ra_ap_hir::{self as hir};
use ra_ap_ide_db::RootDatabase;
use ra_ap_syntax::ast;

use crate::analyzer;
use crate::{analyzer, tree::Tree};

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

#[derive(Debug)]
pub struct Filter<'a> {
Expand Down
3 changes: 1 addition & 2 deletions src/command/structure/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ use std::fmt;

use ra_ap_ide::RootDatabase;

use crate::{analyzer, item::visibility::ItemVisibility};
use crate::{analyzer, item::visibility::ItemVisibility, tree::Tree};

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

#[derive(Debug)]
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ pub mod options;
pub(crate) mod analyzer;
pub(crate) mod colors;
pub(crate) mod item;
pub(crate) mod tree;
4 changes: 4 additions & 0 deletions src/command/structure/tree.rs → src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

use crate::item::Item;

mod builder;

pub(crate) use self::builder::TreeBuilder;

#[derive(Clone, PartialEq, Debug)]
pub struct Tree {
pub item: Item,
Expand Down
14 changes: 5 additions & 9 deletions src/command/structure/builder.rs → src/tree/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@ use ra_ap_hir::{self as hir, Crate};
use ra_ap_ide_db::RootDatabase;
use scopeguard::defer;

use crate::item::Item;

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

#[derive(Debug)]
pub struct Builder<'a> {
#[allow(dead_code)]
options: &'a Options,
pub struct TreeBuilder<'a> {
db: &'a RootDatabase,
krate: hir::Crate,
}

impl<'a> Builder<'a> {
pub fn new(options: &'a Options, db: &'a RootDatabase, krate: hir::Crate) -> Self {
Self { options, db, krate }
impl<'a> TreeBuilder<'a> {
pub fn new(db: &'a RootDatabase, krate: hir::Crate) -> Self {
Self { db, krate }
}

pub fn build(mut self) -> anyhow::Result<Tree> {
Expand Down

0 comments on commit 90fdb23

Please sign in to comment.