Exemplo n.º 1
0
        private async Task InitializeAsync(Stream input, Stream output)
        {
            var documentSelector = new DocumentSelector(
                LanguageNames.AllLanguages
                .Select(x => new DocumentFilter
            {
                Language = x.ToLowerInvariant()
            }));

            _server = await OmniSharp.Extensions.LanguageServer.Server.LanguageServer.From(options => options
                                                                                           .WithInput(input)
                                                                                           .WithOutput(output)
                                                                                           .ConfigureLogging(x => x
                                                                                                             .AddSerilog(_logger)
                                                                                                             .AddLanguageProtocolLogging()
                                                                                                             .SetMinimumLevel(_minLogLevel))
                                                                                           .AddHandler(new TextDocumentSyncHandler(_workspace, documentSelector))
                                                                                           .AddHandler(new CompletionHandler(_workspace, documentSelector))
                                                                                           .AddHandler(new DefinitionHandler(_workspace, documentSelector))
                                                                                           .AddHandler(new WorkspaceSymbolsHandler(_workspace))
                                                                                           .AddHandler(new DocumentHighlightHandler(_workspace, documentSelector))
                                                                                           .AddHandler(new DocumentSymbolsHandler(_workspace, documentSelector))
                                                                                           .AddHandler(new HoverHandler(_workspace, documentSelector))
                                                                                           .AddHandler(new SignatureHelpHandler(_workspace, documentSelector)));

            var diagnosticService = _workspace.Services.GetService <IDiagnosticService>();

            _diagnosticNotifier = new DiagnosticNotifier(_server, diagnosticService);
        }
        private async Task InitializeAsync(Stream input, Stream output)
        {
            _server = await OmniSharp.Extensions.LanguageServer.Server.LanguageServer.From(options => options
                                                                                           .WithInput(input)
                                                                                           .WithOutput(output)
                                                                                           .WithLoggerFactory(_loggerFactory)
                                                                                           .OnInitialized(OnInitialized));

            var diagnosticService = _workspace.Services.GetService <IDiagnosticService>();

            _diagnosticNotifier = new DiagnosticNotifier(_server, diagnosticService);

            var documentSelector = new DocumentSelector(
                LanguageNames.AllLanguages
                .Select(x => new DocumentFilter
            {
                Language = x.ToLowerInvariant()
            }));

            var registrationOptions = new TextDocumentRegistrationOptions
            {
                DocumentSelector = documentSelector
            };

            _server.AddHandlers(
                new TextDocumentSyncHandler(_workspace, registrationOptions),
                new CompletionHandler(_workspace, registrationOptions),
                new DefinitionHandler(_workspace, registrationOptions),
                new WorkspaceSymbolsHandler(_workspace),
                new DocumentHighlightHandler(_workspace, registrationOptions),
                new DocumentSymbolsHandler(_workspace, registrationOptions),
                new HoverHandler(_workspace, registrationOptions),
                new SignatureHelpHandler(_workspace, registrationOptions));
        }