1- //! FIXME: write short doc here
2-
1+ //! Utilities for creating `Analysis` instances for tests.
32use base_db:: fixture:: ChangeFixture ;
43use test_utils:: { extract_annotations, RangeOrOffset } ;
54
65use crate :: { Analysis , AnalysisHost , FileId , FilePosition , FileRange } ;
76
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 ) {
109 let mut host = AnalysisHost :: default ( ) ;
1110 let change_fixture = ChangeFixture :: parse ( ra_fixture) ;
1211 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 ] )
1913}
2014
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 > ) {
2317 let mut host = AnalysisHost :: default ( ) ;
2418 let change_fixture = ChangeFixture :: parse ( ra_fixture) ;
2519 host. db . apply_change ( change_fixture. change ) ;
26- ( host. analysis ( ) , change_fixture. files [ 0 ] )
20+ ( host. analysis ( ) , change_fixture. files )
2721}
2822
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 ) {
3125 let mut host = AnalysisHost :: default ( ) ;
3226 let change_fixture = ChangeFixture :: parse ( ra_fixture) ;
3327 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 } )
3534}
3635
3736/// 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 ) {
3938 let mut host = AnalysisHost :: default ( ) ;
4039 let change_fixture = ChangeFixture :: parse ( ra_fixture) ;
4140 host. db . apply_change ( change_fixture. change ) ;
@@ -48,9 +47,7 @@ pub(crate) fn analysis_and_range(ra_fixture: &str) -> (Analysis, FileRange) {
4847}
4948
5049/// 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 ) > ) {
5451 let mut host = AnalysisHost :: default ( ) ;
5552 let change_fixture = ChangeFixture :: parse ( ra_fixture) ;
5653 host. db . apply_change ( change_fixture. change ) ;
0 commit comments