public override async Task DisposeAsync() { await LanguageClient.Shutdown(); await _psesProcess.Stop(); LanguageClient?.Dispose(); }
/// <summary> /// Dispose of resources being used by the extension package. /// </summary> /// <param name="disposing"> /// Explicit disposal? /// </param> protected override void Dispose(bool disposing) { if (disposing) { if (LanguageClient != null) { LanguageClient.Dispose(); LanguageClient = null; } } base.Dispose(disposing); }
public override async Task DisposeAsync() { try { await LanguageClient.Shutdown(); await _psesProcess.Stop(); LanguageClient?.Dispose(); } catch (ObjectDisposedException) { // Language client has a disposal bug in it } }
public async Task Test1() { var logFactory = LoggerFactory.Create(a => a.AddNLog().SetMinimumLevel(LogLevel.Trace)); var serverProcess = new NamedPipeServerProcess("test", logFactory); var languageClient = new LanguageClient(logFactory, serverProcess); var clientInit = languageClient.Initialize("/"); var serverInit = RhetosLanguageServer.BuildLanguageServer(serverProcess.ClientOutputStream, serverProcess.ClientInputStream, builder => builder.AddNLog().AddLanguageServer().AddConsole()); Task.WaitAll(clientInit, serverInit); Console.WriteLine(languageClient.IsConnected.ToString()); var textDocument = new TextDocumentItem() { Text = @"// <rhetosRootPath="""" />\nble ble ble\nblelle", Uri = new Uri("file://ble.rhe") }; var opened = await languageClient.SendRequest <object>(DocumentNames.DidOpen, new DidOpenTextDocumentParams() { TextDocument = textDocument }); Task.Delay(2500).Wait(); var result = await languageClient.SendRequest <CompletionList>(DocumentNames.Completion, new CompletionParams() { TextDocument = new TextDocumentIdentifier(textDocument.Uri), Position = new Position() }); Console.WriteLine(JsonConvert.SerializeObject(result.Items, Formatting.Indented)); Task.Delay(3000).Wait(); languageClient.Dispose(); }