mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 13:33:31 +00:00
internal: Move out WithFixture
into dev-dep only crate
This commit is contained in:
parent
ec6162308e
commit
f49a2fed3f
59 changed files with 189 additions and 119 deletions
25
Cargo.lock
generated
25
Cargo.lock
generated
|
@ -77,7 +77,6 @@ dependencies = [
|
||||||
"span",
|
"span",
|
||||||
"stdx",
|
"stdx",
|
||||||
"syntax",
|
"syntax",
|
||||||
"test-utils",
|
|
||||||
"triomphe",
|
"triomphe",
|
||||||
"vfs",
|
"vfs",
|
||||||
]
|
]
|
||||||
|
@ -519,6 +518,7 @@ dependencies = [
|
||||||
"span",
|
"span",
|
||||||
"stdx",
|
"stdx",
|
||||||
"syntax",
|
"syntax",
|
||||||
|
"test-fixture",
|
||||||
"test-utils",
|
"test-utils",
|
||||||
"tracing",
|
"tracing",
|
||||||
"triomphe",
|
"triomphe",
|
||||||
|
@ -546,7 +546,6 @@ dependencies = [
|
||||||
"span",
|
"span",
|
||||||
"stdx",
|
"stdx",
|
||||||
"syntax",
|
"syntax",
|
||||||
"test-utils",
|
|
||||||
"tracing",
|
"tracing",
|
||||||
"triomphe",
|
"triomphe",
|
||||||
"tt",
|
"tt",
|
||||||
|
@ -584,6 +583,7 @@ dependencies = [
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"stdx",
|
"stdx",
|
||||||
"syntax",
|
"syntax",
|
||||||
|
"test-fixture",
|
||||||
"test-utils",
|
"test-utils",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
@ -627,6 +627,7 @@ dependencies = [
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"stdx",
|
"stdx",
|
||||||
"syntax",
|
"syntax",
|
||||||
|
"test-fixture",
|
||||||
"test-utils",
|
"test-utils",
|
||||||
"text-edit",
|
"text-edit",
|
||||||
"toolchain",
|
"toolchain",
|
||||||
|
@ -650,6 +651,7 @@ dependencies = [
|
||||||
"sourcegen",
|
"sourcegen",
|
||||||
"stdx",
|
"stdx",
|
||||||
"syntax",
|
"syntax",
|
||||||
|
"test-fixture",
|
||||||
"test-utils",
|
"test-utils",
|
||||||
"text-edit",
|
"text-edit",
|
||||||
]
|
]
|
||||||
|
@ -669,6 +671,7 @@ dependencies = [
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"stdx",
|
"stdx",
|
||||||
"syntax",
|
"syntax",
|
||||||
|
"test-fixture",
|
||||||
"test-utils",
|
"test-utils",
|
||||||
"text-edit",
|
"text-edit",
|
||||||
]
|
]
|
||||||
|
@ -700,6 +703,7 @@ dependencies = [
|
||||||
"span",
|
"span",
|
||||||
"stdx",
|
"stdx",
|
||||||
"syntax",
|
"syntax",
|
||||||
|
"test-fixture",
|
||||||
"test-utils",
|
"test-utils",
|
||||||
"text-edit",
|
"text-edit",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
@ -724,6 +728,7 @@ dependencies = [
|
||||||
"sourcegen",
|
"sourcegen",
|
||||||
"stdx",
|
"stdx",
|
||||||
"syntax",
|
"syntax",
|
||||||
|
"test-fixture",
|
||||||
"test-utils",
|
"test-utils",
|
||||||
"text-edit",
|
"text-edit",
|
||||||
]
|
]
|
||||||
|
@ -741,6 +746,7 @@ dependencies = [
|
||||||
"parser",
|
"parser",
|
||||||
"stdx",
|
"stdx",
|
||||||
"syntax",
|
"syntax",
|
||||||
|
"test-fixture",
|
||||||
"test-utils",
|
"test-utils",
|
||||||
"text-edit",
|
"text-edit",
|
||||||
"triomphe",
|
"triomphe",
|
||||||
|
@ -1543,6 +1549,7 @@ dependencies = [
|
||||||
"sourcegen",
|
"sourcegen",
|
||||||
"stdx",
|
"stdx",
|
||||||
"syntax",
|
"syntax",
|
||||||
|
"test-fixture",
|
||||||
"test-utils",
|
"test-utils",
|
||||||
"tikv-jemallocator",
|
"tikv-jemallocator",
|
||||||
"toolchain",
|
"toolchain",
|
||||||
|
@ -1815,6 +1822,20 @@ dependencies = [
|
||||||
"ungrammar",
|
"ungrammar",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "test-fixture"
|
||||||
|
version = "0.0.0"
|
||||||
|
dependencies = [
|
||||||
|
"base-db",
|
||||||
|
"cfg",
|
||||||
|
"hir-expand",
|
||||||
|
"rustc-hash",
|
||||||
|
"span",
|
||||||
|
"stdx",
|
||||||
|
"test-utils",
|
||||||
|
"tt",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "test-utils"
|
name = "test-utils"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
|
|
@ -70,11 +70,9 @@ proc-macro-srv = { path = "./crates/proc-macro-srv", version = "0.0.0" }
|
||||||
proc-macro-srv-cli = { path = "./crates/proc-macro-srv-cli", version = "0.0.0" }
|
proc-macro-srv-cli = { path = "./crates/proc-macro-srv-cli", version = "0.0.0" }
|
||||||
profile = { path = "./crates/profile", version = "0.0.0" }
|
profile = { path = "./crates/profile", version = "0.0.0" }
|
||||||
project-model = { path = "./crates/project-model", version = "0.0.0" }
|
project-model = { path = "./crates/project-model", version = "0.0.0" }
|
||||||
sourcegen = { path = "./crates/sourcegen", version = "0.0.0" }
|
|
||||||
span = { path = "./crates/span", version = "0.0.0" }
|
span = { path = "./crates/span", version = "0.0.0" }
|
||||||
stdx = { path = "./crates/stdx", version = "0.0.0" }
|
stdx = { path = "./crates/stdx", version = "0.0.0" }
|
||||||
syntax = { path = "./crates/syntax", version = "0.0.0" }
|
syntax = { path = "./crates/syntax", version = "0.0.0" }
|
||||||
test-utils = { path = "./crates/test-utils", version = "0.0.0" }
|
|
||||||
text-edit = { path = "./crates/text-edit", version = "0.0.0" }
|
text-edit = { path = "./crates/text-edit", version = "0.0.0" }
|
||||||
toolchain = { path = "./crates/toolchain", version = "0.0.0" }
|
toolchain = { path = "./crates/toolchain", version = "0.0.0" }
|
||||||
tt = { path = "./crates/tt", version = "0.0.0" }
|
tt = { path = "./crates/tt", version = "0.0.0" }
|
||||||
|
@ -84,6 +82,9 @@ rustc-dependencies = { path = "./crates/rustc-dependencies", version = "0.0.0" }
|
||||||
|
|
||||||
# local crates that aren't published to crates.io. These should not have versions.
|
# local crates that aren't published to crates.io. These should not have versions.
|
||||||
proc-macro-test = { path = "./crates/proc-macro-test" }
|
proc-macro-test = { path = "./crates/proc-macro-test" }
|
||||||
|
sourcegen = { path = "./crates/sourcegen" }
|
||||||
|
test-fixture = { path = "./crates/test-fixture" }
|
||||||
|
test-utils = { path = "./crates/test-utils" }
|
||||||
|
|
||||||
# In-tree crates that are published separately and follow semver. See lib/README.md
|
# In-tree crates that are published separately and follow semver. See lib/README.md
|
||||||
line-index = { version = "0.1.1" }
|
line-index = { version = "0.1.1" }
|
||||||
|
@ -94,8 +95,11 @@ lsp-server = { version = "0.7.4" }
|
||||||
anyhow = "1.0.75"
|
anyhow = "1.0.75"
|
||||||
bitflags = "2.4.1"
|
bitflags = "2.4.1"
|
||||||
cargo_metadata = "0.18.1"
|
cargo_metadata = "0.18.1"
|
||||||
|
command-group = "2.0.1"
|
||||||
|
crossbeam-channel = "0.5.8"
|
||||||
dissimilar = "1.0.7"
|
dissimilar = "1.0.7"
|
||||||
either = "1.9.0"
|
either = "1.9.0"
|
||||||
|
expect-test = "1.4.0"
|
||||||
hashbrown = { version = "0.14", features = [
|
hashbrown = { version = "0.14", features = [
|
||||||
"inline-more",
|
"inline-more",
|
||||||
], default-features = false }
|
], default-features = false }
|
||||||
|
@ -125,5 +129,6 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
|
||||||
triomphe = { version = "0.1.10", default-features = false, features = ["std"] }
|
triomphe = { version = "0.1.10", default-features = false, features = ["std"] }
|
||||||
xshell = "0.2.5"
|
xshell = "0.2.5"
|
||||||
|
|
||||||
|
|
||||||
# We need to freeze the version of the crate, as the raw-api feature is considered unstable
|
# We need to freeze the version of the crate, as the raw-api feature is considered unstable
|
||||||
dashmap = { version = "=5.5.3", features = ["raw-api"] }
|
dashmap = { version = "=5.5.3", features = ["raw-api"] }
|
||||||
|
|
|
@ -22,6 +22,5 @@ cfg.workspace = true
|
||||||
profile.workspace = true
|
profile.workspace = true
|
||||||
stdx.workspace = true
|
stdx.workspace = true
|
||||||
syntax.workspace = true
|
syntax.workspace = true
|
||||||
test-utils.workspace = true
|
|
||||||
vfs.workspace = true
|
vfs.workspace = true
|
||||||
span.workspace = true
|
span.workspace = true
|
||||||
|
|
|
@ -12,7 +12,7 @@ rust-version.workspace = true
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash.workspace = true
|
||||||
|
|
||||||
# locals deps
|
# locals deps
|
||||||
tt.workspace = true
|
tt.workspace = true
|
||||||
|
|
|
@ -13,12 +13,12 @@ doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cargo_metadata.workspace = true
|
cargo_metadata.workspace = true
|
||||||
crossbeam-channel = "0.5.8"
|
crossbeam-channel.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
command-group = "2.0.1"
|
command-group.workspace = true
|
||||||
|
|
||||||
# local deps
|
# local deps
|
||||||
paths.workspace = true
|
paths.workspace = true
|
||||||
|
|
|
@ -23,7 +23,7 @@ indexmap.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
la-arena.workspace = true
|
la-arena.workspace = true
|
||||||
once_cell = "1.17.0"
|
once_cell = "1.17.0"
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
smallvec.workspace = true
|
smallvec.workspace = true
|
||||||
hashbrown.workspace = true
|
hashbrown.workspace = true
|
||||||
|
@ -46,10 +46,11 @@ span.workspace = true
|
||||||
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
expect-test = "1.4.0"
|
expect-test.workspace = true
|
||||||
|
|
||||||
# local deps
|
# local deps
|
||||||
test-utils.workspace = true
|
test-utils.workspace = true
|
||||||
|
test-fixture.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
in-rust-tree = ["rustc-dependencies/in-rust-tree"]
|
in-rust-tree = ["rustc-dependencies/in-rust-tree"]
|
||||||
|
|
|
@ -268,8 +268,9 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use base_db::{FileId, SourceDatabase};
|
use base_db::{FileId, SourceDatabase};
|
||||||
use hir_expand::{fixture::WithFixture, name::AsName, InFile};
|
use hir_expand::{name::AsName, InFile};
|
||||||
use syntax::{algo::find_node_at_offset, ast, AstNode};
|
use syntax::{algo::find_node_at_offset, ast, AstNode};
|
||||||
|
use test_fixture::WithFixture;
|
||||||
use test_utils::{assert_eq_text, extract_offset};
|
use test_utils::{assert_eq_text, extract_offset};
|
||||||
|
|
||||||
use crate::{db::DefDatabase, test_db::TestDB, FunctionId, ModuleDefId};
|
use crate::{db::DefDatabase, test_db::TestDB, FunctionId, ModuleDefId};
|
||||||
|
|
|
@ -2,7 +2,7 @@ mod block;
|
||||||
|
|
||||||
use base_db::SourceDatabase;
|
use base_db::SourceDatabase;
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::{expect, Expect};
|
||||||
use hir_expand::fixture::WithFixture;
|
use test_fixture::WithFixture;
|
||||||
|
|
||||||
use crate::{test_db::TestDB, ModuleDefId};
|
use crate::{test_db::TestDB, ModuleDefId};
|
||||||
|
|
||||||
|
|
|
@ -585,8 +585,9 @@ fn find_local_import_locations(
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use hir_expand::{db::ExpandDatabase, fixture::WithFixture};
|
use hir_expand::db::ExpandDatabase;
|
||||||
use syntax::ast::AstNode;
|
use syntax::ast::AstNode;
|
||||||
|
use test_fixture::WithFixture;
|
||||||
|
|
||||||
use crate::test_db::TestDB;
|
use crate::test_db::TestDB;
|
||||||
|
|
||||||
|
|
|
@ -475,7 +475,7 @@ pub fn search_dependencies(
|
||||||
mod tests {
|
mod tests {
|
||||||
use base_db::{SourceDatabase, Upcast};
|
use base_db::{SourceDatabase, Upcast};
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::{expect, Expect};
|
||||||
use hir_expand::fixture::WithFixture;
|
use test_fixture::WithFixture;
|
||||||
|
|
||||||
use crate::{db::DefDatabase, test_db::TestDB, ItemContainerId, Lookup};
|
use crate::{db::DefDatabase, test_db::TestDB, ItemContainerId, Lookup};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::{expect, Expect};
|
||||||
use hir_expand::fixture::WithFixture;
|
use test_fixture::WithFixture;
|
||||||
|
|
||||||
use crate::{db::DefDatabase, test_db::TestDB};
|
use crate::{db::DefDatabase, test_db::TestDB};
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ use base_db::SourceDatabase;
|
||||||
use expect_test::Expect;
|
use expect_test::Expect;
|
||||||
use hir_expand::{
|
use hir_expand::{
|
||||||
db::ExpandDatabase,
|
db::ExpandDatabase,
|
||||||
fixture::WithFixture,
|
|
||||||
proc_macro::{ProcMacro, ProcMacroExpander, ProcMacroExpansionError, ProcMacroKind},
|
proc_macro::{ProcMacro, ProcMacroExpander, ProcMacroExpansionError, ProcMacroKind},
|
||||||
span_map::SpanMapRef,
|
span_map::SpanMapRef,
|
||||||
InFile, MacroFileId, MacroFileIdExt,
|
InFile, MacroFileId, MacroFileIdExt,
|
||||||
|
@ -33,6 +32,7 @@ use syntax::{
|
||||||
SyntaxKind::{COMMENT, EOF, IDENT, LIFETIME_IDENT},
|
SyntaxKind::{COMMENT, EOF, IDENT, LIFETIME_IDENT},
|
||||||
SyntaxNode, T,
|
SyntaxNode, T,
|
||||||
};
|
};
|
||||||
|
use test_fixture::WithFixture;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::DefDatabase,
|
db::DefDatabase,
|
||||||
|
|
|
@ -2370,7 +2370,7 @@ impl ModCollector<'_, '_> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use base_db::SourceDatabase;
|
use base_db::SourceDatabase;
|
||||||
use hir_expand::fixture::WithFixture;
|
use test_fixture::WithFixture;
|
||||||
|
|
||||||
use crate::{db::DefDatabase, test_db::TestDB};
|
use crate::{db::DefDatabase, test_db::TestDB};
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ mod primitives;
|
||||||
|
|
||||||
use base_db::SourceDatabase;
|
use base_db::SourceDatabase;
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::{expect, Expect};
|
||||||
use hir_expand::fixture::WithFixture;
|
use test_fixture::WithFixture;
|
||||||
use triomphe::Arc;
|
use triomphe::Arc;
|
||||||
|
|
||||||
use crate::{db::DefDatabase, nameres::DefMap, test_db::TestDB};
|
use crate::{db::DefDatabase, nameres::DefMap, test_db::TestDB};
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
use base_db::{SourceDatabase, SourceDatabaseExt};
|
use base_db::{SourceDatabase, SourceDatabaseExt};
|
||||||
|
use test_fixture::WithFixture;
|
||||||
use triomphe::Arc;
|
use triomphe::Arc;
|
||||||
|
|
||||||
use crate::{
|
use crate::{db::DefDatabase, nameres::tests::TestDB, AdtId, ModuleDefId};
|
||||||
db::DefDatabase,
|
|
||||||
nameres::tests::{TestDB, WithFixture},
|
|
||||||
AdtId, ModuleDefId,
|
|
||||||
};
|
|
||||||
|
|
||||||
fn check_def_map_is_not_recomputed(ra_fixture_initial: &str, ra_fixture_change: &str) {
|
fn check_def_map_is_not_recomputed(ra_fixture_initial: &str, ra_fixture_change: &str) {
|
||||||
let (mut db, pos) = TestDB::with_position(ra_fixture_initial);
|
let (mut db, pos) = TestDB::with_position(ra_fixture_initial);
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
use super::*;
|
use expect_test::expect;
|
||||||
|
use test_fixture::WithFixture;
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
|
use crate::nameres::tests::check;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn macro_rules_are_globally_visible() {
|
fn macro_rules_are_globally_visible() {
|
||||||
check(
|
check(
|
||||||
|
|
|
@ -15,7 +15,7 @@ doctest = false
|
||||||
cov-mark = "2.0.0-pre.1"
|
cov-mark = "2.0.0-pre.1"
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
either.workspace = true
|
either.workspace = true
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash.workspace = true
|
||||||
la-arena.workspace = true
|
la-arena.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
hashbrown.workspace = true
|
hashbrown.workspace = true
|
||||||
|
@ -33,7 +33,6 @@ tt.workspace = true
|
||||||
mbe.workspace = true
|
mbe.workspace = true
|
||||||
limit.workspace = true
|
limit.workspace = true
|
||||||
span.workspace = true
|
span.workspace = true
|
||||||
test-utils.workspace = true
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
expect-test = "1.4.0"
|
expect-test = "1.4.0"
|
||||||
|
|
42
crates/hir-expand/src/change.rs
Normal file
42
crates/hir-expand/src/change.rs
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
//! Defines a unit of change that can applied to the database to get the next
|
||||||
|
//! state. Changes are transactional.
|
||||||
|
use base_db::{salsa::Durability, CrateGraph, FileChange, SourceDatabaseExt, SourceRoot};
|
||||||
|
use span::FileId;
|
||||||
|
use triomphe::Arc;
|
||||||
|
|
||||||
|
use crate::{db::ExpandDatabase, proc_macro::ProcMacros};
|
||||||
|
|
||||||
|
#[derive(Debug, Default)]
|
||||||
|
pub struct Change {
|
||||||
|
pub source_change: FileChange,
|
||||||
|
pub proc_macros: Option<ProcMacros>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Change {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self::default()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn apply(self, db: &mut (impl ExpandDatabase + SourceDatabaseExt)) {
|
||||||
|
self.source_change.apply(db);
|
||||||
|
if let Some(proc_macros) = self.proc_macros {
|
||||||
|
db.set_proc_macros_with_durability(Arc::new(proc_macros), Durability::HIGH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn change_file(&mut self, file_id: FileId, new_text: Option<Arc<str>>) {
|
||||||
|
self.source_change.change_file(file_id, new_text)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_crate_graph(&mut self, graph: CrateGraph) {
|
||||||
|
self.source_change.set_crate_graph(graph)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_proc_macros(&mut self, proc_macros: ProcMacros) {
|
||||||
|
self.proc_macros = Some(proc_macros);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_roots(&mut self, roots: Vec<SourceRoot>) {
|
||||||
|
self.source_change.set_roots(roots)
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,7 +14,7 @@ pub mod builtin_fn_macro;
|
||||||
pub mod db;
|
pub mod db;
|
||||||
pub mod eager;
|
pub mod eager;
|
||||||
pub mod files;
|
pub mod files;
|
||||||
pub mod fixture;
|
pub mod change;
|
||||||
pub mod hygiene;
|
pub mod hygiene;
|
||||||
pub mod mod_path;
|
pub mod mod_path;
|
||||||
pub mod name;
|
pub mod name;
|
||||||
|
|
|
@ -21,7 +21,7 @@ ena = "0.14.0"
|
||||||
either.workspace = true
|
either.workspace = true
|
||||||
oorandom = "11.1.3"
|
oorandom = "11.1.3"
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash.workspace = true
|
||||||
scoped-tls = "1.0.0"
|
scoped-tls = "1.0.0"
|
||||||
chalk-solve = { version = "0.95.0", default-features = false }
|
chalk-solve = { version = "0.95.0", default-features = false }
|
||||||
chalk-ir = "0.95.0"
|
chalk-ir = "0.95.0"
|
||||||
|
@ -54,6 +54,7 @@ project-model = { path = "../project-model" }
|
||||||
|
|
||||||
# local deps
|
# local deps
|
||||||
test-utils.workspace = true
|
test-utils.workspace = true
|
||||||
|
test-fixture.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
in-rust-tree = ["rustc-dependencies/in-rust-tree"]
|
in-rust-tree = ["rustc-dependencies/in-rust-tree"]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use base_db::FileId;
|
use base_db::FileId;
|
||||||
use chalk_ir::Substitution;
|
use chalk_ir::Substitution;
|
||||||
use hir_def::db::DefDatabase;
|
use hir_def::db::DefDatabase;
|
||||||
use hir_expand::fixture::WithFixture;
|
use test_fixture::WithFixture;
|
||||||
use test_utils::skip_slow_tests;
|
use test_utils::skip_slow_tests;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::collections::HashMap;
|
||||||
use chalk_ir::{AdtId, TyKind};
|
use chalk_ir::{AdtId, TyKind};
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir_def::db::DefDatabase;
|
use hir_def::db::DefDatabase;
|
||||||
use hir_expand::fixture::WithFixture;
|
use test_fixture::WithFixture;
|
||||||
use triomphe::Arc;
|
use triomphe::Arc;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use base_db::FileId;
|
use base_db::FileId;
|
||||||
use hir_def::db::DefDatabase;
|
use hir_def::db::DefDatabase;
|
||||||
use hir_expand::fixture::WithFixture;
|
|
||||||
use syntax::{TextRange, TextSize};
|
use syntax::{TextRange, TextSize};
|
||||||
|
use test_fixture::WithFixture;
|
||||||
|
|
||||||
use crate::{db::HirDatabase, test_db::TestDB, Interner, Substitution};
|
use crate::{db::HirDatabase, test_db::TestDB, Interner, Substitution};
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,14 @@ use hir_def::{
|
||||||
src::HasSource,
|
src::HasSource,
|
||||||
AssocItemId, DefWithBodyId, HasModule, LocalModuleId, Lookup, ModuleDefId,
|
AssocItemId, DefWithBodyId, HasModule, LocalModuleId, Lookup, ModuleDefId,
|
||||||
};
|
};
|
||||||
use hir_expand::{db::ExpandDatabase, fixture::WithFixture, InFile};
|
use hir_expand::{db::ExpandDatabase, InFile};
|
||||||
use once_cell::race::OnceBool;
|
use once_cell::race::OnceBool;
|
||||||
use stdx::format_to;
|
use stdx::format_to;
|
||||||
use syntax::{
|
use syntax::{
|
||||||
ast::{self, AstNode, HasName},
|
ast::{self, AstNode, HasName},
|
||||||
SyntaxNode,
|
SyntaxNode,
|
||||||
};
|
};
|
||||||
|
use test_fixture::WithFixture;
|
||||||
use tracing_subscriber::{layer::SubscriberExt, Registry};
|
use tracing_subscriber::{layer::SubscriberExt, Registry};
|
||||||
use tracing_tree::HierarchicalLayer;
|
use tracing_tree::HierarchicalLayer;
|
||||||
use triomphe::Arc;
|
use triomphe::Arc;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use base_db::SourceDatabaseExt;
|
use base_db::SourceDatabaseExt;
|
||||||
use hir_expand::fixture::WithFixture;
|
use test_fixture::WithFixture;
|
||||||
use triomphe::Arc;
|
use triomphe::Arc;
|
||||||
|
|
||||||
use crate::{db::HirDatabase, test_db::TestDB};
|
use crate::{db::HirDatabase, test_db::TestDB};
|
||||||
|
|
|
@ -12,7 +12,7 @@ rust-version.workspace = true
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash.workspace = true
|
||||||
either.workspace = true
|
either.workspace = true
|
||||||
arrayvec = "0.7.2"
|
arrayvec = "0.7.2"
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
|
|
|
@ -125,7 +125,7 @@ pub use {
|
||||||
},
|
},
|
||||||
hir_expand::{
|
hir_expand::{
|
||||||
attrs::{Attr, AttrId},
|
attrs::{Attr, AttrId},
|
||||||
fixture::{Change, ChangeFixture, WithFixture},
|
change::Change,
|
||||||
hygiene::{marks_rev, SyntaxContextExt},
|
hygiene::{marks_rev, SyntaxContextExt},
|
||||||
name::{known, Name},
|
name::{known, Name},
|
||||||
proc_macro::ProcMacros,
|
proc_macro::ProcMacros,
|
||||||
|
|
|
@ -31,6 +31,7 @@ expect-test = "1.4.0"
|
||||||
|
|
||||||
# local deps
|
# local deps
|
||||||
test-utils.workspace = true
|
test-utils.workspace = true
|
||||||
|
test-fixture.workspace = true
|
||||||
sourcegen.workspace = true
|
sourcegen.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
|
@ -280,8 +280,9 @@ fn module_distance_heuristic(db: &dyn HirDatabase, current: &Module, item: &Modu
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use hir::{Semantics, WithFixture};
|
use hir::Semantics;
|
||||||
use ide_db::{assists::AssistResolveStrategy, base_db::FileRange, RootDatabase};
|
use ide_db::{assists::AssistResolveStrategy, base_db::FileRange, RootDatabase};
|
||||||
|
use test_fixture::WithFixture;
|
||||||
|
|
||||||
use crate::tests::{
|
use crate::tests::{
|
||||||
check_assist, check_assist_by_label, check_assist_not_applicable, check_assist_target,
|
check_assist, check_assist_by_label, check_assist_not_applicable, check_assist_target,
|
||||||
|
|
|
@ -3,7 +3,7 @@ mod generated;
|
||||||
mod sourcegen;
|
mod sourcegen;
|
||||||
|
|
||||||
use expect_test::expect;
|
use expect_test::expect;
|
||||||
use hir::{Semantics, WithFixture};
|
use hir::Semantics;
|
||||||
use ide_db::{
|
use ide_db::{
|
||||||
base_db::{FileId, FileRange, SourceDatabaseExt},
|
base_db::{FileId, FileRange, SourceDatabaseExt},
|
||||||
imports::insert_use::{ImportGranularity, InsertUseConfig},
|
imports::insert_use::{ImportGranularity, InsertUseConfig},
|
||||||
|
@ -12,6 +12,7 @@ use ide_db::{
|
||||||
};
|
};
|
||||||
use stdx::{format_to, trim_indent};
|
use stdx::{format_to, trim_indent};
|
||||||
use syntax::TextRange;
|
use syntax::TextRange;
|
||||||
|
use test_fixture::WithFixture;
|
||||||
use test_utils::{assert_eq_text, extract_offset};
|
use test_utils::{assert_eq_text, extract_offset};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -275,8 +275,8 @@ fn from_field_name(expr: &ast::Expr) -> Option<String> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use hir::WithFixture;
|
|
||||||
use ide_db::base_db::FileRange;
|
use ide_db::base_db::FileRange;
|
||||||
|
use test_fixture::WithFixture;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
|
|
@ -35,3 +35,4 @@ expect-test = "1.4.0"
|
||||||
|
|
||||||
# local deps
|
# local deps
|
||||||
test-utils.workspace = true
|
test-utils.workspace = true
|
||||||
|
test-fixture.workspace = true
|
||||||
|
|
|
@ -24,7 +24,7 @@ mod use_tree;
|
||||||
mod visibility;
|
mod visibility;
|
||||||
|
|
||||||
use expect_test::Expect;
|
use expect_test::Expect;
|
||||||
use hir::{ChangeFixture, PrefixKind};
|
use hir::PrefixKind;
|
||||||
use ide_db::{
|
use ide_db::{
|
||||||
base_db::{FileLoader, FilePosition},
|
base_db::{FileLoader, FilePosition},
|
||||||
imports::insert_use::{ImportGranularity, InsertUseConfig},
|
imports::insert_use::{ImportGranularity, InsertUseConfig},
|
||||||
|
@ -32,6 +32,7 @@ use ide_db::{
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use stdx::{format_to, trim_indent};
|
use stdx::{format_to, trim_indent};
|
||||||
|
use test_fixture::ChangeFixture;
|
||||||
use test_utils::assert_eq_text;
|
use test_utils::assert_eq_text;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
|
|
@ -16,7 +16,7 @@ cov-mark = "2.0.0-pre.1"
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
rayon.workspace = true
|
rayon.workspace = true
|
||||||
fst = { version = "0.4.7", default-features = false }
|
fst = { version = "0.4.7", default-features = false }
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash.workspace = true
|
||||||
once_cell = "1.17.0"
|
once_cell = "1.17.0"
|
||||||
either.workspace = true
|
either.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
|
@ -48,4 +48,5 @@ xshell.workspace = true
|
||||||
|
|
||||||
# local deps
|
# local deps
|
||||||
test-utils.workspace = true
|
test-utils.workspace = true
|
||||||
|
test-fixture.workspace = true
|
||||||
sourcegen.workspace = true
|
sourcegen.workspace = true
|
||||||
|
|
|
@ -11,7 +11,7 @@ use profile::{memory_usage, Bytes};
|
||||||
use rustc_hash::FxHashSet;
|
use rustc_hash::FxHashSet;
|
||||||
use triomphe::Arc;
|
use triomphe::Arc;
|
||||||
|
|
||||||
use crate::{fixture::Change, symbol_index::SymbolsDatabase, RootDatabase};
|
use crate::{symbol_index::SymbolsDatabase, Change, RootDatabase};
|
||||||
|
|
||||||
impl RootDatabase {
|
impl RootDatabase {
|
||||||
pub fn request_cancellation(&mut self) {
|
pub fn request_cancellation(&mut self) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use hir::{PrefixKind, WithFixture};
|
use hir::PrefixKind;
|
||||||
use stdx::trim_indent;
|
use stdx::trim_indent;
|
||||||
|
use test_fixture::WithFixture;
|
||||||
use test_utils::{assert_eq_text, CURSOR_MARKER};
|
use test_utils::{assert_eq_text, CURSOR_MARKER};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -43,10 +43,7 @@ pub mod syntax_helpers {
|
||||||
pub use parser::LexedStr;
|
pub use parser::LexedStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod fixture {
|
pub use hir::Change;
|
||||||
pub use hir::{Change, ChangeFixture, WithFixture};
|
|
||||||
pub const WORKSPACE: base_db::SourceRootId = base_db::SourceRootId(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
use std::{fmt, mem::ManuallyDrop};
|
use std::{fmt, mem::ManuallyDrop};
|
||||||
|
|
||||||
|
|
|
@ -379,7 +379,8 @@ impl Query {
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use expect_test::expect_file;
|
use expect_test::expect_file;
|
||||||
use hir::{symbols::SymbolCollector, WithFixture};
|
use hir::symbols::SymbolCollector;
|
||||||
|
use test_fixture::WithFixture;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
|
|
@ -115,8 +115,9 @@ fn assoc_item_of_trait(
|
||||||
mod tests {
|
mod tests {
|
||||||
use base_db::FilePosition;
|
use base_db::FilePosition;
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::{expect, Expect};
|
||||||
use hir::{ChangeFixture, Semantics};
|
use hir::Semantics;
|
||||||
use syntax::ast::{self, AstNode};
|
use syntax::ast::{self, AstNode};
|
||||||
|
use test_fixture::ChangeFixture;
|
||||||
|
|
||||||
use crate::RootDatabase;
|
use crate::RootDatabase;
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ expect-test = "1.4.0"
|
||||||
|
|
||||||
# local deps
|
# local deps
|
||||||
test-utils.workspace = true
|
test-utils.workspace = true
|
||||||
|
test-fixture.workspace = true
|
||||||
sourcegen.workspace = true
|
sourcegen.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
mod sourcegen;
|
mod sourcegen;
|
||||||
|
|
||||||
use expect_test::Expect;
|
use expect_test::Expect;
|
||||||
use hir::WithFixture;
|
|
||||||
use ide_db::{
|
use ide_db::{
|
||||||
assists::AssistResolveStrategy, base_db::SourceDatabaseExt, LineIndexDatabase, RootDatabase,
|
assists::AssistResolveStrategy, base_db::SourceDatabaseExt, LineIndexDatabase, RootDatabase,
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use stdx::trim_indent;
|
use stdx::trim_indent;
|
||||||
|
use test_fixture::WithFixture;
|
||||||
use test_utils::{assert_eq_text, extract_annotations, MiniCore};
|
use test_utils::{assert_eq_text, extract_annotations, MiniCore};
|
||||||
|
|
||||||
use crate::{DiagnosticsConfig, ExprFillDefaultMode, Severity};
|
use crate::{DiagnosticsConfig, ExprFillDefaultMode, Severity};
|
||||||
|
|
|
@ -31,3 +31,4 @@ expect-test = "1.4.0"
|
||||||
|
|
||||||
# local deps
|
# local deps
|
||||||
test-utils.workspace = true
|
test-utils.workspace = true
|
||||||
|
test-fixture.workspace = true
|
||||||
|
|
|
@ -65,8 +65,8 @@ fn parser_undefined_placeholder_in_replacement() {
|
||||||
/// `code` may optionally contain a cursor marker `$0`. If it doesn't, then the position will be
|
/// `code` may optionally contain a cursor marker `$0`. If it doesn't, then the position will be
|
||||||
/// the start of the file. If there's a second cursor marker, then we'll return a single range.
|
/// the start of the file. If there's a second cursor marker, then we'll return a single range.
|
||||||
pub(crate) fn single_file(code: &str) -> (ide_db::RootDatabase, FilePosition, Vec<FileRange>) {
|
pub(crate) fn single_file(code: &str) -> (ide_db::RootDatabase, FilePosition, Vec<FileRange>) {
|
||||||
use hir::WithFixture;
|
|
||||||
use ide_db::symbol_index::SymbolsDatabase;
|
use ide_db::symbol_index::SymbolsDatabase;
|
||||||
|
use test_fixture::{WithFixture, WORKSPACE};
|
||||||
let (mut db, file_id, range_or_offset) = if code.contains(test_utils::CURSOR_MARKER) {
|
let (mut db, file_id, range_or_offset) = if code.contains(test_utils::CURSOR_MARKER) {
|
||||||
ide_db::RootDatabase::with_range_or_offset(code)
|
ide_db::RootDatabase::with_range_or_offset(code)
|
||||||
} else {
|
} else {
|
||||||
|
@ -86,7 +86,7 @@ pub(crate) fn single_file(code: &str) -> (ide_db::RootDatabase, FilePosition, Ve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut local_roots = FxHashSet::default();
|
let mut local_roots = FxHashSet::default();
|
||||||
local_roots.insert(ide_db::fixture::WORKSPACE);
|
local_roots.insert(WORKSPACE);
|
||||||
db.set_local_roots_with_durability(Arc::new(local_roots), Durability::HIGH);
|
db.set_local_roots_with_durability(Arc::new(local_roots), Durability::HIGH);
|
||||||
(db, position, selections)
|
(db, position, selections)
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ expect-test = "1.4.0"
|
||||||
|
|
||||||
# local deps
|
# local deps
|
||||||
test-utils.workspace = true
|
test-utils.workspace = true
|
||||||
|
test-fixture.workspace = true
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
in-rust-tree = ["ide-assists/in-rust-tree", "ide-diagnostics/in-rust-tree"]
|
in-rust-tree = ["ide-assists/in-rust-tree", "ide-diagnostics/in-rust-tree"]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//! Utilities for creating `Analysis` instances for tests.
|
//! Utilities for creating `Analysis` instances for tests.
|
||||||
use ide_db::fixture::ChangeFixture;
|
use test_fixture::ChangeFixture;
|
||||||
use test_utils::{extract_annotations, RangeOrOffset};
|
use test_utils::{extract_annotations, RangeOrOffset};
|
||||||
|
|
||||||
use crate::{Analysis, AnalysisHost, FileId, FilePosition, FileRange};
|
use crate::{Analysis, AnalysisHost, FileId, FilePosition, FileRange};
|
||||||
|
|
|
@ -646,8 +646,9 @@ mod tests {
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::{expect, Expect};
|
||||||
use ide_db::{base_db::FilePosition, fixture::ChangeFixture};
|
use ide_db::base_db::FilePosition;
|
||||||
use stdx::format_to;
|
use stdx::format_to;
|
||||||
|
use test_fixture::ChangeFixture;
|
||||||
|
|
||||||
use crate::RootDatabase;
|
use crate::RootDatabase;
|
||||||
|
|
||||||
|
|
|
@ -60,10 +60,10 @@ mod tests {
|
||||||
use ide_assists::{Assist, AssistResolveStrategy};
|
use ide_assists::{Assist, AssistResolveStrategy};
|
||||||
use ide_db::{
|
use ide_db::{
|
||||||
base_db::{salsa::Durability, FileRange},
|
base_db::{salsa::Durability, FileRange},
|
||||||
fixture::WithFixture,
|
|
||||||
symbol_index::SymbolsDatabase,
|
symbol_index::SymbolsDatabase,
|
||||||
FxHashSet, RootDatabase,
|
FxHashSet, RootDatabase,
|
||||||
};
|
};
|
||||||
|
use test_fixture::WithFixture;
|
||||||
use triomphe::Arc;
|
use triomphe::Arc;
|
||||||
|
|
||||||
use super::ssr_assists;
|
use super::ssr_assists;
|
||||||
|
@ -71,7 +71,7 @@ mod tests {
|
||||||
fn get_assists(ra_fixture: &str, resolve: AssistResolveStrategy) -> Vec<Assist> {
|
fn get_assists(ra_fixture: &str, resolve: AssistResolveStrategy) -> Vec<Assist> {
|
||||||
let (mut db, file_id, range_or_offset) = RootDatabase::with_range_or_offset(ra_fixture);
|
let (mut db, file_id, range_or_offset) = RootDatabase::with_range_or_offset(ra_fixture);
|
||||||
let mut local_roots = FxHashSet::default();
|
let mut local_roots = FxHashSet::default();
|
||||||
local_roots.insert(ide_db::fixture::WORKSPACE);
|
local_roots.insert(test_fixture::WORKSPACE);
|
||||||
db.set_local_roots_with_durability(Arc::new(local_roots), Durability::HIGH);
|
db.set_local_roots_with_durability(Arc::new(local_roots), Durability::HIGH);
|
||||||
ssr_assists(&db, &resolve, FileRange { file_id, range: range_or_offset.into() })
|
ssr_assists(&db, &resolve, FileRange { file_id, range: range_or_offset.into() })
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,5 +16,5 @@ doctest = false
|
||||||
# We need to freeze the version of the crate, as the raw-api feature is considered unstable
|
# We need to freeze the version of the crate, as the raw-api feature is considered unstable
|
||||||
dashmap.workspace = true
|
dashmap.workspace = true
|
||||||
hashbrown.workspace = true
|
hashbrown.workspace = true
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash.workspace = true
|
||||||
triomphe.workspace = true
|
triomphe.workspace = true
|
||||||
|
|
|
@ -12,7 +12,7 @@ authors.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
crossbeam-channel = "0.5.5"
|
crossbeam-channel.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,7 @@ use hir_expand::proc_macro::{
|
||||||
use ide::{AnalysisHost, SourceRoot};
|
use ide::{AnalysisHost, SourceRoot};
|
||||||
use ide_db::{
|
use ide_db::{
|
||||||
base_db::{CrateGraph, Env},
|
base_db::{CrateGraph, Env},
|
||||||
fixture::Change,
|
Change, FxHashMap,
|
||||||
FxHashMap,
|
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use proc_macro_api::{MacroDylib, ProcMacroServer};
|
use proc_macro_api::{MacroDylib, ProcMacroServer};
|
||||||
|
|
|
@ -13,7 +13,7 @@ doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cov-mark = "2.0.0-pre.1"
|
cov-mark = "2.0.0-pre.1"
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash.workspace = true
|
||||||
smallvec.workspace = true
|
smallvec.workspace = true
|
||||||
tracing.workspace = true
|
tracing.workspace = true
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ doctest = false
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
cargo_metadata.workspace = true
|
cargo_metadata.workspace = true
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash.workspace = true
|
||||||
semver = "1.0.14"
|
semver = "1.0.14"
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
|
|
|
@ -29,7 +29,7 @@ parking_lot = "0.12.1"
|
||||||
xflags = "0.3.0"
|
xflags = "0.3.0"
|
||||||
oorandom = "11.1.3"
|
oorandom = "11.1.3"
|
||||||
rayon.workspace = true
|
rayon.workspace = true
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash.workspace = true
|
||||||
serde_json = { workspace = true, features = ["preserve_order"] }
|
serde_json = { workspace = true, features = ["preserve_order"] }
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
num_cpus = "1.15.0"
|
num_cpus = "1.15.0"
|
||||||
|
@ -76,6 +76,7 @@ expect-test = "1.4.0"
|
||||||
xshell.workspace = true
|
xshell.workspace = true
|
||||||
|
|
||||||
test-utils.workspace = true
|
test-utils.workspace = true
|
||||||
|
test-fixture.workspace = true
|
||||||
sourcegen.workspace = true
|
sourcegen.workspace = true
|
||||||
mbe.workspace = true
|
mbe.workspace = true
|
||||||
|
|
||||||
|
|
|
@ -278,8 +278,8 @@ fn token_to_symbol(token: &TokenStaticData) -> Option<scip_types::Symbol> {
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use ide::{AnalysisHost, FilePosition, StaticIndex, TextSize};
|
use ide::{AnalysisHost, FilePosition, StaticIndex, TextSize};
|
||||||
use ide_db::fixture::ChangeFixture;
|
|
||||||
use scip::symbol::format_symbol;
|
use scip::symbol::format_symbol;
|
||||||
|
use test_fixture::ChangeFixture;
|
||||||
|
|
||||||
fn position(ra_fixture: &str) -> (AnalysisHost, FilePosition) {
|
fn position(ra_fixture: &str) -> (AnalysisHost, FilePosition) {
|
||||||
let mut host = AnalysisHost::default();
|
let mut host = AnalysisHost::default();
|
||||||
|
|
|
@ -17,7 +17,7 @@ cov-mark = "2.0.0-pre.1"
|
||||||
either.workspace = true
|
either.workspace = true
|
||||||
itertools.workspace = true
|
itertools.workspace = true
|
||||||
rowan = "0.15.15"
|
rowan = "0.15.15"
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash.workspace = true
|
||||||
once_cell = "1.17.0"
|
once_cell = "1.17.0"
|
||||||
indexmap.workspace = true
|
indexmap.workspace = true
|
||||||
smol_str.workspace = true
|
smol_str.workspace = true
|
||||||
|
|
18
crates/test-fixture/Cargo.toml
Normal file
18
crates/test-fixture/Cargo.toml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
[package]
|
||||||
|
name = "test-fixture"
|
||||||
|
version = "0.0.0"
|
||||||
|
rust-version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
authors.workspace = true
|
||||||
|
publish = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
hir-expand.workspace = true
|
||||||
|
test-utils.workspace = true
|
||||||
|
tt.workspace = true
|
||||||
|
cfg.workspace = true
|
||||||
|
base-db.workspace = true
|
||||||
|
rustc-hash.workspace = true
|
||||||
|
span.workspace = true
|
||||||
|
stdx.workspace = true
|
|
@ -2,24 +2,27 @@
|
||||||
use std::{mem, ops::Not, str::FromStr, sync};
|
use std::{mem, ops::Not, str::FromStr, sync};
|
||||||
|
|
||||||
use base_db::{
|
use base_db::{
|
||||||
salsa::Durability, CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency,
|
CrateDisplayName, CrateGraph, CrateId, CrateName, CrateOrigin, Dependency, DependencyKind,
|
||||||
DependencyKind, Edition, Env, FileChange, FileSet, LangCrateOrigin, ReleaseChannel,
|
Edition, Env, FileChange, FileSet, LangCrateOrigin, ReleaseChannel, SourceDatabaseExt,
|
||||||
SourceDatabaseExt, SourceRoot, VfsPath,
|
SourceRoot, VfsPath,
|
||||||
};
|
};
|
||||||
use cfg::CfgOptions;
|
use cfg::CfgOptions;
|
||||||
|
use hir_expand::{
|
||||||
|
change::Change,
|
||||||
|
db::ExpandDatabase,
|
||||||
|
proc_macro::{
|
||||||
|
ProcMacro, ProcMacroExpander, ProcMacroExpansionError, ProcMacroKind, ProcMacros,
|
||||||
|
},
|
||||||
|
};
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use span::{FileId, FilePosition, FileRange, Span};
|
use span::{FileId, FilePosition, FileRange, Span};
|
||||||
use test_utils::{
|
use test_utils::{
|
||||||
extract_range_or_offset, Fixture, FixtureWithProjectMeta, RangeOrOffset, CURSOR_MARKER,
|
extract_range_or_offset, Fixture, FixtureWithProjectMeta, RangeOrOffset, CURSOR_MARKER,
|
||||||
ESCAPED_CURSOR_MARKER,
|
ESCAPED_CURSOR_MARKER,
|
||||||
};
|
};
|
||||||
use triomphe::Arc;
|
|
||||||
use tt::{Leaf, Subtree, TokenTree};
|
use tt::{Leaf, Subtree, TokenTree};
|
||||||
|
|
||||||
use crate::{
|
pub const WORKSPACE: base_db::SourceRootId = base_db::SourceRootId(0);
|
||||||
db::ExpandDatabase,
|
|
||||||
proc_macro::{ProcMacro, ProcMacroExpander, ProcMacroExpansionError, ProcMacros},
|
|
||||||
};
|
|
||||||
|
|
||||||
pub trait WithFixture: Default + ExpandDatabase + SourceDatabaseExt + 'static {
|
pub trait WithFixture: Default + ExpandDatabase + SourceDatabaseExt + 'static {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
|
@ -98,41 +101,6 @@ pub trait WithFixture: Default + ExpandDatabase + SourceDatabaseExt + 'static {
|
||||||
|
|
||||||
impl<DB: ExpandDatabase + SourceDatabaseExt + Default + 'static> WithFixture for DB {}
|
impl<DB: ExpandDatabase + SourceDatabaseExt + Default + 'static> WithFixture for DB {}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
|
||||||
pub struct Change {
|
|
||||||
pub source_change: FileChange,
|
|
||||||
pub proc_macros: Option<ProcMacros>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Change {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self::default()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn apply(self, db: &mut (impl ExpandDatabase + SourceDatabaseExt)) {
|
|
||||||
self.source_change.apply(db);
|
|
||||||
if let Some(proc_macros) = self.proc_macros {
|
|
||||||
db.set_proc_macros_with_durability(Arc::new(proc_macros), Durability::HIGH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn change_file(&mut self, file_id: FileId, new_text: Option<Arc<str>>) {
|
|
||||||
self.source_change.change_file(file_id, new_text)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_crate_graph(&mut self, graph: CrateGraph) {
|
|
||||||
self.source_change.set_crate_graph(graph)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_proc_macros(&mut self, proc_macros: ProcMacros) {
|
|
||||||
self.proc_macros = Some(proc_macros);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_roots(&mut self, roots: Vec<SourceRoot>) {
|
|
||||||
self.source_change.set_roots(roots)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct ChangeFixture {
|
pub struct ChangeFixture {
|
||||||
pub file_position: Option<(FileId, RangeOrOffset)>,
|
pub file_position: Option<(FileId, RangeOrOffset)>,
|
||||||
pub files: Vec<FileId>,
|
pub files: Vec<FileId>,
|
||||||
|
@ -223,7 +191,7 @@ impl ChangeFixture {
|
||||||
origin,
|
origin,
|
||||||
meta.target_data_layout
|
meta.target_data_layout
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map(Arc::from)
|
.map(From::from)
|
||||||
.ok_or_else(|| "target_data_layout unset".into()),
|
.ok_or_else(|| "target_data_layout unset".into()),
|
||||||
Some(toolchain),
|
Some(toolchain),
|
||||||
);
|
);
|
||||||
|
@ -242,7 +210,7 @@ impl ChangeFixture {
|
||||||
default_target_data_layout = meta.target_data_layout;
|
default_target_data_layout = meta.target_data_layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
source_change.change_file(file_id, Some(Arc::from(text)));
|
source_change.change_file(file_id, Some(text.into()));
|
||||||
let path = VfsPath::new_virtual_path(meta.path);
|
let path = VfsPath::new_virtual_path(meta.path);
|
||||||
file_set.insert(file_id, path);
|
file_set.insert(file_id, path);
|
||||||
files.push(file_id);
|
files.push(file_id);
|
||||||
|
@ -297,7 +265,7 @@ impl ChangeFixture {
|
||||||
fs.insert(core_file, VfsPath::new_virtual_path("/sysroot/core/lib.rs".to_string()));
|
fs.insert(core_file, VfsPath::new_virtual_path("/sysroot/core/lib.rs".to_string()));
|
||||||
roots.push(SourceRoot::new_library(fs));
|
roots.push(SourceRoot::new_library(fs));
|
||||||
|
|
||||||
source_change.change_file(core_file, Some(Arc::from(mini_core.source_code())));
|
source_change.change_file(core_file, Some(mini_core.source_code().into()));
|
||||||
|
|
||||||
let all_crates = crate_graph.crates_in_topological_order();
|
let all_crates = crate_graph.crates_in_topological_order();
|
||||||
|
|
||||||
|
@ -342,7 +310,7 @@ impl ChangeFixture {
|
||||||
);
|
);
|
||||||
roots.push(SourceRoot::new_library(fs));
|
roots.push(SourceRoot::new_library(fs));
|
||||||
|
|
||||||
source_change.change_file(proc_lib_file, Some(Arc::from(source)));
|
source_change.change_file(proc_lib_file, Some(source.into()));
|
||||||
|
|
||||||
let all_crates = crate_graph.crates_in_topological_order();
|
let all_crates = crate_graph.crates_in_topological_order();
|
||||||
|
|
||||||
|
@ -406,7 +374,7 @@ pub fn identity(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
.into(),
|
.into(),
|
||||||
ProcMacro {
|
ProcMacro {
|
||||||
name: "identity".into(),
|
name: "identity".into(),
|
||||||
kind: crate::ProcMacroKind::Attr,
|
kind: ProcMacroKind::Attr,
|
||||||
expander: sync::Arc::new(IdentityProcMacroExpander),
|
expander: sync::Arc::new(IdentityProcMacroExpander),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -420,7 +388,7 @@ pub fn derive_identity(item: TokenStream) -> TokenStream {
|
||||||
.into(),
|
.into(),
|
||||||
ProcMacro {
|
ProcMacro {
|
||||||
name: "DeriveIdentity".into(),
|
name: "DeriveIdentity".into(),
|
||||||
kind: crate::ProcMacroKind::CustomDerive,
|
kind: ProcMacroKind::CustomDerive,
|
||||||
expander: sync::Arc::new(IdentityProcMacroExpander),
|
expander: sync::Arc::new(IdentityProcMacroExpander),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -434,7 +402,7 @@ pub fn input_replace(attr: TokenStream, _item: TokenStream) -> TokenStream {
|
||||||
.into(),
|
.into(),
|
||||||
ProcMacro {
|
ProcMacro {
|
||||||
name: "input_replace".into(),
|
name: "input_replace".into(),
|
||||||
kind: crate::ProcMacroKind::Attr,
|
kind: ProcMacroKind::Attr,
|
||||||
expander: sync::Arc::new(AttributeInputReplaceProcMacroExpander),
|
expander: sync::Arc::new(AttributeInputReplaceProcMacroExpander),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -448,7 +416,7 @@ pub fn mirror(input: TokenStream) -> TokenStream {
|
||||||
.into(),
|
.into(),
|
||||||
ProcMacro {
|
ProcMacro {
|
||||||
name: "mirror".into(),
|
name: "mirror".into(),
|
||||||
kind: crate::ProcMacroKind::FuncLike,
|
kind: ProcMacroKind::FuncLike,
|
||||||
expander: sync::Arc::new(MirrorProcMacroExpander),
|
expander: sync::Arc::new(MirrorProcMacroExpander),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -462,7 +430,7 @@ pub fn shorten(input: TokenStream) -> TokenStream {
|
||||||
.into(),
|
.into(),
|
||||||
ProcMacro {
|
ProcMacro {
|
||||||
name: "shorten".into(),
|
name: "shorten".into(),
|
||||||
kind: crate::ProcMacroKind::FuncLike,
|
kind: ProcMacroKind::FuncLike,
|
||||||
expander: sync::Arc::new(ShortenProcMacroExpander),
|
expander: sync::Arc::new(ShortenProcMacroExpander),
|
||||||
},
|
},
|
||||||
),
|
),
|
|
@ -15,7 +15,7 @@ doctest = false
|
||||||
# Avoid adding deps here, this crate is widely used in tests it should compile fast!
|
# Avoid adding deps here, this crate is widely used in tests it should compile fast!
|
||||||
dissimilar = "1.0.7"
|
dissimilar = "1.0.7"
|
||||||
text-size.workspace = true
|
text-size.workspace = true
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash.workspace = true
|
||||||
|
|
||||||
stdx.workspace = true
|
stdx.workspace = true
|
||||||
profile.workspace = true
|
profile.workspace = true
|
||||||
|
|
|
@ -12,7 +12,7 @@ rust-version.workspace = true
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash.workspace = true
|
||||||
fst = "0.4.7"
|
fst = "0.4.7"
|
||||||
indexmap.workspace = true
|
indexmap.workspace = true
|
||||||
nohash-hasher.workspace = true
|
nohash-hasher.workspace = true
|
||||||
|
|
Loading…
Reference in a new issue