Пример #1
0
        public Server(CreationOptions creationOptions, Action <LanguageServerOptions> onOptionsFunc)
        {
            BicepDeploymentsInterop.Initialize();
            server = OmnisharpLanguageServer.PreInit(options =>
            {
                options
                .WithHandler <BicepTextDocumentSyncHandler>()
                .WithHandler <BicepDocumentSymbolHandler>()
                .WithHandler <BicepDefinitionHandler>()
                .WithHandler <BicepDeploymentGraphHandler>()
                .WithHandler <BicepReferencesHandler>()
                .WithHandler <BicepDocumentHighlightHandler>()
                .WithHandler <BicepDocumentFormattingHandler>()
                .WithHandler <BicepRenameHandler>()
                .WithHandler <BicepHoverHandler>()
                .WithHandler <BicepCompletionHandler>()
                .WithHandler <BicepCodeActionHandler>()
                .WithHandler <BicepDidChangeWatchedFilesHandler>()
                .WithHandler <BicepSignatureHelpHandler>()
                .WithHandler <BicepSemanticTokensHandler>()
                .WithHandler <BicepTelemetryHandler>()
                .WithHandler <BicepBuildCommandHandler>()
                .WithHandler <BicepDeployCommandHandler>()
                .WithHandler <BicepDeploymentScopeRequestHandler>()
                .WithHandler <BicepRegistryCacheRequestHandler>()
                .WithHandler <InsertResourceHandler>()
                .WithServices(services => RegisterServices(creationOptions, services));

                creationOptions.onRegisterServices?.Invoke(options.Services);

                onOptionsFunc(options);
            });
        }
Пример #2
0
        private Server(CreationOptions creationOptions, Action <LanguageServerOptions> onOptionsFunc)
        {
            BicepDeploymentsInterop.Initialize();
            server = OmniSharp.Extensions.LanguageServer.Server.LanguageServer.PreInit(options =>
            {
                options
                .WithHandler <BicepTextDocumentSyncHandler>()
                .WithHandler <BicepDocumentSymbolHandler>()
                .WithHandler <BicepDefinitionHandler>()
                .WithHandler <BicepDeploymentGraphHandler>()
                .WithHandler <BicepReferencesHandler>()
                .WithHandler <BicepDocumentHighlightHandler>()
                .WithHandler <BicepDocumentFormattingHandler>()
                .WithHandler <BicepRenameHandler>()
                .WithHandler <BicepHoverHandler>()
                .WithHandler <BicepCompletionHandler>()
                .WithHandler <BicepCodeActionHandler>()
                .WithHandler <BicepDidChangeWatchedFilesHandler>()
                .WithHandler <BicepSignatureHelpHandler>()
#pragma warning disable 0612 // disable 'obsolete' warning for proposed LSP feature
                .WithHandler <BicepSemanticTokensHandler>()
#pragma warning restore 0612
                .WithServices(services => RegisterServices(creationOptions, services));

                onOptionsFunc(options);
            });
        }
Пример #3
0
        public static async Task <ILanguageServer> From(LanguageServerOptions options)
        {
            var server = new LanguageServer(
                options.Input,
                options.Output,
                options.Reciever,
                options.RequestProcessIdentifier,
                options.LoggerFactory,
                options.Serializer,
                options.Services,
                options.HandlerTypes.Select(x => x.Assembly)
                .Distinct().Concat(options.HandlerAssemblies),
                options.InitializeDelegates,
                options.InitializedDelegates
                );

            if (options.AddDefaultLoggingProvider)
            {
                options.LoggerFactory.AddProvider(new LanguageServerLoggerProvider(server));
            }

            await server.Initialize();

            return(server);
        }
