1
- //! FIXME: write short doc here
2
-
1
+ //! Utilities for creating `Analysis` instances for tests.
3
2
use base_db:: fixture:: ChangeFixture ;
4
3
use test_utils:: { extract_annotations, RangeOrOffset } ;
5
4
6
5
use crate :: { Analysis , AnalysisHost , FileId , FilePosition , FileRange } ;
7
6
8
- /// Creates analysis from a multi-file fixture, returns positions marked with <|> .
9
- pub ( crate ) fn analysis_and_position ( ra_fixture : & str ) -> ( Analysis , FilePosition ) {
7
+ /// Creates analysis for a single file .
8
+ pub ( crate ) fn file ( ra_fixture : & str ) -> ( Analysis , FileId ) {
10
9
let mut host = AnalysisHost :: default ( ) ;
11
10
let change_fixture = ChangeFixture :: parse ( ra_fixture) ;
12
11
host. db . apply_change ( change_fixture. change ) ;
13
- let ( file_id, range_or_offset) = change_fixture. file_position . expect ( "expected a marker (<|>)" ) ;
14
- let offset = match range_or_offset {
15
- RangeOrOffset :: Range ( _) => panic ! ( ) ,
16
- RangeOrOffset :: Offset ( it) => it,
17
- } ;
18
- ( host. analysis ( ) , FilePosition { file_id, offset } )
12
+ ( host. analysis ( ) , change_fixture. files [ 0 ] )
19
13
}
20
14
21
- /// Creates analysis for a single file .
22
- pub ( crate ) fn single_file ( ra_fixture : & str ) -> ( Analysis , FileId ) {
15
+ /// Creates analysis for many files .
16
+ pub ( crate ) fn files ( ra_fixture : & str ) -> ( Analysis , Vec < FileId > ) {
23
17
let mut host = AnalysisHost :: default ( ) ;
24
18
let change_fixture = ChangeFixture :: parse ( ra_fixture) ;
25
19
host. db . apply_change ( change_fixture. change ) ;
26
- ( host. analysis ( ) , change_fixture. files [ 0 ] )
20
+ ( host. analysis ( ) , change_fixture. files )
27
21
}
28
22
29
- /// Creates analysis for a single file.
30
- pub ( crate ) fn many_files ( ra_fixture : & str ) -> ( Analysis , Vec < FileId > ) {
23
+ /// Creates analysis from a multi- file fixture, returns positions marked with <|> .
24
+ pub ( crate ) fn position ( ra_fixture : & str ) -> ( Analysis , FilePosition ) {
31
25
let mut host = AnalysisHost :: default ( ) ;
32
26
let change_fixture = ChangeFixture :: parse ( ra_fixture) ;
33
27
host. db . apply_change ( change_fixture. change ) ;
34
- ( host. analysis ( ) , change_fixture. files )
28
+ let ( file_id, range_or_offset) = change_fixture. file_position . expect ( "expected a marker (<|>)" ) ;
29
+ let offset = match range_or_offset {
30
+ RangeOrOffset :: Range ( _) => panic ! ( ) ,
31
+ RangeOrOffset :: Offset ( it) => it,
32
+ } ;
33
+ ( host. analysis ( ) , FilePosition { file_id, offset } )
35
34
}
36
35
37
36
/// Creates analysis for a single file, returns range marked with a pair of <|>.
38
- pub ( crate ) fn analysis_and_range ( ra_fixture : & str ) -> ( Analysis , FileRange ) {
37
+ pub ( crate ) fn range ( ra_fixture : & str ) -> ( Analysis , FileRange ) {
39
38
let mut host = AnalysisHost :: default ( ) ;
40
39
let change_fixture = ChangeFixture :: parse ( ra_fixture) ;
41
40
host. db . apply_change ( change_fixture. change ) ;
@@ -48,9 +47,7 @@ pub(crate) fn analysis_and_range(ra_fixture: &str) -> (Analysis, FileRange) {
48
47
}
49
48
50
49
/// Creates analysis from a multi-file fixture, returns positions marked with <|>.
51
- pub ( crate ) fn analysis_and_annotations (
52
- ra_fixture : & str ,
53
- ) -> ( Analysis , FilePosition , Vec < ( FileRange , String ) > ) {
50
+ pub ( crate ) fn annotations ( ra_fixture : & str ) -> ( Analysis , FilePosition , Vec < ( FileRange , String ) > ) {
54
51
let mut host = AnalysisHost :: default ( ) ;
55
52
let change_fixture = ChangeFixture :: parse ( ra_fixture) ;
56
53
host. db . apply_change ( change_fixture. change ) ;
0 commit comments