public static async Task <Server> InitializeAsync(this Server server, InterpreterConfiguration configuration, Uri rootUri = null, IEnumerable <string> searchPaths = null)
        {
            configuration.AssertInstalled();

            server.OnLogMessage += Server_OnLogMessage;
            var properties = new InterpreterFactoryCreationOptions {
                TraceLevel   = System.Diagnostics.TraceLevel.Verbose,
                DatabasePath = TestData.GetAstAnalysisCachePath(configuration.Version)
            }.ToDictionary();

            configuration.WriteToDictionary(properties);

            await server.Initialize(new InitializeParams {
                rootUri = rootUri,
                initializationOptions = new PythonInitializationOptions {
                    interpreter = new PythonInitializationOptions.Interpreter {
                        assembly   = typeof(AstPythonInterpreterFactory).Assembly.Location,
                        typeName   = typeof(AstPythonInterpreterFactory).FullName,
                        properties = properties
                    },
                    analysisUpdates = true,
                    searchPaths     = searchPaths?.ToArray() ?? Array.Empty <string>(),
                    traceLogging    = true,
                },
                capabilities = new ClientCapabilities {
                    python = new PythonClientCapabilities {
                        liveLinting = true,
                    }
                }
            }, CancellationToken.None);

            return(server);
        }
        public async Task <Server> CreateServer(Uri rootUri, InterpreterConfiguration configuration = null, Dictionary <Uri, PublishDiagnosticsEventArgs> diagnosticEvents = null)
        {
            configuration = configuration ?? Default;
            configuration.AssertInstalled();

            var sm = new ServiceManager();

            sm.AddService(new TestLogger());
            var s = new Server(sm);

            var properties = new InterpreterFactoryCreationOptions {
                TraceLevel   = System.Diagnostics.TraceLevel.Verbose,
                DatabasePath = TestData.GetAstAnalysisCachePath(configuration.Version)
            }.ToDictionary();

            configuration.WriteToDictionary(properties);

            await s.Initialize(new InitializeParams {
                rootUri = rootUri,
                initializationOptions = new PythonInitializationOptions {
                    interpreter = new PythonInitializationOptions.Interpreter {
                        assembly   = typeof(AstPythonInterpreterFactory).Assembly.Location,
                        typeName   = typeof(AstPythonInterpreterFactory).FullName,
                        properties = properties
                    },
                    testEnvironment = true,
                    analysisUpdates = true,
                    traceLogging    = true,
                },
                capabilities = new ClientCapabilities {
                    python = new PythonClientCapabilities {
                        liveLinting = true,
                    }
                }
            }, CancellationToken.None);

            if (diagnosticEvents != null)
            {
                s.OnPublishDiagnostics += (sender, e) => { lock (diagnosticEvents) diagnosticEvents[e.uri] = e; };
            }

            if (rootUri != null)
            {
                await LoadFromDirectoryAsync(s, rootUri.LocalPath).ConfigureAwait(false);

                await s.WaitForCompleteAnalysisAsync(CancellationToken.None).ConfigureAwait(false);
            }

            return(s);
        }