fn build_in_watch_mode(
        config: &Arc<Config>,
        compiler: &Compiler<TPerfLogger>,
        compiler_state: &mut CompilerState,
        schemas: &Arc<RwLock<HashMap<StringKey, Arc<SDLSchema>>>>,
        source_programs: &Arc<RwLock<HashMap<StringKey, Program>>>,
        perf_logger: Arc<TPerfLogger>,
        log_event: &impl PerfLogEvent,
    ) -> LSPProcessResult<()> {
        // we should trigger build only for changed projects
        // this set will be used in the `build_raw_programs` to ignore unchanged projects
        let affected_projects = config
            .projects
            .keys()
            .filter(|project_name| compiler_state.project_has_pending_changes(**project_name))
            .collect::<HashSet<_>>();

        // This will build programs, but won't apply any transformations to them
        // that should be enough for LSP to start showing fragments information
        let (programs, build_raw_programs_errors) = compiler.build_raw_programs(
            &compiler_state,
            &schemas
                .read()
                .expect("LSPState::build_in_watch_mode: expect to acquire read lock on schemas"),
            Some(affected_projects),
            log_event,
        )?;

        if !build_raw_programs_errors.is_empty() {
            Self::log_errors(&perf_logger, &build_raw_programs_errors)
        }
        let timer = log_event.start("lsp_build_in_watch_writing_programs_time");

        let mut source_programs_write_lock = source_programs.write().expect(
            "LSPState::build_in_watch_mode: expect to acquire write lock on source_programs",
        );
        for (program_name, program) in programs {
            // NOTE: Currently, we rely on the fact that `build_raw_programs`
            // will always return a full program, so we can safely replace it in the current
            // list of source_programs
            source_programs_write_lock.insert(program_name, program);
        }

        compiler_state.complete_compilation();

        log_event.stop(timer);
        Ok(())
    }
/// This function should handle internal watchman builds that will
/// update schemas/source_programs every time those are created/updated
This function should handle internal watchman builds that will
update schemas/source_programs every time those are created/updated
This function should handle internal watchman builds that will update schemas / source_programs every time those are created / updated
fn build_in_watch_mode(
        config: &Arc<Config>,
        compiler: &Compiler<TPerfLogger>,
        compiler_state: &mut CompilerState,
        schemas: &Arc<RwLock<HashMap<StringKey, Arc<SDLSchema>>>>,
        source_programs: &Arc<RwLock<HashMap<StringKey, Program>>>,
        perf_logger: Arc<TPerfLogger>,
        log_event: &impl PerfLogEvent,
    ) -> LSPProcessResult<()> {
        // we should trigger build only for changed projects
        // this set will be used in the `build_raw_programs` to ignore unchanged projects
        let affected_projects = config
            .projects
            .keys()
            .filter(|project_name| compiler_state.project_has_pending_changes(**project_name))
            .collect::<HashSet<_>>();
        // This will build programs, but won't apply any transformations to them
        // that should be enough for LSP to start showing fragments information
        let (programs, build_raw_programs_errors) = compiler.build_raw_programs(
            &compiler_state,
            &schemas
                .read()
                .expect("LSPState::build_in_watch_mode: expect to acquire read lock on schemas"),
            Some(affected_projects),
            log_event,
        )?;
        if !build_raw_programs_errors.is_empty() {
            Self::log_errors(&perf_logger, &build_raw_programs_errors)
        }
        let timer = log_event.start("lsp_build_in_watch_writing_programs_time");
        let mut source_programs_write_lock = source_programs.write().expect(
            "LSPState::build_in_watch_mode: expect to acquire write lock on source_programs",
        );
        for (program_name, program) in programs {
            // NOTE: Currently, we rely on the fact that `build_raw_programs`
            // will always return a full program, so we can safely replace it in the current
            // list of source_programs
            source_programs_write_lock.insert(program_name, program);
        }
        compiler_state.complete_compilation();
        log_event.stop(timer);
        Ok(())
    }
fn build_in_watch_mode ( config : & Arc < Config > , compiler : & Compiler < TPerfLogger > , compiler_state : & mut CompilerState , schemas : & Arc < RwLock < HashMap < StringKey , Arc < SDLSchema > > > > , source_programs : & Arc < RwLock < HashMap < StringKey , Program > > > , perf_logger : Arc < TPerfLogger > , log_event : & impl PerfLogEvent , ) -> LSPProcessResult < ( ) > { // we should trigger build only for changed projects // this set will be used in the `build_raw_programs` to ignore unchanged projects let affected_projects = config . projects . keys ( ) . filter ( | project_name | compiler_state . project_has_pending_changes ( * * project_name ) ) . collect :: < HashSet < _ > > ( ) ; // This will build programs, but won't apply any transformations to them // that should be enough for LSP to start showing fragments information let ( programs , build_raw_programs_errors ) = compiler . build_raw_programs ( & compiler_state , & schemas . read ( ) . expect ( " " ) , Some ( affected_projects ) , log_event , ) ? ; if ! build_raw_programs_errors . is_empty ( ) { Self :: log_errors ( & perf_logger , & build_raw_programs_errors ) } let timer = log_event . start ( " " ) ; let mut source_programs_write_lock = source_programs . write ( ) . expect ( " " , ) ; for ( program_name , program ) in programs { // NOTE: Currently, we rely on the fact that `build_raw_programs` // will always return a full program, so we can safely replace it in the current // list of source_programs source_programs_write_lock . insert ( program_name , program ) ; } compiler_state . complete_compilation ( ) ; log_event . stop ( timer ) ; Ok ( ( ) ) }
This function should handle internal watchman builds that will
update schemas/source_programs every time those are created/updated
This function should handle internal watchman builds that will update schemas / source_programs every time those are created / updated
config
&Arc<Config>
compiler
&Compiler<TPerfLogger>
compiler_state
&mut CompilerState
schemas
&Arc<RwLock<HashMap<StringKey, Arc<SDLSchema>>>>
source_programs
&Arc<RwLock<HashMap<StringKey, Program>>>
perf_logger
Arc<TPerfLogger>
log_event
&impl PerfLogEvent
config
&Arc<Config>
compiler
&Compiler<TPerfLogger>
compiler_state
&mut CompilerState
schemas
&Arc<RwLock<HashMap<StringKey, Arc<SDLSchema>>>>
source_programs
&Arc<RwLock<HashMap<StringKey, Program>>>
perf_logger
Arc<TPerfLogger>
log_event
&impl PerfLogEvent