pub(crate) fn run(&mut self) {
        // NB: defer wildcard expansion until all other imports have been
        // indexed.
        let mut wildcard_imports = Vec::new();

        while let Some(task) = self.queue.pop_front() {
            match task {
                Task::LoadFile {
                    kind,
                    source_id,
                    mod_item,
                } => {
                    log::trace!("load file: {}", mod_item.item);

                    let source = match self.sources.get(source_id).cloned() {
                        Some(source) => source,
                        None => {
                            self.diagnostics
                                .internal(source_id, "missing queued source by id");
                            continue;
                        }
                    };

                    let mut file = match crate::parse_all::<ast::File>(source.as_str()) {
                        Ok(file) => file,
                        Err(error) => {
                            self.diagnostics.error(source_id, error);
                            continue;
                        }
                    };

                    let root = match kind {
                        LoadFileKind::Root => source.path().map(ToOwned::to_owned),
                        LoadFileKind::Module { root } => root,
                    };

                    log::trace!("index: {}", mod_item.item);
                    let items = Items::new(mod_item.item.clone(), self.gen.clone());

                    let mut indexer = Indexer {
                        root,
                        storage: self.query.storage(),
                        loaded: &mut self.loaded,
                        consts: self.consts.clone(),
                        query: self.query.clone(),
                        queue: &mut self.queue,
                        sources: self.sources,
                        context: self.context,
                        options: self.options,
                        source_id,
                        source,
                        diagnostics: self.diagnostics,
                        items,
                        scopes: IndexScopes::new(),
                        mod_item,
                        impl_item: Default::default(),
                        visitor: self.visitor.clone(),
                        source_loader: self.source_loader.clone(),
                        nested_item: None,
                    };

                    if let Err(error) = file.index(&mut indexer) {
                        indexer.diagnostics.error(source_id, error);
                    }
                }
                Task::ExpandImport(import) => {
                    let source_id = import.source_id;
                    let queue = &mut self.queue;

                    let result =
                        import.process(self.context, &self.storage, &self.query, &mut |task| {
                            queue.push_back(task);
                        });

                    if let Err(error) = result {
                        self.diagnostics.error(source_id, error);
                    }
                }
                Task::ExpandWildcardImport(wildcard_import) => {
                    wildcard_imports.push(wildcard_import);
                }
            }
        }

        for wildcard_import in wildcard_imports {
            let source_id = wildcard_import.source_id;

            if let Err(error) = wildcard_import.process_local(&self.query) {
                self.diagnostics.error(source_id, error);
            }
        }
    }
/// Run the worker until the task queue is empty.
Run the worker until the task queue is empty.
Run the worker until the task queue is empty .
pub(crate) fn run(&mut self) {
        // NB: defer wildcard expansion until all other imports have been
        // indexed.
        let mut wildcard_imports = Vec::new();
        while let Some(task) = self.queue.pop_front() {
            match task {
                Task::LoadFile {
                    kind,
                    source_id,
                    mod_item,
                } => {
                    log::trace!("load file: {}", mod_item.item);
                    let source = match self.sources.get(source_id).cloned() {
                        Some(source) => source,
                        None => {
                            self.diagnostics
                                .internal(source_id, "missing queued source by id");
                            continue;
                        }
                    };
                    let mut file = match crate::parse_all::<ast::File>(source.as_str()) {
                        Ok(file) => file,
                        Err(error) => {
                            self.diagnostics.error(source_id, error);
                            continue;
                        }
                    };
                    let root = match kind {
                        LoadFileKind::Root => source.path().map(ToOwned::to_owned),
                        LoadFileKind::Module { root } => root,
                    };
                    log::trace!("index: {}", mod_item.item);
                    let items = Items::new(mod_item.item.clone(), self.gen.clone());
                    let mut indexer = Indexer {
                        root,
                        storage: self.query.storage(),
                        loaded: &mut self.loaded,
                        consts: self.consts.clone(),
                        query: self.query.clone(),
                        queue: &mut self.queue,
                        sources: self.sources,
                        context: self.context,
                        options: self.options,
                        source_id,
                        source,
                        diagnostics: self.diagnostics,
                        items,
                        scopes: IndexScopes::new(),
                        mod_item,
                        impl_item: Default::default(),
                        visitor: self.visitor.clone(),
                        source_loader: self.source_loader.clone(),
                        nested_item: None,
                    };
                    if let Err(error) = file.index(&mut indexer) {
                        indexer.diagnostics.error(source_id, error);
                    }
                }
                Task::ExpandImport(import) => {
                    let source_id = import.source_id;
                    let queue = &mut self.queue;
                    let result =
                        import.process(self.context, &self.storage, &self.query, &mut |task| {
                            queue.push_back(task);
                        });
                    if let Err(error) = result {
                        self.diagnostics.error(source_id, error);
                    }
                }
                Task::ExpandWildcardImport(wildcard_import) => {
                    wildcard_imports.push(wildcard_import);
                }
            }
        }
        for wildcard_import in wildcard_imports {
            let source_id = wildcard_import.source_id;
            if let Err(error) = wildcard_import.process_local(&self.query) {
                self.diagnostics.error(source_id, error);
            }
        }
    }
pub ( crate ) fn run ( & mut self ) { // NB: defer wildcard expansion until all other imports have been // indexed. let mut wildcard_imports = Vec :: new ( ) ; while let Some ( task ) = self . queue . pop_front ( ) { match task { Task :: LoadFile { kind , source_id , mod_item , } => { log :: trace ! ( " " mod_item item ) ; let source = match self . sources . get ( source_id ) . cloned ( ) { Some ( source ) => source , None => { self . diagnostics . internal ( source_id , " " ) ; continue ; } } ; let mut file = match crate :: parse_all :: < ast :: File > ( source . as_str ( ) ) { Ok ( file ) => file , Err ( error ) => { self . diagnostics . error ( source_id , error ) ; continue ; } } ; let root = match kind { LoadFileKind :: Root => source . path ( ) . map ( ToOwned :: to_owned ) , LoadFileKind :: Module { root } => root , } ; log :: trace ! ( " " mod_item item ) ; let items = Items :: new ( mod_item . item . clone ( ) , self . gen . clone ( ) ) ; let mut indexer = Indexer { root , storage : self . query . storage ( ) , loaded : & mut self . loaded , consts : self . consts . clone ( ) , query : self . query . clone ( ) , queue : & mut self . queue , sources : self . sources , context : self . context , options : self . options , source_id , source , diagnostics : self . diagnostics , items , scopes : IndexScopes :: new ( ) , mod_item , impl_item : Default :: default ( ) , visitor : self . visitor . clone ( ) , source_loader : self . source_loader . clone ( ) , nested_item : None , } ; if let Err ( error ) = file . index ( & mut indexer ) { indexer . diagnostics . error ( source_id , error ) ; } } Task :: ExpandImport ( import ) => { let source_id = import . source_id ; let queue = & mut self . queue ; let result = import . process ( self . context , & self . storage , & self . query , & mut | task | { queue . push_back ( task ) ; } ) ; if let Err ( error ) = result { self . diagnostics . error ( source_id , error ) ; } } Task :: ExpandWildcardImport ( wildcard_import ) => { wildcard_imports . push ( wildcard_import ) ; } } } for wildcard_import in wildcard_imports { let source_id = wildcard_import . source_id ; if let Err ( error ) = wildcard_import . process_local ( & self . query ) { self . diagnostics . error ( source_id , error ) ; } } }
Run the worker until the task queue is empty.
Run the worker until the task queue is empty .
&mut self
&mut self