Пример #4
0
        protected internal virtual (ILanguageClient client, ILanguageServer server) Create(
            Action <LanguageClientOptions> clientOptionsAction,
            Action <LanguageServerOptions> serverOptionsAction
            )
        {
            var clientPipe = new Pipe(TestOptions.DefaultPipeOptions);
            var serverPipe = new Pipe(TestOptions.DefaultPipeOptions);

            _client = LanguageClient.PreInit(
                options => {
                options
                .WithLoggerFactory(TestOptions.ClientLoggerFactory)
                .WithAssemblies(TestOptions.Assemblies)
                .ConfigureLogging(x => x.SetMinimumLevel(LogLevel.Trace))
                .WithAssemblies(typeof(LanguageProtocolTestBase).Assembly, GetType().Assembly)
                .WithInputScheduler(options.InputScheduler)
                .WithOutputScheduler(options.OutputScheduler)
                .WithDefaultScheduler(options.DefaultScheduler)
                .Services
                .AddTransient(typeof(IPipelineBehavior <,>), typeof(SettlePipeline <,>))
                .AddSingleton(ClientEvents as IRequestSettler);
                ConfigureClientInputOutput(serverPipe.Reader, clientPipe.Writer, options);
                clientOptionsAction(options);
            }
                );

            _server = RealLanguageServer.PreInit(
                options => {
                options
                .WithLoggerFactory(TestOptions.ServerLoggerFactory)
                .WithAssemblies(TestOptions.Assemblies)
                .ConfigureLogging(x => x.SetMinimumLevel(LogLevel.Trace))
                .WithAssemblies(typeof(LanguageProtocolTestBase).Assembly, GetType().Assembly)
                .WithInputScheduler(options.InputScheduler)
                .WithOutputScheduler(options.OutputScheduler)
                .WithDefaultScheduler(options.DefaultScheduler)
                .Services
                .AddTransient(typeof(IPipelineBehavior <,>), typeof(SettlePipeline <,>))
                .AddSingleton(ServerEvents as IRequestSettler);
                ConfigureServerInputOutput(clientPipe.Reader, serverPipe.Writer, options);
                serverOptionsAction(options);
            }
                );

            Disposable.Add(_client);
            Disposable.Add(_server);

            return(_client, _server);
        }
Пример #5
0
        public LanguageServer Get(string name)
        {
            if (_servers.TryGetValue(name, out var server))
            {
                return(server);
            }

            var options = name == Options.DefaultName ? _monitor.CurrentValue : _monitor.Get(name);

            var container = LanguageServer.CreateContainer(options, _outerServiceProvider);

            server = container.Resolve <LanguageServer>();
            _servers.TryAdd(name, server);

            return(server);
        }
Пример #6
0
        public Server(CreationOptions creationOptions, Action <LanguageServerOptions> onOptionsFunc)
        {
            BicepDeploymentsInterop.Initialize();
            server = OmnisharpLanguageServer.PreInit(options =>
            {
                options
                .WithHandler <BicepTextDocumentSyncHandler>()
                .WithHandler <BicepDocumentSymbolHandler>()
                .WithHandler <BicepDefinitionHandler>()
                .WithHandler <BicepDeploymentGraphHandler>()
                .WithHandler <BicepReferencesHandler>()
                .WithHandler <BicepDocumentHighlightHandler>()
                .WithHandler <BicepDocumentFormattingHandler>()
                .WithHandler <BicepRenameHandler>()
                .WithHandler <BicepHoverHandler>()
                .WithHandler <BicepCompletionHandler>()
                .WithHandler <BicepCodeActionHandler>()
                .WithHandler <BicepCreateConfigFileHandler>()
                .WithHandler <BicepDidChangeWatchedFilesHandler>()
                .WithHandler <BicepEditLinterRuleCommandHandler>()
                .WithHandler <BicepGetRecommendedConfigLocationHandler>()
                .WithHandler <BicepSignatureHelpHandler>()
                .WithHandler <BicepSemanticTokensHandler>()
                .WithHandler <BicepTelemetryHandler>()
                .WithHandler <BicepBuildCommandHandler>()
                .WithHandler <BicepGenerateParamsCommandHandler>()
                .WithHandler <BicepDeploymentStartCommandHandler>()
                // Base handler - ExecuteTypedResponseCommandHandlerBase is serial. This blocks other commands on the client side.
                // To avoid the above issue, we'll change the RequestProcessType to parallel
                .WithHandler <BicepDeploymentWaitForCompletionCommandHandler>(new JsonRpcHandlerOptions()
                {
                    RequestProcessType = RequestProcessType.Parallel
                })
                .WithHandler <BicepDeploymentScopeRequestHandler>()
                .WithHandler <BicepDeploymentParametersHandler>()
                .WithHandler <BicepForceModulesRestoreCommandHandler>()
                .WithHandler <BicepRegistryCacheRequestHandler>()
                .WithHandler <InsertResourceHandler>()
                .WithServices(services => RegisterServices(creationOptions, services));

                creationOptions.onRegisterServices?.Invoke(options.Services);

                onOptionsFunc(options);
            });
        }
Пример #7
0
        protected virtual async Task <(ILanguageClient client, ILanguageServer server)> Initialize(
            Action <LanguageClientOptions> clientOptionsAction,
            Action <LanguageServerOptions> serverOptionsAction)
        {
            var clientPipe = new Pipe(TestOptions.DefaultPipeOptions);
            var serverPipe = new Pipe(TestOptions.DefaultPipeOptions);

            _client = LanguageClient.PreInit(options => {
                options
                .WithLoggerFactory(TestOptions.ClientLoggerFactory)
                .ConfigureLogging(x => {
                    x.Services.RemoveAll(typeof(ILoggerFactory));
                    x.Services.AddSingleton(TestOptions.ClientLoggerFactory);
                })
                .Services
                .AddTransient(typeof(IPipelineBehavior <,>), typeof(SettlePipeline <,>))
                .AddSingleton(ServerEvents as IRequestSettler);
                ConfigureClientInputOutput(serverPipe.Reader, clientPipe.Writer, options);
                clientOptionsAction(options);
            });

            _server = RealLanguageServer.PreInit(options => {
                options
                .WithLoggerFactory(TestOptions.ServerLoggerFactory)
                .ConfigureLogging(x => {
                    x.Services.RemoveAll(typeof(ILoggerFactory));
                    x.Services.AddSingleton(TestOptions.ServerLoggerFactory);
                })
                .Services
                .AddTransient(typeof(IPipelineBehavior <,>), typeof(SettlePipeline <,>))
                .AddSingleton(ServerEvents as IRequestSettler);
                ConfigureServerInputOutput(clientPipe.Reader, serverPipe.Writer, options);
                serverOptionsAction(options);
            });

            Disposable.Add(_client);
            Disposable.Add(_server);

            return(await ObservableEx.ForkJoin(
                       Observable.FromAsync(_client.Initialize),
                       Observable.FromAsync(_server.Initialize),
                       (a, b) => (_client, _server)
                       ).ToTask(CancellationToken));
        }
Пример #8
0
        private Server(Action <LanguageServerOptions> onOptionsFunc)
        {
            server = OmniSharp.Extensions.LanguageServer.Server.LanguageServer.PreInit(options =>
            {
                options
                .WithHandler <BicepTextDocumentSyncHandler>()
                .WithHandler <BicepDocumentSymbolHandler>()
                .WithHandler <BicepDefinitionHandler>()
                .WithHandler <BicepReferencesHandler>()
                .WithHandler <BicepDocumentHighlightHandler>()
                .WithHandler <BicepRenameHandler>()
                .WithHandler <BicepHoverHandler>()
#pragma warning disable 0612 // disable 'obsolete' warning for proposed LSP feature
                .WithHandler <BicepSemanticTokensHandler>()
#pragma warning restore 0612
                .WithServices(RegisterServices);

                onOptionsFunc(options);
            });
        }
Пример #9
0
        private static async Task Main(string[] args)
        {
            var configuration = CreateConfiguration(args);

            InitializeLogger(configuration);
            try {
                var server = await OmniSharpLanguageServer.From(
                    options => options
                    .WithInput(Console.OpenStandardInput())
                    .WithOutput(Console.OpenStandardOutput())
                    .ConfigureConfiguration(builder => builder.AddConfiguration(configuration))
                    .ConfigureLogging(SetupLogging)
                    .WithUnhandledExceptionHandler(LogException)
                    .WithDafnyLanguageServer(configuration)
                    );

                await server.WaitForExit;
            } finally {
                Log.CloseAndFlush();
            }
        }
 public LanguageServerLoggerProvider(LanguageServer languageServer)
 {
     _languageServer = languageServer;
 }
Пример #11
0
 public LanguageServerLogger(LanguageServer responseRouter, Func <LogLevel> logLevelGetter)
 {
     _logLevelGetter = logLevelGetter;
     _responseRouter = responseRouter;
 }