@@ -48,10 +48,17 @@ impl<'a> Extractor<'a> {
4848 ast,
4949 text,
5050 errors,
51- semantics_info,
51+ mut semantics_info,
5252 } = rust_analyzer. parse ( file) ;
5353 self . steps . push ( ExtractionStep :: parse ( before_parse, file) ) ;
54-
54+ if let Ok ( info) = & semantics_info {
55+ let before_load = Instant :: now ( ) ;
56+ if info. semantics . to_def ( & ast) . is_none ( ) {
57+ semantics_info = Err ( "not included as a module" ) ;
58+ }
59+ self . steps
60+ . push ( ExtractionStep :: load_source ( before_load, file) ) ;
61+ }
5562 let before_extract = Instant :: now ( ) ;
5663 let line_index = LineIndex :: new ( text. as_ref ( ) ) ;
5764 let display_path = file. to_string_lossy ( ) ;
@@ -119,20 +126,10 @@ impl<'a> Extractor<'a> {
119126 ret
120127 }
121128
122- pub fn load_source (
123- & mut self ,
124- file : & Path ,
125- semantics : & Semantics < ' _ , RootDatabase > ,
126- vfs : & Vfs ,
127- ) -> Result < ( ) , String > {
128- let before = Instant :: now ( ) ;
129- let Some ( id) = path_to_file_id ( file, vfs) else {
129+ pub fn check_file ( & mut self , file : & Path , vfs : & Vfs ) -> Result < ( ) , String > {
130+ if path_to_file_id ( file, vfs) . is_none ( ) {
130131 return Err ( "not included in files loaded from manifest" . to_string ( ) ) ;
131132 } ;
132- if semantics. file_to_module_def ( id) . is_none ( ) {
133- return Err ( "not included as a module" . to_string ( ) ) ;
134- }
135- self . steps . push ( ExtractionStep :: load_source ( before, file) ) ;
136133 Ok ( ( ) )
137134 }
138135
@@ -206,7 +203,7 @@ fn main() -> anyhow::Result<()> {
206203 if let Some ( ( ref db, ref vfs) ) = extractor. load_manifest ( manifest, & cargo_config) {
207204 let semantics = Semantics :: new ( db) ;
208205 for file in files {
209- match extractor. load_source ( file, & semantics , vfs) {
206+ match extractor. check_file ( file, vfs) {
210207 Ok ( ( ) ) => extractor. extract_with_semantics ( file, & semantics, vfs) ,
211208 Err ( reason) => extractor. extract_without_semantics ( file, & reason) ,
212209 } ;
0 commit comments