static async Task Main(string[] args) { var options = new LanguageServerOptions() .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .WithLoggerFactory(new LoggerFactory()) .AddDefaultLoggingProvider() .WithMinimumLogLevel(LogLevel.Trace) .WithServices(ConfigureServices) .WithHandler <TextDocumentSyncHandler>() .OnInitialize((s, _) => { var serviceProvider = (s as LanguageServer).Services; var bufferManager = serviceProvider.GetService <BufferManager>(); var diagnosticsHandler = serviceProvider.GetService <DiagnosticsHandler>(); // Hook up diagnostics bufferManager.BufferUpdated += (__, x) => diagnosticsHandler.PublishDiagnostics(x.Uri, bufferManager.GetBuffer(x.Uri)); return(Task.CompletedTask); }); var server = await LanguageServer.From(options); await server.WaitForExit; }
public async Task Works_With_IWorkspaceSymbolsHandler() { var process = new NamedPipeServerProcess(Guid.NewGuid().ToString("N"), LoggerFactory); await process.Start(); var client = new LanguageClient(LoggerFactory, process); var handler = Substitute.For <IWorkspaceSymbolsHandler>(); var cts = new CancellationTokenSource(); cts.CancelAfter(1000 * 60 * 5); var serverStart = LanguageServer.From(x => x .WithInput(process.ClientOutputStream) .WithOutput(process.ClientInputStream) .ConfigureLogging(z => z.Services.AddSingleton(LoggerFactory)), cts.Token ); await Task.WhenAll( client.Initialize( Directory.GetCurrentDirectory(), new object(), cts.Token), serverStart ); using var server = await serverStart; server.AddHandlers(handler); }
static async Task Main(string[] args) { //System.Diagnostics.Debugger.Launch(); Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .WriteTo.Debug() .MinimumLevel.Verbose() .CreateLogger(); Log.Logger.Information("ILSpy Backend starting"); var server = await LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .ConfigureLogging( x => x .AddSerilog(Log.Logger) .AddLanguageProtocolLogging() .SetMinimumLevel(LogLevel.Debug)) .AddDefaultLoggingProvider() .WithServices(ConfigureServices) .WithHandler <AddAssemblyHandler>() .WithHandler <DecompileAssemblyHandler>() .WithHandler <DecompileMemberHandler>() .WithHandler <DecompileTypeHandler>() .WithHandler <ListMembersHandler>() .WithHandler <ListNamespacesHandler>() .WithHandler <ListTypesHandler>() .WithHandler <RemoveAssemblyHandler>() ); await server.WasShutDown; }
public static async Task Main(string[] args) { var logLevel = LogLevel.Information; for (var i = 0; i < args.Length; i++) { if (args[i].IndexOf("debug", StringComparison.OrdinalIgnoreCase) >= 0) { while (!Debugger.IsAttached) { Thread.Sleep(1000); } Debugger.Break(); continue; } if (args[i] == "--logLevel" && i + 1 < args.Length) { var logLevelString = args[++i]; if (!Enum.TryParse(logLevelString, out logLevel)) { logLevel = LogLevel.Information; Console.WriteLine($"Invalid log level '{logLevelString}'. Defaulting to {logLevel.ToString()}."); } } } var threadManager = new ForegroundThreadManager(); var snapshotManager = new WorkspaceSnapshotManager(threadManager); var server = await LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .WithLoggerFactory(new LoggerFactory()) .AddDefaultLoggingProvider() .WithMinimumLogLevel(LogLevel.Trace) // We're adding a new endpoint that will handle a specific set of language server features. .WithHandler <TextDocumentSynchronizationEndpoint>() .WithHandler <ProtoCompletionEndpoint>() .WithHandler <ProtoDefinitionEndpoint>() .WithServices(services => { services.AddSingleton <ForegroundThreadManager>(threadManager); services.AddSingleton <WorkspaceSnapshotManager>(snapshotManager); })); await Task.Factory.StartNew( () => snapshotManager.InitializeAsync(server), CancellationToken.None, TaskCreationOptions.None, threadManager.ForegroundScheduler); var languageServer = (LanguageServer)server; languageServer.MinimumLogLevel = logLevel; await server.WaitForExit; }
static async Task MainAsync(string[] args) { Parser.Default.ParseArguments <Options>(args) .WithParsed(o => { if (o.Debug) { Debugger.Launch(); } }); var server = await LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .WithHandler <CompletionHandler>() .WithHandler <TextDocumentHandler>() .WithHandler <NavigationHandler>() .WithServices(serviceCollection => { serviceCollection.AddSingleton(typeof(IDiagnosticReporter), typeof(DiagnosticReporter)); serviceCollection.AddSingleton(typeof(IInjectionWorkspace), typeof(InjectionWorkspace)); serviceCollection.AddSingleton(typeof(ErrorReporter), errorReporter); }) ); await server.WaitForExit; }
public async Task StartServer() { log.Debug(Resources.LoggingMessages.server_starting); server = await LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .ConfigureLogging(x => x .AddSerilog(log) .AddLanguageServer() ) .WithServices(ConfigureServices) .WithHandler <TextDocumentSyncTaskHandler>() .WithHandler <DidChangeWatchedFilesHandler>() .WithHandler <CompletionTaskHandler>() .WithHandler <CompileHandler>() .WithHandler <CounterExampleHandler>() .WithHandler <CodeLensTaskHandler>() .WithHandler <DefinitionTaskHandler>() .WithHandler <RenameTaskHandler>() .WithHandler <HoverTaskHandler>() .WithHandler <ShutdownHandler>() ); ExecutePostLaunchTasks(); await RedirectStreamUntilServerExits(); log.Debug(Resources.LoggingMessages.server_closed); }
public async Task Start() { var server = Server = await LanguageServer.From(_options); server.Exit.Subscribe(Observer.Create <int>(i => Cancel())); var environment = _compositionHost.GetExport <IOmniSharpEnvironment>(); var logger = _compositionHost.GetExport <ILoggerFactory>().CreateLogger <LanguageServerHost>(); logger.LogInformation($"Omnisharp server running using Lsp at location '{environment.TargetDirectory}' on host {environment.HostProcessId}."); Console.CancelKeyPress += (sender, e) => { Cancel(); e.Cancel = true; }; if (environment.HostProcessId != -1) { try { var hostProcess = Process.GetProcessById(environment.HostProcessId); hostProcess.EnableRaisingEvents = true; hostProcess.OnExit(Cancel); } catch { // If the process dies before we get here then request shutdown // immediately Cancel(); } } }
private static async Task MainAsync(string[] args) { Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) .MinimumLevel.Verbose() .CreateLogger(); var server = await LanguageServer.From( options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .ConfigureLogging( x => x .AddSerilog(Log.Logger) .AddLanguageProtocolLogging() .SetMinimumLevel(LogLevel.Debug) ) .WithHandler <CompletionHandler>() .WithHandler <TextDocumentHandler>() .WithServices(x => x.AddLogging(b => b.SetMinimumLevel(LogLevel.Trace))) .WithServices( services => { services.AddSingleton <WorkspaceService>(); } ) ); await server.WaitForExit; }
static async Task MainAsync(string[] args) { // while (!System.Diagnostics.Debugger.IsAttached) // { // await Task.Delay(100); // } var server = await LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .WithLoggerFactory(new LoggerFactory()) .AddDefaultLoggingProvider() .WithMinimumLogLevel(LogLevel.Trace) .WithHandler <DocumentChangeHandler>() .WithHandler <DocumentSaveHandler>() .WithHandler <DocumentOpenHandler>() .WithHandler <CompletionHandler>() .WithHandler <DocumentCloseHandler>() .WithServices((IServiceCollection services) => { services.AddSingleton <BufferManager>(); }) ); await server.WaitForExit; }
public async Task Works_With_IWorkspaceSymbolsHandler() { var process = new NamedPipeServerProcess(Guid.NewGuid().ToString("N"), LoggerFactory); await process.Start(); var client = new LanguageClient(LoggerFactory, process); var handler = Substitute.For <IWorkspaceSymbolsHandler>(); var cts = new CancellationTokenSource(); cts.CancelAfter(1000 * 60 * 5); var serverStart = LanguageServer.From(x => x //.WithHandler(handler) .WithInput(process.ClientOutputStream) .WithOutput(process.ClientInputStream) .WithLoggerFactory(LoggerFactory) .AddDefaultLoggingProvider() .WithMinimumLogLevel(LogLevel.Trace), cts.Token ); await Task.WhenAll( client.Initialize( Directory.GetCurrentDirectory(), new object(), cts.Token), serverStart ); var server = await serverStart; server.AddHandlers(handler); }
static async Task Main(string[] args) { var server = await LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .WithLoggerFactory(new LoggerFactory()) .AddDefaultLoggingProvider() .WithServices(ConfigureServices) .WithHandler <TextDocumentSyncHandler>() .WithHandler <CompletionHandler>() .WithHandler <DefinitionHandler>() .WithHandler <SignatureHelpHandler>() .WithHandler <HoverHandler>() .OnStarted(async(languageServer, result, token) => { var configuration = await languageServer.Configuration.GetConfiguration( new ConfigurationItem { Section = "pragma" } ).ConfigureAwait(false); TextDocumentSyncHandler.includeDirectory = configuration["pragma:includeDirectory"]; }) ).ConfigureAwait(false); await server.WaitForExit; }
public async Task TriggersStartedTask() { var startedDelegate = Substitute.For <StartedDelegate>(); startedDelegate(Arg.Any <InitializeResult>()).Returns(Task.CompletedTask); var process = new NamedPipeServerProcess(Guid.NewGuid().ToString("N"), LoggerFactory); await process.Start(); var client = new LanguageClient(LoggerFactory, process); var cts = new CancellationTokenSource(); cts.CancelAfter(TimeSpan.FromSeconds(15)); var serverStart = LanguageServer.From(x => x .OnStarted(startedDelegate) .OnStarted(startedDelegate) .OnStarted(startedDelegate) .OnStarted(startedDelegate) .WithInput(process.ClientOutputStream) .WithOutput(process.ClientInputStream) .ConfigureLogging(z => z.Services.AddSingleton(LoggerFactory)) .AddHandlers(TextDocumentSyncHandlerExtensions.With(DocumentSelector.ForPattern("**/*.cs"), "csharp")) , cts.Token); await Task.WhenAll( client.Initialize( Directory.GetCurrentDirectory(), new object(), cts.Token), serverStart ); using var server = await serverStart; _ = startedDelegate.Received(4)(Arg.Any <InitializeResult>()); }
static async Task MainAsync(string[] args) { Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) .MinimumLevel.Verbose() .CreateLogger(); Log.Logger.Information("This only goes file..."); var server = await LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .ConfigureLogging(x => x .AddSerilog() .AddLanguageProtocolLogging() .SetMinimumLevel(LogLevel.Trace)) .WithHandler <TextDocumentSyncHandler>() .WithHandler <CompletionHandler>() .WithHandler <SemanticTokensHandlerDl>() .WithHandler <DiagnosticsHandler>() .WithServices(x => x.AddLogging(b => b.SetMinimumLevel(LogLevel.Trace))) .WithServices(services => { services.AddSingleton <BufferManager>(); }) ); await server.WaitForExit; }
public static Task <ILanguageServer> CreateServer(Stream input, Stream output) { return(LanguageServer.From(options => options .WithInput(input) .WithOutput(output) .WithHandler <DFoldingRangeHandler>() .WithHandler <DDefinitionHandler>() .WithHandler <TextDocumentHandler>() .WithHandler <DHoverHandler>() .WithHandler <DReferencesHandler>() .WithHandler <DSelectionRangeHandler>() .WithHandler <DCompletionHandler>() .WithHandler <DDocumentHighlightHandler>() .OnInitialize(async(server, request) => { var workspaceFolders = new HashSet <string>(); workspaceFolders.Add(request.RootPath); if (request.WorkspaceFolders != null) { request.WorkspaceFolders.Select(folder => workspaceFolders.Add(folder.Uri.AbsolutePath)); } await WorkspaceManager.SetWorkspaceRoots(workspaceFolders, server.ProgressManager, request); }) )); }
public static async Task <ILanguageServer> BuildLanguageServer(Stream inputStream, Stream outputStream, Action <ILoggingBuilder> logBuilderAction) { var server = await LanguageServer.From(options => options .WithInput(inputStream) .WithOutput(outputStream) .ConfigureLogging(logBuilderAction) .WithHandler <TextDocumentHandler>() .WithHandler <RhetosHoverHandler>() .WithHandler <RhetosSignatureHelpHandler>() .WithHandler <RhetosCompletionHandler>() .WithServices(services => { services.AddTransient <ServerEventHandler>(); services.AddSingleton <RhetosWorkspace>(); services.AddTransient <RhetosDocumentFactory>(); services.AddSingleton <RhetosAppContext>(); services.AddSingleton <XmlDocumentationProvider>(); services.AddSingleton <ILogProvider, RhetosNetCoreLogProvider>(); services.AddSingleton <PublishDiagnosticsRunner>(); services.AddSingleton <RhetosProjectMonitor>(); services.AddSingleton <ConceptQueries>(); }) .OnInitialize((languageServer, request) => { var log = languageServer.Services.GetRequiredService <ILoggerFactory>().CreateLogger("Init"); var logFileMessage = GetLogFilePath(); if (string.IsNullOrEmpty(logFileMessage)) { logFileMessage = "No log file configuration found. Edit 'NLog.config' to add log file target."; } else { logFileMessage = $"Log file: '{logFileMessage}'."; } var localPath = new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath; log.LogInformation($"Initialized. Running server '{localPath}'. {logFileMessage}"); log.LogDebug(JsonConvert.SerializeObject(request, Formatting.Indented)); return(Task.CompletedTask); }) .OnInitialized((languageServer, request, response) => { response.Capabilities.TextDocumentSync.Kind = TextDocumentSyncKind.Full; response.Capabilities.TextDocumentSync.Options.Change = TextDocumentSyncKind.Full; languageServer.Services.GetService <PublishDiagnosticsRunner>().Start(); languageServer.Services.GetService <RhetosProjectMonitor>().Start(); return(Task.CompletedTask); }) ); return(server); }
internal static async Task Main(string[] args) { ILanguageServer server = await LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .WithServices(ConfigureServices) .WithHandler <GameConstantsFileDocumentSyncHandler>() ); await server.WaitForExit; }
private static Task <ILanguageServer> CreateLanguageServer() { return(LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .WithLoggerFactory(new LoggerFactory()) .AddDefaultLoggingProvider() .WithMinimumLogLevel(LogLevel.Trace) .WithHandler <CompletionProvider>() .WithHandler <TextDocumentHandler>() )); }
static async Task MainAsync(string[] args) { var server = await LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .WithHandler <TextDocumentHandler>() .OnStarted(OnStartedCallback) ); await server.WaitForExit; }
static async Task MainAsync(string[] args) { var server = await LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .WithLoggerFactory(new LoggerFactory()) .AddDefaultLoggingProvider() .WithMinimumLogLevel(LogLevel.Trace) .WithHandler <MarkdownDocumentHandler>() ); await server.WaitForExit; }
/// <summary> /// Entry point for GSharp LanguageServer. /// </summary> /// <param name="args">Command line arguments.</param> /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> public static async Task Main(string[] args) { var server = await LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .WithLoggerFactory(new LoggerFactory()) .AddDefaultLoggingProvider() .WithMinimumLogLevel(LogLevel.Trace) .WithServices(ConfigureServices) .WithHandler <DocumentSyncHandler>() .WithHandler <FoldingHandler>()); await server.WaitForExit; }
public static Task <ILanguageServer> From(Action <LanguageServerOptions, PapyrusLanguageServerOptions> optionsAction) { var papyrusOptions = new PapyrusLanguageServerOptions(); return(LanguageServer.From((options) => { optionsAction(options, papyrusOptions); options.WithServices((collection) => collection .AddSingleton <IFileSystem, LocalFileSystem>() .AddSingleton <IXmlProjectLocator, FileSystemXmlProjectLocator>() .AddSingleton <IXmlProjectDeserializer, XmlProjectDeserializer>() .AddSingleton <IXmlProjectLoader, FileSystemXmlProjectLoader>() .AddSingleton <IScriptTextProvider, TextDocumentScriptTextProvider>((provider) => { var textProvider = provider.CreateInstance <TextDocumentScriptTextProvider>( provider.CreateInstance <FileSystemScriptTextProvider>()); AntlrPatch.SetTextProvider(textProvider); return textProvider; }) .AddSingleton <ICreationKitInisLocator>(new CreationKitInisLocator(papyrusOptions.IniLocations)) .AddSingleton <ICreationKitConfigLoader, CreationKitInisConfigLoader>() .AddSingleton((provider) => provider.CreateInstance <CreationKitProgramOptionsProvider>( papyrusOptions.AmbientProjectName, papyrusOptions.FlagsFileName, papyrusOptions.DefaultCreationKitConfig)) .AddSingleton <IProgramOptionsProvider>((provider) => provider.CreateInstance <ProjectProgramOptionsProvider>(papyrusOptions.FlagsFileName)) .AddSingleton <ProjectManager>()) .WithHandler <WorkspaceManager>() .WithHandler <DefinitionHandler>() .WithHandler <DocumentSymbolHandler>() .WithHandler <DocumentSyntaxTreeHandler>() .WithHandler <HoverHandler>() .WithHandler <CompletionHandler>() .WithHandler <SignatureHelpHandler>() .WithHandler <ReferencesHandler>() .WithHandler <RenameHandler>() .WithHandler <DocumentScriptInfoHandler>() .WithHandler <DocumentAssemblyHandler>() .WithHandler <ProjectInfosHandler>(); HarmonyPatches.Apply(); })); }
static async Task Main(string[] args) { var server = await LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .WithLoggerFactory(new LoggerFactory()) .AddDefaultLoggingProvider() .WithMinimumLogLevel(LogLevel.Trace) .WithServices(serviceCollection => { serviceCollection.AddSingleton <BufferManager>(); }) .WithHandler <TextDocumentSyncHandler>() ); await server.WaitForExit; }
static async Task MainAsync(string[] args) { //Debugger.Launch(); //while (!System.Diagnostics.Debugger.IsAttached) //{ // await Task.Delay(100); //} Log.Logger = new LoggerConfiguration() .Enrich.FromLogContext() .WriteTo.File("log.txt", rollingInterval: RollingInterval.Day) .CreateLogger(); Log.Logger.Information("This only goes file..."); var server = await LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .ConfigureLogging(x => x .AddSerilog() .AddLanguageServer() .SetMinimumLevel(LogLevel.Debug)) .WithHandler <TextDocumentHandler>() .WithHandler <DidChangeWatchedFilesHandler>() .WithHandler <FoldingRangeHandler>() .WithServices(services => { services.AddSingleton <Foo>(provider => { var loggerFactory = provider.GetService <ILoggerFactory>(); var logger = loggerFactory.CreateLogger <Foo>(); logger.LogInformation("Configuring"); return(new Foo(logger)); }); }).OnInitialize((s, request) => { var serviceProvider = s.Services; var foo = serviceProvider.GetService <Foo>(); return(Task.CompletedTask); }) ); await server.WaitForExit; }
private static async Task MainAsync(string[] args) { var server = await LanguageServer.From( options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .WithHandler <Handlers.TextDocumentSyncHandler>() .WithHandler <Handlers.CompletionHandler>() .WithServices(ConfigureServices) .ConfigureLogging(x => x .AddSerilog() .AddLanguageServer() .SetMinimumLevel(LogLevel.Debug) ) ); await server.WaitForExit; }
static async Task MainAsync(string[] args) { // while (!System.Diagnostics.Debugger.IsAttached) // { // await Task.Delay(100); // } var server = await LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .WithLoggerFactory(new LoggerFactory()) .AddDefaultLoggingProvider() .WithMinimumLogLevel(LogLevel.Trace) .WithHandler <SkryptDocumentHandler>() ); await server.WaitForExit; }
static async Task Main(string[] args) { var server = await LanguageServer.From(options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .WithLoggerFactory(new LoggerFactory()) .AddDefaultLoggingProvider() .WithServices(ConfigureServices) .WithHandler <TextDocumentSyncHandler>() .WithHandler <DocumentHighlightHandler>() .WithHandler <CompletionHandler>() .WithHandler <CompletionResolveHandler>() .WithHandler <DefinitionProvider>() .WithHandler <OnTypeFormattingHandler>() ); await server.WaitForExit; }
public async Task Start() { var server = await LanguageServer.From(_options); server.Exit.Subscribe(Observer.Create <int>(i => _cancellationTokenSource.Cancel())); _eventEmitter.SetLanguageServer(server); server.Window.LogMessage(new LogMessageParams() { Message = "initialized...", Type = MessageType.Log }); WorkspaceInitializer.Initialize(_serviceProvider, _compositionHost); _logger.LogInformation($"Omnisharp server running using Lsp at location '{_environment.TargetDirectory}' on host {_environment.HostProcessId}."); Console.CancelKeyPress += (sender, e) => { _cancellationTokenSource.Cancel(); e.Cancel = true; }; if (_environment.HostProcessId != -1) { try { var hostProcess = Process.GetProcessById(_environment.HostProcessId); hostProcess.EnableRaisingEvents = true; hostProcess.OnExit(() => _cancellationTokenSource.Cancel()); } catch { // If the process dies before we get here then request shutdown // immediately _cancellationTokenSource.Cancel(); } } }
static async Task Main(string[] args) { //System.Diagnostics.Debugger.Launch(); //while (!System.Diagnostics.Debugger.IsAttached) //{ // await Task.Delay(100); //} var options = new LanguageServerOptions() .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .WithLoggerFactory(new LoggerFactory()) .AddDefaultLoggingProvider() .WithMinimumLogLevel(LogLevel.Trace) .WithHandler <TextDocumentHandler>(); options.OnInitialize(Delegate); var server = await LanguageServer.From(options); await server.WaitForExit; }
private static async Task MainAsync(string[] args) { // Debugger.Launch(); // while (!Debugger.IsAttached) // { // await Task.Delay(100); // } var server = await LanguageServer.From( options => options .WithInput(Console.OpenStandardInput()) .WithOutput(Console.OpenStandardOutput()) .ConfigureLogging(lb => { lb.AddLanguageProtocolLogging() .SetMinimumLevel(LogLevel.Debug); }) .WithHandler <TextDocumentHandler>() .WithHandler <SemanticTokensHandler>() .WithServices(x => x.AddLogging(b => b.SetMinimumLevel(LogLevel.Trace))) .WithServices(s => { s.AddSingleton(provider => { var lsf = provider.GetService <ILanguageServerFacade>(); var loggerFactory = provider.GetService <ILoggerFactory>(); var logger = loggerFactory.CreateLogger <LspHost>(); return(new LspHost(logger, lsf)); }); }) ); await server.WaitForExit; }
public ActionDelegateData() { { var baseOptions = new LanguageServerOptions().WithPipe(new Pipe()); void BaseDelegate(LanguageServerOptions o) { o.WithPipe(new Pipe()); } var serviceProvider = new ServiceCollection().BuildServiceProvider(); Add(new ActionDelegate("create (server): options", () => LanguageServer.Create(baseOptions))); Add(new ActionDelegate("create (server): options, serviceProvider", () => LanguageServer.Create(baseOptions, serviceProvider))); Add(new ActionDelegate("create (server): action", () => LanguageServer.Create(BaseDelegate))); Add(new ActionDelegate("create (server): action, serviceProvider", () => LanguageServer.Create(BaseDelegate, serviceProvider))); Add(new ActionDelegate("from (server): options", () => LanguageServer.From(baseOptions))); Add(new ActionDelegate("from (server): options, cancellationToken", () => LanguageServer.From(baseOptions, CancellationToken.None))); Add( new ActionDelegate( "from (server): options, serviceProvider, cancellationToken", () => LanguageServer.From(baseOptions, serviceProvider, CancellationToken.None) ) ); Add(new ActionDelegate("from (server): options, serviceProvider", () => LanguageServer.From(baseOptions, serviceProvider))); Add(new ActionDelegate("from (server): action", () => LanguageServer.From(BaseDelegate))); Add(new ActionDelegate("from (server): action, cancellationToken", () => LanguageServer.From(BaseDelegate, CancellationToken.None))); Add( new ActionDelegate( "from (server): action, serviceProvider, cancellationToken", () => LanguageServer.From(BaseDelegate, serviceProvider, CancellationToken.None) ) ); Add(new ActionDelegate("from (server): action, serviceProvider", () => LanguageServer.From(BaseDelegate, serviceProvider))); } { var baseOptions = new LanguageClientOptions().WithPipe(new Pipe()); void BaseDelegate(LanguageClientOptions o) { o.WithPipe(new Pipe()); } var serviceProvider = new ServiceCollection().BuildServiceProvider(); Add(new ActionDelegate("create (client): options", () => LanguageClient.Create(baseOptions))); Add(new ActionDelegate("create (client): options, serviceProvider", () => LanguageClient.Create(baseOptions, serviceProvider))); Add(new ActionDelegate("create (client): action", () => LanguageClient.Create(BaseDelegate))); Add(new ActionDelegate("create (client): action, serviceProvider", () => LanguageClient.Create(BaseDelegate, serviceProvider))); Add(new ActionDelegate("from (client): options", () => LanguageClient.From(baseOptions))); Add(new ActionDelegate("from (client): options, cancellationToken", () => LanguageClient.From(baseOptions, CancellationToken.None))); Add( new ActionDelegate( "from (client): options, serviceProvider, cancellationToken", () => LanguageClient.From(baseOptions, serviceProvider, CancellationToken.None) ) ); Add(new ActionDelegate("from (client): options, serviceProvider", () => LanguageClient.From(baseOptions, serviceProvider))); Add(new ActionDelegate("from (client): action", () => LanguageClient.From(BaseDelegate))); Add(new ActionDelegate("from (client): action, cancellationToken", () => LanguageClient.From(BaseDelegate, CancellationToken.None))); Add( new ActionDelegate( "from (client): action, serviceProvider, cancellationToken", () => LanguageClient.From(BaseDelegate, serviceProvider, CancellationToken.None) ) ); Add(new ActionDelegate("from (client): action, serviceProvider", () => LanguageClient.From(BaseDelegate, serviceProvider))); } }