@@ -14,7 +14,7 @@ use crate::{
14
14
/// Mock analysis is used in test to bootstrap an AnalysisHost/Analysis
15
15
/// from a set of in-memory files.
16
16
#[ derive( Debug , Default ) ]
17
- pub struct MockAnalysis {
17
+ pub ( crate ) struct MockAnalysis {
18
18
files : Vec < Fixture > ,
19
19
}
20
20
@@ -29,15 +29,15 @@ impl MockAnalysis {
29
29
/// //- /foo.rs
30
30
/// struct Baz;
31
31
/// ```
32
- pub fn with_files ( ra_fixture : & str ) -> MockAnalysis {
32
+ pub ( crate ) fn with_files ( ra_fixture : & str ) -> MockAnalysis {
33
33
let ( res, pos) = MockAnalysis :: with_fixture ( ra_fixture) ;
34
34
assert ! ( pos. is_none( ) ) ;
35
35
res
36
36
}
37
37
38
38
/// Same as `with_files`, but requires that a single file contains a `<|>` marker,
39
39
/// whose position is also returned.
40
- pub fn with_files_and_position ( fixture : & str ) -> ( MockAnalysis , FilePosition ) {
40
+ pub ( crate ) fn with_files_and_position ( fixture : & str ) -> ( MockAnalysis , FilePosition ) {
41
41
let ( res, position) = MockAnalysis :: with_fixture ( fixture) ;
42
42
let ( file_id, range_or_offset) = position. expect ( "expected a marker (<|>)" ) ;
43
43
let offset = match range_or_offset {
@@ -70,12 +70,12 @@ impl MockAnalysis {
70
70
file_id
71
71
}
72
72
73
- pub fn id_of ( & self , path : & str ) -> FileId {
73
+ pub ( crate ) fn id_of ( & self , path : & str ) -> FileId {
74
74
let ( file_id, _) =
75
75
self . files ( ) . find ( |( _, data) | path == data. path ) . expect ( "no file in this mock" ) ;
76
76
file_id
77
77
}
78
- pub fn annotations ( & self ) -> Vec < ( FileRange , String ) > {
78
+ pub ( crate ) fn annotations ( & self ) -> Vec < ( FileRange , String ) > {
79
79
self . files ( )
80
80
. flat_map ( |( file_id, fixture) | {
81
81
let annotations = extract_annotations ( & fixture. text ) ;
@@ -85,15 +85,15 @@ impl MockAnalysis {
85
85
} )
86
86
. collect ( )
87
87
}
88
- pub fn files ( & self ) -> impl Iterator < Item = ( FileId , & Fixture ) > + ' _ {
88
+ pub ( crate ) fn files ( & self ) -> impl Iterator < Item = ( FileId , & Fixture ) > + ' _ {
89
89
self . files . iter ( ) . enumerate ( ) . map ( |( idx, fixture) | ( FileId ( idx as u32 + 1 ) , fixture) )
90
90
}
91
- pub fn annotation ( & self ) -> ( FileRange , String ) {
91
+ pub ( crate ) fn annotation ( & self ) -> ( FileRange , String ) {
92
92
let mut all = self . annotations ( ) ;
93
93
assert_eq ! ( all. len( ) , 1 ) ;
94
94
all. pop ( ) . unwrap ( )
95
95
}
96
- pub fn analysis_host ( self ) -> AnalysisHost {
96
+ pub ( crate ) fn analysis_host ( self ) -> AnalysisHost {
97
97
let mut host = AnalysisHost :: default ( ) ;
98
98
let mut change = AnalysisChange :: new ( ) ;
99
99
let mut file_set = FileSet :: default ( ) ;
@@ -146,26 +146,26 @@ impl MockAnalysis {
146
146
host. apply_change ( change) ;
147
147
host
148
148
}
149
- pub fn analysis ( self ) -> Analysis {
149
+ pub ( crate ) fn analysis ( self ) -> Analysis {
150
150
self . analysis_host ( ) . analysis ( )
151
151
}
152
152
}
153
153
154
154
/// Creates analysis from a multi-file fixture, returns positions marked with <|>.
155
- pub fn analysis_and_position ( ra_fixture : & str ) -> ( Analysis , FilePosition ) {
155
+ pub ( crate ) fn analysis_and_position ( ra_fixture : & str ) -> ( Analysis , FilePosition ) {
156
156
let ( mock, position) = MockAnalysis :: with_files_and_position ( ra_fixture) ;
157
157
( mock. analysis ( ) , position)
158
158
}
159
159
160
160
/// Creates analysis for a single file.
161
- pub fn single_file ( ra_fixture : & str ) -> ( Analysis , FileId ) {
161
+ pub ( crate ) fn single_file ( ra_fixture : & str ) -> ( Analysis , FileId ) {
162
162
let mock = MockAnalysis :: with_files ( ra_fixture) ;
163
163
let file_id = mock. id_of ( "/main.rs" ) ;
164
164
( mock. analysis ( ) , file_id)
165
165
}
166
166
167
167
/// Creates analysis for a single file, returns range marked with a pair of <|>.
168
- pub fn analysis_and_range ( ra_fixture : & str ) -> ( Analysis , FileRange ) {
168
+ pub ( crate ) fn analysis_and_range ( ra_fixture : & str ) -> ( Analysis , FileRange ) {
169
169
let ( res, position) = MockAnalysis :: with_fixture ( ra_fixture) ;
170
170
let ( file_id, range_or_offset) = position. expect ( "expected a marker (<|>)" ) ;
171
171
let range = match range_or_offset {
0 commit comments