Re-export FxHashMap and FxHashSet from ide_db

This commit is contained in:
Lukas Wirth 2022-04-25 18:51:59 +02:00
parent 8154365b00
commit 4255996965
43 changed files with 70 additions and 94 deletions

5
Cargo.lock generated
View file

@ -606,7 +606,6 @@ dependencies = [
"profile",
"pulldown-cmark",
"pulldown-cmark-to-cmark",
"rustc-hash",
"stdx",
"syntax",
"test_utils",
@ -627,7 +626,6 @@ dependencies = [
"ide_db",
"itertools",
"profile",
"rustc-hash",
"sourcegen",
"stdx",
"syntax",
@ -647,7 +645,6 @@ dependencies = [
"itertools",
"once_cell",
"profile",
"rustc-hash",
"smallvec",
"stdx",
"syntax",
@ -695,7 +692,6 @@ dependencies = [
"ide_db",
"itertools",
"profile",
"rustc-hash",
"sourcegen",
"stdx",
"syntax",
@ -713,7 +709,6 @@ dependencies = [
"ide_db",
"itertools",
"parser",
"rustc-hash",
"syntax",
"test_utils",
"text_edit",

View file

@ -15,7 +15,6 @@ crossbeam-channel = "0.5.4"
either = "1.6.1"
itertools = "0.10.3"
tracing = "0.1.32"
rustc-hash = "1.1.0"
oorandom = "11.1.3"
pulldown-cmark-to-cmark = "10.0.1"
pulldown-cmark = { version = "0.9.1", default-features = false }

View file

@ -1,6 +1,4 @@
use ide_db::syntax_helpers::node_ext::vis_eq;
use rustc_hash::FxHashSet;
use ide_db::{syntax_helpers::node_ext::vis_eq, FxHashSet};
use syntax::{
ast::{self, AstNode, AstToken},
match_ast, Direction, NodeOrToken, SourceFile,

View file

@ -5,9 +5,8 @@ use ide_db::{
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,
FxHashSet, RootDatabase,
};
use rustc_hash::FxHashSet;
use syntax::{
ast::{self, HasLoopBody},
match_ast, AstNode,

View file

@ -1,10 +1,10 @@
use either::Either;
use hir::{known, Callable, HasVisibility, HirDisplay, Semantics, TypeInfo};
use ide_db::{
base_db::FileRange, famous_defs::FamousDefs, syntax_helpers::node_ext::walk_ty, RootDatabase,
base_db::FileRange, famous_defs::FamousDefs, syntax_helpers::node_ext::walk_ty, FxHashMap,
RootDatabase,
};
use itertools::Itertools;
use rustc_hash::FxHashMap;
use stdx::to_lower_snake_case;
use syntax::{
ast::{self, AstNode, HasArgList, HasGenericParams, HasName, UnaryOp},

View file

@ -12,9 +12,8 @@ use ide_db::{
salsa::{Database, ParallelDatabase, Snapshot},
Cancelled, CrateGraph, CrateId, SourceDatabase, SourceDatabaseExt,
},
FxIndexMap,
FxHashSet, FxIndexMap,
};
use rustc_hash::FxHashSet;
use crate::RootDatabase;

View file

@ -1,7 +1,7 @@
//! helper data structure to schedule work for parallel prime caches.
use std::{collections::VecDeque, hash::Hash};
use rustc_hash::FxHashMap;
use ide_db::FxHashMap;
pub(crate) struct TopologicSortIterBuilder<T> {
nodes: FxHashMap<T, Entry<T>>,

View file

@ -14,9 +14,8 @@ use ide_db::{
base_db::FileId,
defs::{Definition, NameClass, NameRefClass},
search::{ReferenceCategory, SearchScope, UsageSearchResult},
RootDatabase,
FxHashMap, RootDatabase,
};
use rustc_hash::FxHashMap;
use syntax::{
algo::find_node_at_offset,
ast::{self, HasName},

View file

@ -9,10 +9,9 @@ use ide_db::{
defs::Definition,
helpers::visit_file_defs,
search::SearchScope,
RootDatabase, SymbolKind,
FxHashMap, FxHashSet, RootDatabase, SymbolKind,
};
use itertools::Itertools;
use rustc_hash::{FxHashMap, FxHashSet};
use stdx::{always, format_to};
use syntax::{
ast::{self, AstNode, HasAttrs as _},

View file

@ -1,9 +1,9 @@
use std::sync::Arc;
use ide_db::base_db::salsa::Durability;
use ide_db::base_db::{CrateGraph, SourceDatabase};
use ide_db::RootDatabase;
use rustc_hash::FxHashMap;
use ide_db::{
base_db::{salsa::Durability, CrateGraph, SourceDatabase},
FxHashMap, RootDatabase,
};
// Feature: Shuffle Crate Graph
//

View file

@ -63,9 +63,8 @@ mod tests {
use ide_db::{
base_db::{fixture::WithFixture, salsa::Durability, FileRange},
symbol_index::SymbolsDatabase,
RootDatabase,
FxHashSet, RootDatabase,
};
use rustc_hash::FxHashSet;
use super::ssr_assists;

View file

@ -7,9 +7,8 @@ use hir::{db::HirDatabase, Crate, Module, Semantics};
use ide_db::{
base_db::{FileId, FileRange, SourceDatabaseExt},
defs::{Definition, IdentClass},
RootDatabase,
FxHashSet, RootDatabase,
};
use rustc_hash::FxHashSet;
use syntax::{AstNode, SyntaxKind::*, SyntaxToken, TextRange, T};
use crate::{

View file

@ -14,8 +14,7 @@ mod html;
mod tests;
use hir::{InFile, Name, Semantics};
use ide_db::RootDatabase;
use rustc_hash::FxHashMap;
use ide_db::{FxHashMap, RootDatabase};
use syntax::{
ast, AstNode, AstToken, NodeOrToken, SyntaxKind::*, SyntaxNode, TextRange, WalkEvent, T,
};

View file

@ -3,9 +3,8 @@
use hir::{AsAssocItem, HasVisibility, Semantics};
use ide_db::{
defs::{Definition, IdentClass, NameClass, NameRefClass},
RootDatabase, SymbolKind,
FxHashMap, RootDatabase, SymbolKind,
};
use rustc_hash::FxHashMap;
use syntax::{
ast, match_ast, AstNode, AstToken, NodeOrToken,
SyntaxKind::{self, *},

View file

@ -3,9 +3,8 @@ use std::sync::Arc;
use dot::{Id, LabelText};
use ide_db::{
base_db::{CrateGraph, CrateId, Dependency, SourceDatabase, SourceDatabaseExt},
RootDatabase,
FxHashSet, RootDatabase,
};
use rustc_hash::FxHashSet;
// Feature: View Crate Graph
//

View file

@ -11,7 +11,7 @@ doctest = false
[dependencies]
cov-mark = "2.0.0-pre.1"
rustc-hash = "1.1.0"
itertools = "0.10.3"
either = "1.6.1"

View file

@ -7,10 +7,9 @@ use ide_db::{
helpers::mod_path_to_ast,
imports::insert_use::{insert_use, ImportScope, InsertUseConfig},
search::FileReference,
RootDatabase,
FxHashSet, RootDatabase,
};
use itertools::{Itertools, Position};
use rustc_hash::FxHashSet;
use syntax::{
ast::{
self, edit::IndentLevel, edit_in_place::Indent, make, AstNode, HasAttrs, HasGenericParams,

View file

@ -1,11 +1,9 @@
use rustc_hash::{FxHashMap, FxHashSet};
use hir::{HasSource, HirDisplay, Module, Semantics, TypeInfo};
use ide_db::{
base_db::FileId,
defs::{Definition, NameRefClass},
famous_defs::FamousDefs,
RootDatabase, SnippetCap,
FxHashMap, FxHashSet, RootDatabase, SnippetCap,
};
use stdx::to_lower_snake_case;
use syntax::{

View file

@ -1,4 +1,4 @@
use rustc_hash::FxHashSet;
use ide_db::FxHashSet;
use syntax::{
ast::{self, edit_in_place::GenericParamsOwnerEdit, make, HasGenericParams},
ted::{self, Position},

View file

@ -1,7 +1,6 @@
use either::Either;
use ide_db::FxHashMap;
use itertools::Itertools;
use rustc_hash::FxHashMap;
use syntax::{ast, ted, AstNode};
use crate::{AssistContext, AssistId, AssistKind, Assists};

View file

@ -1,8 +1,6 @@
use itertools::Itertools;
use rustc_hash::FxHashMap;
use hir::{PathResolution, Semantics};
use ide_db::RootDatabase;
use ide_db::{FxHashMap, RootDatabase};
use itertools::Itertools;
use syntax::{
ast::{self, HasName},
ted, AstNode,

View file

@ -12,7 +12,7 @@ doctest = false
[dependencies]
cov-mark = "2.0.0-pre.1"
itertools = "0.10.3"
rustc-hash = "1.1.0"
once_cell = "1.10.0"
smallvec = "1.8.0"

View file

@ -7,11 +7,10 @@ use ide_db::{
Lint, CLIPPY_LINTS, CLIPPY_LINT_GROUPS, DEFAULT_LINTS, FEATURES, RUSTDOC_LINTS,
},
syntax_helpers::node_ext::parse_tt_as_comma_sep_paths,
SymbolKind,
FxHashMap, SymbolKind,
};
use itertools::Itertools;
use once_cell::sync::Lazy;
use rustc_hash::FxHashMap;
use syntax::{
ast::{self, AttrKind},
AstNode, SyntaxKind, T,

View file

@ -1,6 +1,6 @@
//! Completes references after dot (fields and method calls).
use rustc_hash::FxHashSet;
use ide_db::FxHashSet;
use crate::{context::CompletionContext, patterns::ImmediateLocation, Completions};

View file

@ -1,7 +1,7 @@
//! See [`complete_fn_param`].
use hir::HirDisplay;
use rustc_hash::FxHashMap;
use ide_db::FxHashMap;
use syntax::{
algo,
ast::{self, HasModuleItem},

View file

@ -3,11 +3,11 @@
use std::iter;
use hir::{Module, ModuleSource};
use ide_db::FxHashSet;
use ide_db::{
base_db::{SourceDatabaseExt, VfsPath},
RootDatabase, SymbolKind,
};
use rustc_hash::FxHashSet;
use crate::{context::NameContext, CompletionItem};

View file

@ -1,7 +1,7 @@
//! Completes constants and paths in unqualified patterns.
use hir::{db::DefDatabase, AssocItem, ScopeDef};
use rustc_hash::FxHashSet;
use ide_db::FxHashSet;
use syntax::ast::Pat;
use crate::{

View file

@ -1,7 +1,7 @@
//! Completion of paths, i.e. `some::prefix::$0`.
use hir::{ScopeDef, Trait};
use rustc_hash::FxHashSet;
use ide_db::FxHashSet;
use syntax::ast;
use crate::{

View file

@ -1,7 +1,7 @@
//! Completion for use trees
use hir::ScopeDef;
use rustc_hash::FxHashSet;
use ide_db::FxHashSet;
use syntax::{ast, AstNode};
use crate::{

View file

@ -10,9 +10,8 @@ use ide_db::{
active_parameter::ActiveParameter,
base_db::{FilePosition, SourceDatabase},
famous_defs::FamousDefs,
RootDatabase,
FxHashMap, FxHashSet, RootDatabase,
};
use rustc_hash::{FxHashMap, FxHashSet};
use syntax::{
algo::{find_node_at_offset, non_trivia_sibling},
ast::{self, AttrKind, HasName, NameOrNameRef},

View file

@ -49,9 +49,9 @@ use hir::{
db::{AstDatabase, DefDatabase, HirDatabase},
symbols::FileSymbolKind,
};
use rustc_hash::FxHashSet;
use crate::{line_index::LineIndex, symbol_index::SymbolsDatabase};
pub use rustc_hash::{FxHashMap, FxHashSet, FxHasher};
/// `base_db` is normally also needed in places where `ide_db` is used, so this re-export is for convenience.
pub use base_db;

View file

@ -12,7 +12,8 @@ doctest = false
[dependencies]
cov-mark = "2.0.0-pre.1"
itertools = "0.10.3"
rustc-hash = "1.1.0"
either = "1.6.1"
profile = { path = "../profile", version = "0.0.0" }

View file

@ -3,8 +3,7 @@ use hir::{
db::{AstDatabase, HirDatabase},
known, AssocItem, HirDisplay, InFile, Type,
};
use ide_db::{assists::Assist, famous_defs::FamousDefs, source_change::SourceChange};
use rustc_hash::FxHashMap;
use ide_db::{assists::Assist, famous_defs::FamousDefs, source_change::SourceChange, FxHashMap};
use stdx::format_to;
use syntax::{
algo,

View file

@ -59,9 +59,8 @@ use ide_db::{
base_db::{FileId, SourceDatabase},
label::Label,
source_change::SourceChange,
RootDatabase,
FxHashSet, RootDatabase,
};
use rustc_hash::FxHashSet;
use syntax::{ast::AstNode, TextRange};
#[derive(Copy, Clone, Debug, PartialEq)]

View file

@ -12,7 +12,7 @@ doctest = false
[dependencies]
cov-mark = "2.0.0-pre.1"
rustc-hash = "1.1.0"
itertools = "0.10.3"
text_edit = { path = "../text_edit", version = "0.0.0" }

View file

@ -80,15 +80,15 @@ mod errors;
#[cfg(test)]
mod tests;
use crate::errors::bail;
pub use crate::errors::SsrError;
pub use crate::from_comment::ssr_from_comment;
pub use crate::matching::Match;
use crate::matching::MatchFailureReason;
pub use crate::{errors::SsrError, from_comment::ssr_from_comment, matching::Match};
use crate::{errors::bail, matching::MatchFailureReason};
use hir::Semantics;
use ide_db::base_db::{FileId, FilePosition, FileRange};
use ide_db::{
base_db::{FileId, FilePosition, FileRange},
FxHashMap,
};
use resolving::ResolvedRule;
use rustc_hash::FxHashMap;
use syntax::{ast, AstNode, SyntaxNode, TextRange};
use text_edit::TextEdit;

View file

@ -7,13 +7,11 @@ use crate::{
SsrMatches,
};
use hir::Semantics;
use ide_db::base_db::FileRange;
use rustc_hash::FxHashMap;
use ide_db::{base_db::FileRange, FxHashMap};
use std::{cell::Cell, iter::Peekable};
use syntax::{ast, SyntaxElement, SyntaxElementChildren, SyntaxKind, SyntaxNode, SyntaxToken};
use syntax::{
ast::{AstNode, AstToken},
SmolStr,
ast::{self, AstNode, AstToken},
SmolStr, SyntaxElement, SyntaxElementChildren, SyntaxKind, SyntaxNode, SyntaxToken,
};
// Creates a match error. If we're currently attempting to match some code that we thought we were

View file

@ -7,10 +7,11 @@
//! then we'll get 3 matches, however only the outermost and innermost matches can be accepted. The
//! middle match would take the second `foo` from the outer match.
use crate::{Match, SsrMatches};
use rustc_hash::FxHashMap;
use ide_db::FxHashMap;
use syntax::SyntaxNode;
use crate::{Match, SsrMatches};
pub(crate) fn nest_and_remove_collisions(
mut matches: Vec<Match>,
sema: &hir::Semantics<ide_db::RootDatabase>,

View file

@ -4,7 +4,7 @@
//! placeholders, which start with `$`. For replacement templates, this is the final form. For
//! search patterns, we go further and parse the pattern as each kind of thing that we can match.
//! e.g. expressions, type references etc.
use rustc_hash::{FxHashMap, FxHashSet};
use ide_db::{FxHashMap, FxHashSet};
use std::{fmt::Display, str::FromStr};
use syntax::{SmolStr, SyntaxKind, SyntaxNode, T};

View file

@ -1,14 +1,15 @@
//! Code for applying replacement templates for matches that have previously been found.
use crate::fragments;
use crate::{resolving::ResolvedRule, Match, SsrMatches};
use ide_db::{FxHashMap, FxHashSet};
use itertools::Itertools;
use rustc_hash::{FxHashMap, FxHashSet};
use syntax::ast::{self, AstNode, AstToken};
use syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize};
use syntax::{
ast::{self, AstNode, AstToken},
SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize,
};
use text_edit::TextEdit;
use crate::{fragments, resolving::ResolvedRule, Match, SsrMatches};
/// Returns a text edit that will replace each match in `matches` with its corresponding replacement
/// template. Placeholders in the template will have been substituted with whatever they matched to
/// in the original code.

View file

@ -1,13 +1,12 @@
//! This module is responsible for resolving paths within rules.
use crate::errors::error;
use crate::{parsing, SsrError};
use hir::AsAssocItem;
use ide_db::base_db::FilePosition;
use ide_db::{base_db::FilePosition, FxHashMap};
use parsing::Placeholder;
use rustc_hash::FxHashMap;
use syntax::{ast, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken};
use crate::{errors::error, parsing, SsrError};
pub(crate) struct ResolutionScope<'db> {
scope: hir::SemanticsScope<'db>,
node: SyntaxNode,

View file

@ -9,8 +9,8 @@ use ide_db::{
base_db::{FileId, FileRange},
defs::Definition,
search::{SearchScope, UsageSearchResult},
FxHashSet,
};
use rustc_hash::FxHashSet;
use syntax::{ast, AstNode, SyntaxKind, SyntaxNode};
/// A cache for the results of find_usages. This is for when we have multiple patterns that have the

View file

@ -1,10 +1,13 @@
use crate::{MatchFinder, SsrRule};
use expect_test::{expect, Expect};
use ide_db::base_db::{salsa::Durability, FileId, FilePosition, FileRange, SourceDatabaseExt};
use rustc_hash::FxHashSet;
use ide_db::{
base_db::{salsa::Durability, FileId, FilePosition, FileRange, SourceDatabaseExt},
FxHashSet,
};
use std::sync::Arc;
use test_utils::RangeOrOffset;
use crate::{MatchFinder, SsrRule};
fn parse_error_text(query: &str) -> String {
format!("{}", query.parse::<SsrRule>().unwrap_err())
}