pub(crate) async fn create_state(
        config: Arc<Config>,
        lsp_state_errors: Arc<RwLock<Vec<LSPStateError>>>,
        extra_data_provider: Box<dyn LSPExtraDataProvider>,
        perf_logger: Arc<TPerfLogger>,
    ) -> LSPProcessResult<Self> {
        let mut lsp_state = Self::new(config, extra_data_provider, lsp_state_errors, perf_logger);

        let setup_event = lsp_state
            .perf_logger
            .create_event("lsp_state_initialize_resources");
        let log_time = setup_event.start("lsp_state_initialize_resources_time");

        let file_source = FileSource::connect(&lsp_state.config, &setup_event)
            .await
            .map_err(LSPProcessError::CompilerError)?;
        let (mut compiler_state, file_source_subscription) = file_source
            .subscribe(&setup_event, lsp_state.perf_logger.as_ref())
            .await
            .map_err(LSPProcessError::CompilerError)?;

        lsp_state.initial_build(&mut compiler_state, &setup_event)?;

        // Preload schema documentation - this will warm-up schema documentation cache in the LSP Extra Data providers
        lsp_state.preload_documentation();

        // Finally, start a dedicated watchman subscription, just for LSP to update schemas/programs in lsp_state
        lsp_state.watch_and_update_schemas(compiler_state, file_source_subscription);

        // This is an instance of a regular Relay compiler that we will run in
        // watch mode in a separate future (it will report errors)
        setup_event.stop(log_time);
        lsp_state.perf_logger.complete_event(setup_event);
        lsp_state.perf_logger.flush();

        lsp_state.compiler = Some(Compiler::new(
            Arc::clone(&lsp_state.config),
            Arc::clone(&lsp_state.perf_logger),
        ));

        Ok(lsp_state)
    }
/// This method is responsible for creating schema/source_programs for LSP internal state
/// - so the LSP can provide these to Hover/Completion/GoToDefinition requests.
/// It also creates a watchman subscription that is responsible for keeping these resources up-to-date.
This method is responsible for creating schema/source_programs for LSP internal state
so the LSP can provide these to Hover/Completion/GoToDefinition requests.
It also creates a watchman subscription that is responsible for keeping these resources up-to-date.
This method is responsible for creating schema / source_programs for LSP internal state so the LSP can provide these to Hover / Completion / GoToDefinition requests . It also creates a watchman subscription that is responsible for keeping these resources up - to - date .
pub(crate) async fn create_state(
        config: Arc<Config>,
        lsp_state_errors: Arc<RwLock<Vec<LSPStateError>>>,
        extra_data_provider: Box<dyn LSPExtraDataProvider>,
        perf_logger: Arc<TPerfLogger>,
    ) -> LSPProcessResult<Self> {
        let mut lsp_state = Self::new(config, extra_data_provider, lsp_state_errors, perf_logger);
        let setup_event = lsp_state
            .perf_logger
            .create_event("lsp_state_initialize_resources");
        let log_time = setup_event.start("lsp_state_initialize_resources_time");
        let file_source = FileSource::connect(&lsp_state.config, &setup_event)
            .await
            .map_err(LSPProcessError::CompilerError)?;
        let (mut compiler_state, file_source_subscription) = file_source
            .subscribe(&setup_event, lsp_state.perf_logger.as_ref())
            .await
            .map_err(LSPProcessError::CompilerError)?;
        lsp_state.initial_build(&mut compiler_state, &setup_event)?;
        // Preload schema documentation - this will warm-up schema documentation cache in the LSP Extra Data providers
        lsp_state.preload_documentation();
        // Finally, start a dedicated watchman subscription, just for LSP to update schemas/programs in lsp_state
        lsp_state.watch_and_update_schemas(compiler_state, file_source_subscription);
        // This is an instance of a regular Relay compiler that we will run in
        // watch mode in a separate future (it will report errors)
        setup_event.stop(log_time);
        lsp_state.perf_logger.complete_event(setup_event);
        lsp_state.perf_logger.flush();
        lsp_state.compiler = Some(Compiler::new(
            Arc::clone(&lsp_state.config),
            Arc::clone(&lsp_state.perf_logger),
        ));
        Ok(lsp_state)
    }
pub ( crate ) async fn create_state ( config : Arc < Config > , lsp_state_errors : Arc < RwLock < Vec < LSPStateError > > > , extra_data_provider : Box < dyn LSPExtraDataProvider > , perf_logger : Arc < TPerfLogger > , ) -> LSPProcessResult < Self > { let mut lsp_state = Self :: new ( config , extra_data_provider , lsp_state_errors , perf_logger ) ; let setup_event = lsp_state . perf_logger . create_event ( " " ) ; let log_time = setup_event . start ( " " ) ; let file_source = FileSource :: connect ( & lsp_state . config , & setup_event ) . await . map_err ( LSPProcessError :: CompilerError ) ? ; let ( mut compiler_state , file_source_subscription ) = file_source . subscribe ( & setup_event , lsp_state . perf_logger . as_ref ( ) ) . await . map_err ( LSPProcessError :: CompilerError ) ? ; lsp_state . initial_build ( & mut compiler_state , & setup_event ) ? ; // Preload schema documentation - this will warm-up schema documentation cache in the LSP Extra Data providers lsp_state . preload_documentation ( ) ; // Finally, start a dedicated watchman subscription, just for LSP to update schemas/programs in lsp_state lsp_state . watch_and_update_schemas ( compiler_state , file_source_subscription ) ; // This is an instance of a regular Relay compiler that we will run in // watch mode in a separate future (it will report errors) setup_event . stop ( log_time ) ; lsp_state . perf_logger . complete_event ( setup_event ) ; lsp_state . perf_logger . flush ( ) ; lsp_state . compiler = Some ( Compiler :: new ( Arc :: clone ( & lsp_state . config ) , Arc :: clone ( & lsp_state . perf_logger ) , ) ) ; Ok ( lsp_state ) }
This method is responsible for creating schema/source_programs for LSP internal state
 so the LSP can provide these to Hover/Completion/GoToDefinition requests.
This method is responsible for creating schema / source_programs for LSP internal state so the LSP can provide these to Hover / Completion / GoToDefinition requests .
config
Arc<Config>
lsp_state_errors
Arc<RwLock<Vec<LSPStateError>>>
extra_data_provider
Box<dyn LSPExtraDataProvider>
perf_logger
Arc<TPerfLogger>
config
Arc<Config>
lsp_state_errors
Arc<RwLock<Vec<LSPStateError>>>
extra_data_provider
Box<dyn LSPExtraDataProvider>
perf_logger
Arc<TPerfLogger>