mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Add convenience method for testing
This commit is contained in:
parent
3564fbb7f5
commit
5766ceab06
4 changed files with 15 additions and 7 deletions
|
@ -8,8 +8,8 @@ use rustc_hash::FxHashMap;
|
|||
use test_utils::{extract_offset, parse_fixture, CURSOR_MARKER};
|
||||
|
||||
use crate::{
|
||||
CrateGraph, Edition, FileId, FilePosition, RelativePathBuf, SourceDatabaseExt, SourceRoot,
|
||||
SourceRootId,
|
||||
CrateGraph, CrateId, Edition, FileId, FilePosition, RelativePathBuf, SourceDatabaseExt,
|
||||
SourceRoot, SourceRootId,
|
||||
};
|
||||
|
||||
pub const WORKSPACE: SourceRootId = SourceRootId(0);
|
||||
|
@ -33,6 +33,14 @@ pub trait WithFixture: Default + SourceDatabaseExt + 'static {
|
|||
let pos = with_files(&mut db, fixture);
|
||||
(db, pos.unwrap())
|
||||
}
|
||||
|
||||
fn test_crate(&self) -> CrateId {
|
||||
let crate_graph = self.crate_graph();
|
||||
let mut it = crate_graph.iter();
|
||||
let res = it.next().unwrap();
|
||||
assert!(it.next().is_none());
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
impl<DB: SourceDatabaseExt + Default + 'static> WithFixture for DB {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue