aboutsummaryrefslogtreecommitdiff
path: root/crates/base_db
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-02-22 13:15:04 +0000
committerGitHub <[email protected]>2021-02-22 13:15:04 +0000
commit7775d92b47d43f655db5cf9408a3ecb2379de217 (patch)
treeb4602b819847b6d7419048dd26b29374bd28f18b /crates/base_db
parent14de9e54a6d9ef070399b34a11634294a8cc3ca5 (diff)
parent58be1edfbb86658dcf9ce58800f53ef2a333b7da (diff)
Merge #7749
7749: Make more common assist easier to ues r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/base_db')
-rw-r--r--crates/base_db/src/fixture.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/base_db/src/fixture.rs b/crates/base_db/src/fixture.rs
index 98acd61b1..5c9824814 100644
--- a/crates/base_db/src/fixture.rs
+++ b/crates/base_db/src/fixture.rs
@@ -67,7 +67,7 @@ use test_utils::{
67use vfs::{file_set::FileSet, VfsPath}; 67use vfs::{file_set::FileSet, VfsPath};
68 68
69use crate::{ 69use crate::{
70 input::CrateName, Change, CrateGraph, CrateId, Edition, Env, FileId, FilePosition, 70 input::CrateName, Change, CrateGraph, CrateId, Edition, Env, FileId, FilePosition, FileRange,
71 SourceDatabaseExt, SourceRoot, SourceRootId, 71 SourceDatabaseExt, SourceRoot, SourceRootId,
72}; 72};
73 73
@@ -99,6 +99,15 @@ pub trait WithFixture: Default + SourceDatabaseExt + 'static {
99 (db, FilePosition { file_id, offset }) 99 (db, FilePosition { file_id, offset })
100 } 100 }
101 101
102 fn with_range(ra_fixture: &str) -> (Self, FileRange) {
103 let (db, file_id, range_or_offset) = Self::with_range_or_offset(ra_fixture);
104 let range = match range_or_offset {
105 RangeOrOffset::Range(it) => it,
106 RangeOrOffset::Offset(_) => panic!(),
107 };
108 (db, FileRange { file_id, range })
109 }
110
102 fn with_range_or_offset(ra_fixture: &str) -> (Self, FileId, RangeOrOffset) { 111 fn with_range_or_offset(ra_fixture: &str) -> (Self, FileId, RangeOrOffset) {
103 let fixture = ChangeFixture::parse(ra_fixture); 112 let fixture = ChangeFixture::parse(ra_fixture);
104 let mut db = Self::default(); 113 let mut db = Self::default();