Exemplo n.º 1
0
        public override async Task DisposeAsync()
        {
            await LanguageClient.Shutdown();

            await _psesProcess.Stop();

            LanguageClient?.Dispose();
        }
Exemplo n.º 2
0
        public override async Task DisposeAsync()
        {
            try
            {
                await LanguageClient.Shutdown();

                await _psesProcess.Stop();

                LanguageClient?.Dispose();
            }
            catch (ObjectDisposedException)
            {
                // Language client has a disposal bug in it
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///     The main asynchronous program entry-point.
        /// </summary>
        /// <returns>
        ///     A <see cref="Task"/> representing program operation.
        /// </returns>
        static async Task AsyncMain()
        {
            ProcessStartInfo serverStartInfo = new ProcessStartInfo("dotnet")
            {
                Arguments = $"\"{ServerAssembly}\""
            };

            Log.Information("Starting server...");
            LanguageClient client = new LanguageClient(Log.Logger, serverStartInfo)
            {
                ClientCapabilities =
                {
                    Workspace                   =
                    {
                        DidChangeConfiguration  = new DidChangeConfigurationCapability
                        {
                            DynamicRegistration = false
                        }
                    }
                }
            };

            using (client)
            {
                // Listen for log messages from the language server.
                client.Window.OnLogMessage((message, messageType) =>
                {
                    Log.Information("Language server says: [{MessageType:l}] {Message}", messageType, message);
                });

                // Listen for our custom notification from the language server.
                client.HandleNotification <DummyParams>("dummy/notify", notification =>
                {
                    Log.Information("Received dummy notification from language server: {Message}",
                                    notification.Message
                                    );
                });

                await client.Initialize(workspaceRoot : @"C:\Foo");

                Log.Information("Client started.");

                // Update server configuration.
                client.Workspace.DidChangeConfiguration(
                    new JObject(
                        new JProperty("setting1", true),
                        new JProperty("setting2", "Hello")
                        )
                    );

                // Invoke our custom handler.
                await client.SendRequest("dummy", new DummyParams
                {
                    Message = "Hello, world!"
                });

                Log.Information("Stopping language server...");
                await client.Shutdown();

                Log.Information("Server stopped.");
            }
        }