From 58be1edfbb86658dcf9ce58800f53ef2a333b7da Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 22 Feb 2021 15:18:11 +0300 Subject: Make more common assist easier to ues --- crates/base_db/src/fixture.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'crates/base_db') 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::{ use vfs::{file_set::FileSet, VfsPath}; use crate::{ - input::CrateName, Change, CrateGraph, CrateId, Edition, Env, FileId, FilePosition, + input::CrateName, Change, CrateGraph, CrateId, Edition, Env, FileId, FilePosition, FileRange, SourceDatabaseExt, SourceRoot, SourceRootId, }; @@ -99,6 +99,15 @@ pub trait WithFixture: Default + SourceDatabaseExt + 'static { (db, FilePosition { file_id, offset }) } + fn with_range(ra_fixture: &str) -> (Self, FileRange) { + let (db, file_id, range_or_offset) = Self::with_range_or_offset(ra_fixture); + let range = match range_or_offset { + RangeOrOffset::Range(it) => it, + RangeOrOffset::Offset(_) => panic!(), + }; + (db, FileRange { file_id, range }) + } + fn with_range_or_offset(ra_fixture: &str) -> (Self, FileId, RangeOrOffset) { let fixture = ChangeFixture::parse(ra_fixture); let mut db = Self::default(); -- cgit v1.2.3