Skip to content

Commit

Permalink
Merge #11639
Browse files Browse the repository at this point in the history
11639: internal: Re-arrange ide_db modules r=Veykril a=Veykril

Thins out the `helpers` module by giving some items more appropriate places to live
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
  • Loading branch information
bors[bot] and Veykril authored Mar 6, 2022
2 parents b953812 + 93b09ca commit 5fae65d
Show file tree
Hide file tree
Showing 86 changed files with 670 additions and 683 deletions.
1 change: 1 addition & 0 deletions crates/hir/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ fn resolve_doc_path(
};

let modpath = {
// FIXME: this is not how we should get a mod path here
let ast_path = ast::SourceFile::parse(&format!("type T = {};", link))
.syntax_node()
.descendants()
Expand Down
2 changes: 1 addition & 1 deletion crates/ide/src/expand_macro.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use hir::Semantics;
use ide_db::{
helpers::{insert_whitespace_into_node::insert_ws_into, pick_best_token},
helpers::pick_best_token, syntax_helpers::insert_whitespace_into_node::insert_ws_into,
RootDatabase,
};
use syntax::{ast, ted, AstNode, NodeOrToken, SyntaxKind, SyntaxNode, T};
Expand Down
2 changes: 1 addition & 1 deletion crates/ide/src/folding_ranges.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ide_db::helpers::node_ext::vis_eq;
use ide_db::syntax_helpers::node_ext::vis_eq;
use rustc_hash::FxHashSet;

use syntax::{
Expand Down
5 changes: 2 additions & 3 deletions crates/ide/src/highlight_related.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use hir::Semantics;
use ide_db::{
base_db::{FileId, FilePosition},
defs::{Definition, IdentClass},
helpers::{
for_each_break_and_continue_expr, for_each_tail_expr, node_ext::walk_expr, pick_best_token,
},
helpers::pick_best_token,
search::{FileReference, ReferenceCategory, SearchScope},
syntax_helpers::node_ext::{for_each_break_and_continue_expr, for_each_tail_expr, walk_expr},
RootDatabase,
};
use rustc_hash::FxHashSet;
Expand Down
3 changes: 2 additions & 1 deletion crates/ide/src/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ use hir::{HasSource, Semantics};
use ide_db::{
base_db::FileRange,
defs::{Definition, IdentClass},
helpers::{pick_best_token, FamousDefs},
famous_defs::FamousDefs,
helpers::pick_best_token,
FxIndexSet, RootDatabase,
};
use itertools::Itertools;
Expand Down
6 changes: 2 additions & 4 deletions crates/ide/src/hover/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ use hir::{AsAssocItem, AttributeTemplate, HasAttrs, HasSource, HirDisplay, Seman
use ide_db::{
base_db::SourceDatabase,
defs::Definition,
helpers::{
generated_lints::{CLIPPY_LINTS, DEFAULT_LINTS, FEATURES},
FamousDefs,
},
famous_defs::FamousDefs,
generated::lints::{CLIPPY_LINTS, DEFAULT_LINTS, FEATURES},
RootDatabase,
};
use itertools::Itertools;
Expand Down
2 changes: 1 addition & 1 deletion crates/ide/src/inlay_hints.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use either::Either;
use hir::{known, Callable, HasVisibility, HirDisplay, Semantics, TypeInfo};
use ide_db::{base_db::FileRange, helpers::FamousDefs, RootDatabase};
use ide_db::{base_db::FileRange, famous_defs::FamousDefs, RootDatabase};
use itertools::Itertools;
use stdx::to_lower_snake_case;
use syntax::{
Expand Down
2 changes: 1 addition & 1 deletion crates/ide/src/join_lines.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ide_assists::utils::extract_trivial_expression;
use ide_db::helpers::node_ext::expr_as_name_ref;
use ide_db::syntax_helpers::node_ext::expr_as_name_ref;
use itertools::Itertools;
use syntax::{
ast::{self, AstNode, AstToken, IsString},
Expand Down
2 changes: 1 addition & 1 deletion crates/ide/src/syntax_highlighting/format.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Syntax highlighting for format macro strings.
use ide_db::{
helpers::format_string::{is_format_string, lex_format_specifiers, FormatSpecifier},
syntax_helpers::format_string::{is_format_string, lex_format_specifiers, FormatSpecifier},
SymbolKind,
};
use syntax::{ast, TextRange};
Expand Down
2 changes: 1 addition & 1 deletion crates/ide/src/syntax_highlighting/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use hir::{AsAssocItem, HasVisibility, Semantics};
use ide_db::{
defs::{Definition, IdentClass, NameClass, NameRefClass},
helpers::FamousDefs,
famous_defs::FamousDefs,
RootDatabase, SymbolKind,
};
use rustc_hash::FxHashMap;
Expand Down
3 changes: 1 addition & 2 deletions crates/ide/src/syntax_highlighting/inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use std::mem;
use either::Either;
use hir::{InFile, Semantics};
use ide_db::{
active_parameter::ActiveParameter, defs::Definition, helpers::rust_doc::is_rust_fence,
SymbolKind,
active_parameter::ActiveParameter, defs::Definition, rust_doc::is_rust_fence, SymbolKind,
};
use syntax::{
ast::{self, AstNode, IsString, QuoteOffsets},
Expand Down
2 changes: 1 addition & 1 deletion crates/ide_assists/src/assist_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! module, and we use to statically check that we only produce snippet
//! assists if we are allowed to.

use ide_db::helpers::{insert_use::InsertUseConfig, SnippetCap};
use ide_db::{imports::insert_use::InsertUseConfig, SnippetCap};

use crate::AssistKind;

Expand Down
2 changes: 1 addition & 1 deletion crates/ide_assists/src/assist_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::mem;
use hir::Semantics;
use ide_db::{
base_db::{AnchoredPathBuf, FileId, FileRange},
helpers::SnippetCap,
SnippetCap,
};
use ide_db::{
label::Label,
Expand Down
2 changes: 1 addition & 1 deletion crates/ide_assists/src/handlers/add_explicit_type.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use hir::HirDisplay;
use ide_db::helpers::node_ext::walk_ty;
use ide_db::syntax_helpers::node_ext::walk_ty;
use syntax::ast::{self, AstNode, LetStmt, Param};

use crate::{AssistContext, AssistId, AssistKind, Assists};
Expand Down
4 changes: 3 additions & 1 deletion crates/ide_assists/src/handlers/add_missing_impl_members.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use hir::HasSource;
use ide_db::{helpers::insert_whitespace_into_node::insert_ws_into, traits::resolve_target_trait};
use ide_db::{
syntax_helpers::insert_whitespace_into_node::insert_ws_into, traits::resolve_target_trait,
};
use syntax::ast::{self, make, AstNode};

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/ide_assists/src/handlers/add_missing_match_arms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::iter::{self, Peekable};

use either::Either;
use hir::{Adt, Crate, HasAttrs, HasSource, ModuleDef, Semantics};
use ide_db::helpers::{mod_path_to_ast, FamousDefs};
use ide_db::RootDatabase;
use ide_db::{famous_defs::FamousDefs, helpers::mod_path_to_ast};
use itertools::Itertools;
use syntax::ast::{self, make, AstNode, HasName, MatchArmList, MatchExpr, Pat};

Expand Down
10 changes: 6 additions & 4 deletions crates/ide_assists/src/handlers/auto_import.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use ide_db::helpers::{
import_assets::{ImportAssets, ImportCandidate},
insert_use::{insert_use, ImportScope},
mod_path_to_ast,
use ide_db::{
helpers::mod_path_to_ast,
imports::{
import_assets::{ImportAssets, ImportCandidate},
insert_use::{insert_use, ImportScope},
},
};
use syntax::{ast, AstNode, NodeOrToken, SyntaxElement};

Expand Down
7 changes: 3 additions & 4 deletions crates/ide_assists/src/handlers/convert_bool_then.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use hir::{known, AsAssocItem, Semantics};
use ide_db::{
helpers::{
for_each_tail_expr,
node_ext::{block_as_lone_tail, is_pattern_cond, preorder_expr},
FamousDefs,
famous_defs::FamousDefs,
syntax_helpers::node_ext::{
block_as_lone_tail, for_each_tail_expr, is_pattern_cond, preorder_expr,
},
RootDatabase,
};
Expand Down
5 changes: 1 addition & 4 deletions crates/ide_assists/src/handlers/convert_into_to_from.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use ide_db::{
helpers::{mod_path_to_ast, FamousDefs},
traits::resolve_target_trait,
};
use ide_db::{famous_defs::FamousDefs, helpers::mod_path_to_ast, traits::resolve_target_trait};
use syntax::ast::{self, AstNode, HasName};

use crate::{AssistContext, AssistId, AssistKind, Assists};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use hir::known;
use ide_db::helpers::FamousDefs;
use ide_db::famous_defs::FamousDefs;
use stdx::format_to;
use syntax::{
ast::{self, edit_in_place::Indent, make, HasArgList, HasLoopBody},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::iter::once;

use ide_db::helpers::node_ext::{is_pattern_cond, single_let};
use ide_db::syntax_helpers::node_ext::{is_pattern_cond, single_let};
use syntax::{
ast::{
self,
Expand Down
2 changes: 1 addition & 1 deletion crates/ide_assists/src/handlers/convert_while_to_loop.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::iter::once;

use ide_db::helpers::node_ext::is_pattern_cond;
use ide_db::syntax_helpers::node_ext::is_pattern_cond;
use syntax::{
ast::{
self,
Expand Down
10 changes: 4 additions & 6 deletions crates/ide_assists/src/handlers/extract_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ use either::Either;
use hir::{HirDisplay, InFile, Local, ModuleDef, Semantics, TypeInfo};
use ide_db::{
defs::{Definition, NameRefClass},
helpers::{
insert_use::{insert_use, ImportScope},
mod_path_to_ast,
node_ext::{preorder_expr, walk_expr, walk_pat, walk_patterns_in_expr},
FamousDefs,
},
famous_defs::FamousDefs,
helpers::mod_path_to_ast,
imports::insert_use::{insert_use, ImportScope},
search::{FileReference, ReferenceCategory, SearchScope},
syntax_helpers::node_ext::{preorder_expr, walk_expr, walk_pat, walk_patterns_in_expr},
FxIndexSet, RootDatabase,
};
use itertools::Itertools;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ use either::Either;
use hir::{Module, ModuleDef, Name, Variant};
use ide_db::{
defs::Definition,
helpers::{
insert_use::{insert_use, ImportScope, InsertUseConfig},
mod_path_to_ast,
},
helpers::mod_path_to_ast,
imports::insert_use::{insert_use, ImportScope, InsertUseConfig},
search::FileReference,
RootDatabase,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/ide_assists/src/handlers/extract_type_alias.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use either::Either;
use ide_db::helpers::node_ext::walk_ty;
use ide_db::syntax_helpers::node_ext::walk_ty;
use itertools::Itertools;
use syntax::{
ast::{self, edit::IndentLevel, AstNode, HasGenericParams, HasName},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ide_db::{helpers::FamousDefs, RootDatabase};
use ide_db::{famous_defs::FamousDefs, RootDatabase};
use syntax::ast::{self, AstNode, HasName};

use crate::{AssistContext, AssistId, AssistKind, Assists};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ide_db::helpers::FamousDefs;
use ide_db::famous_defs::FamousDefs;
use itertools::Itertools;
use stdx::format_to;
use syntax::{
Expand Down
2 changes: 1 addition & 1 deletion crates/ide_assists/src/handlers/generate_deref.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::fmt::Display;

use ide_db::{helpers::FamousDefs, RootDatabase};
use ide_db::{famous_defs::FamousDefs, RootDatabase};
use syntax::{
ast::{self, HasName},
AstNode, SyntaxNode,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use ide_db::helpers::FamousDefs;
use ide_db::RootDatabase;
use ide_db::{famous_defs::FamousDefs, RootDatabase};
use syntax::ast::{self, AstNode, HasName};

use crate::{utils::generate_trait_impl_text, AssistContext, AssistId, AssistKind, Assists};
Expand Down
5 changes: 2 additions & 3 deletions crates/ide_assists/src/handlers/generate_function.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use rustc_hash::{FxHashMap, FxHashSet};

use hir::{HasSource, HirDisplay, Module, Semantics, TypeInfo};
use ide_db::helpers::FamousDefs;
use ide_db::{
base_db::FileId,
defs::{Definition, NameRefClass},
helpers::SnippetCap,
RootDatabase,
famous_defs::FamousDefs,
RootDatabase, SnippetCap,
};
use stdx::to_lower_snake_case;
use syntax::{
Expand Down
2 changes: 1 addition & 1 deletion crates/ide_assists/src/handlers/generate_getter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ide_db::helpers::FamousDefs;
use ide_db::famous_defs::FamousDefs;
use stdx::{format_to, to_lower_snake_case};
use syntax::ast::{self, AstNode, HasName, HasVisibility};

Expand Down
3 changes: 2 additions & 1 deletion crates/ide_assists/src/handlers/inline_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use hir::{db::HirDatabase, PathResolution, Semantics, TypeInfo};
use ide_db::{
base_db::{FileId, FileRange},
defs::Definition,
helpers::{insert_use::remove_path_if_in_use_stmt, node_ext::expr_as_name_ref},
imports::insert_use::remove_path_if_in_use_stmt,
path_transform::PathTransform,
search::{FileReference, SearchScope},
syntax_helpers::node_ext::expr_as_name_ref,
RootDatabase,
};
use itertools::{izip, Itertools};
Expand Down
2 changes: 1 addition & 1 deletion crates/ide_assists/src/handlers/invert_if.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ide_db::helpers::node_ext::is_pattern_cond;
use ide_db::syntax_helpers::node_ext::is_pattern_cond;
use syntax::{
ast::{self, AstNode},
T,
Expand Down
2 changes: 1 addition & 1 deletion crates/ide_assists/src/handlers/merge_imports.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ide_db::helpers::merge_imports::{try_merge_imports, try_merge_trees, MergeBehavior};
use ide_db::imports::merge_imports::{try_merge_imports, try_merge_trees, MergeBehavior};
use syntax::{algo::neighbor, ast, ted, AstNode};

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/ide_assists/src/handlers/promote_local_to_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use hir::{HirDisplay, ModuleDef, PathResolution, Semantics};
use ide_db::{
assists::{AssistId, AssistKind},
defs::Definition,
helpers::node_ext::preorder_expr,
syntax_helpers::node_ext::preorder_expr,
RootDatabase,
};
use stdx::to_upper_snake_case;
Expand Down
2 changes: 1 addition & 1 deletion crates/ide_assists/src/handlers/qualify_method_call.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use hir::{ItemInNs, ModuleDef};
use ide_db::{
assists::{AssistId, AssistKind},
helpers::import_assets::item_for_path_search,
imports::import_assets::item_for_path_search,
};
use syntax::{ast, AstNode};

Expand Down
8 changes: 4 additions & 4 deletions crates/ide_assists/src/handlers/qualify_path.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::iter;

use hir::AsAssocItem;
use ide_db::helpers::{
import_assets::{ImportCandidate, LocatedImport},
mod_path_to_ast,
};
use ide_db::RootDatabase;
use ide_db::{
helpers::mod_path_to_ast,
imports::import_assets::{ImportCandidate, LocatedImport},
};
use syntax::{
ast,
ast::{make, HasArgList},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use hir::{InFile, ModuleDef};
use ide_db::{
helpers::{
import_assets::NameToImport, insert_whitespace_into_node::insert_ws_into, mod_path_to_ast,
},
items_locator,
helpers::mod_path_to_ast, imports::import_assets::NameToImport, items_locator,
syntax_helpers::insert_whitespace_into_node::insert_ws_into,
};
use itertools::Itertools;
use syntax::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::iter::{self, successors};
use either::Either;
use ide_db::{
defs::NameClass,
helpers::node_ext::{is_pattern_cond, single_let},
syntax_helpers::node_ext::{is_pattern_cond, single_let},
ty_filter::TryEnum,
RootDatabase,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use hir::AsAssocItem;
use ide_db::helpers::{
insert_use::{insert_use, ImportScope},
mod_path_to_ast,
use ide_db::{
helpers::mod_path_to_ast,
imports::insert_use::{insert_use, ImportScope},
};
use syntax::{
ast::{self, make},
Expand Down
5 changes: 4 additions & 1 deletion crates/ide_assists/src/handlers/unwrap_result_return_type.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use ide_db::helpers::{for_each_tail_expr, node_ext::walk_expr, FamousDefs};
use ide_db::{
famous_defs::FamousDefs,
syntax_helpers::node_ext::{for_each_tail_expr, walk_expr},
};
use itertools::Itertools;
use syntax::{
ast::{self, Expr},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::iter;

use ide_db::helpers::{for_each_tail_expr, node_ext::walk_expr, FamousDefs};
use ide_db::{
famous_defs::FamousDefs,
syntax_helpers::node_ext::{for_each_tail_expr, walk_expr},
};
use syntax::{
ast::{self, make, Expr},
match_ast, AstNode,
Expand Down
Loading

0 comments on commit 5fae65d

Please sign in to comment.