Esempio n. 1
0
 private static Task StartedAsync(ILanguageServer server, CancellationToken cancellationToken)
 {
     // TODO this currently only sent to get rid of the "Server answer pending" of the VSCode plugin.
     server.SendNotification("serverStarted", DafnyVersion);
     server.SendNotification("dafnyLanguageServerVersionReceived", DafnyVersion);
     return(Task.CompletedTask);
 }
Esempio n. 2
0
 public void Started(TextDocumentItem textDocument)
 {
     _languageServer.SendNotification(new VerificationStartedParams {
         Uri     = textDocument.Uri,
         Version = textDocument.Version,
     });
 }
 private void ExtensionService_ExtensionAddedAsync(object sender, EditorCommand e)
 {
     _languageServer?.SendNotification <ExtensionCommandAddedNotification>("powerShell/extensionCommandAdded",
                                                                           new ExtensionCommandAddedNotification
     {
         Name        = e.Name,
         DisplayName = e.DisplayName
     });
 }
        public void Emit(string kind, object args)
        {
            switch (kind)
            {
            case EventTypes.Diagnostic:
                if (args is DiagnosticMessage message)
                {
                    var groups = message.Results
                                 .GroupBy(z => Helpers.ToUri(z.FileName), z => z.QuickFixes);

                    foreach (var group in groups)
                    {
                        _server.TextDocument.PublishDiagnostics(new PublishDiagnosticsParams()
                        {
                            Uri         = group.Key,
                            Version     = _documentVersions.GetVersion(group.Key),
                            Diagnostics = group
                                          .SelectMany(z => z.Select(v => v.ToDiagnostic()))
                                          .ToArray()
                        });
                    }
                }
                break;

            case EventTypes.ProjectAdded:
            case EventTypes.ProjectChanged:
            case EventTypes.ProjectRemoved:
                _server.SendNotification($"o#/{kind}".ToLowerInvariant(), JToken.FromObject(args));     // ProjectInformationResponse
                break;

            // work done??
            case EventTypes.PackageRestoreStarted:
            case EventTypes.PackageRestoreFinished:
            case EventTypes.UnresolvedDependencies:
                _server.SendNotification($"o#/{kind}".ToLowerInvariant(), JToken.FromObject(args));
                break;

            case EventTypes.Error:
            case EventTypes.ProjectConfiguration:
            case EventTypes.ProjectDiagnosticStatus:
                _server.SendNotification($"o#/{kind}".ToLowerInvariant(), JToken.FromObject(args));
                break;

            default:
                _server.SendNotification($"o#/{kind}".ToLowerInvariant(), JToken.FromObject(args));
                break;
            }
        }
Esempio n. 5
0
 public static void CancelRequest(this ILanguageServer mediator, long id)
 {
     mediator.SendNotification(GeneralNames.CancelRequest, new CancelParams()
     {
         Id = id
     });
 }
Esempio n. 6
0
 public static void CancelRequest(this ILanguageServer mediator, long id)
 {
     mediator.SendNotification <CancelParams>("$/cancelRequest", new CancelParams()
     {
         Id = id
     });
 }
Esempio n. 7
0
        public void ClearTerminal()
        {
            if (!TestHasLanguageServer())
            {
                return;
            }
            ;

            _languageServer.SendNotification("editor/clearTerminal");
        }
        /// <summary>
        ///     Notify the language client that the language service is no longer busy.
        /// </summary>
        /// <param name="router">
        ///     The language server used to route messages to the client.
        /// </param>
        /// <param name="message">
        ///     An optional message indicating the operation that was completed.
        /// </param>
        public static void ClearBusy(this ILanguageServer router, string message = null)
        {
            if (router == null)
            {
                throw new ArgumentNullException(nameof(router));
            }

            router.SendNotification("msbuild/busy", new BusyNotificationParams
            {
                IsBusy  = false,
                Message = message
            });
        }
        /// <summary>
        ///     Notify the language client that the language service is busy.
        /// </summary>
        /// <param name="router">
        ///     The language server used to route messages to the client.
        /// </param>
        /// <param name="message">
        ///     A message describing why the language service is busy.
        /// </param>
        public static void NotifyBusy(this ILanguageServer router, string message)
        {
            if (router == null)
            {
                throw new ArgumentNullException(nameof(router));
            }

            if (String.IsNullOrWhiteSpace(message))
            {
                throw new ArgumentException("Argument cannot be null, empty, or entirely composed of whitespace: 'message'.", nameof(message));
            }

            router.SendNotification("msbuild/busy", new BusyNotificationParams
            {
                IsBusy  = true,
                Message = message
            });
        }
Esempio n. 10
0
        public override Task <Unit> Handle(PublishDiagnosticsParams request,
                                           CancellationToken cancellationToken)
        {
            _logger.LogInformation(
                $"------------------------ {request.PrettyPrint()}");

            _languageServer.Window.LogError(
                $"--------------DIAGNOSTICS! {request.PrettyPrint()}");

            var uri = request.Uri;

            var errors = _bufferManager.GetAstFor(uri.ToString()).Errors;

            var diagnostics = new List <Diagnostic>();

            foreach (var error in errors)
            {
                diagnostics.Add(new Diagnostic()
                {
                    Severity = DiagnosticSeverity.Error,
                    Message  = $"Parser Error:\n{error.Message}",
                    Range    = new Range(new Position(error.Line - 1, error.Column),
                                         new Position(error.Line - 1, error.Column)),
                });
            }

            diagnostics.Add(new Diagnostic()
            {
                Severity = DiagnosticSeverity.Error,
                Message  = $"Parser Error:\nTEST",
                Range    = new Range(new Position(3, 4),
                                     new Position(3, 8))
            });

            request.Diagnostics = new Container <Diagnostic>(diagnostics);

            _languageServer.SendNotification("textDocument/publishDiagnostics", request);

            return(Unit.Task);
        }
 public static void SendTelemetry(this ILanguageServer mediator, object @params)
 {
     mediator.SendNotification("telemetry/event", @params);
 }
Esempio n. 12
0
 public static void CancelRequest(this ILanguageServer mediator, CancelParams @params)
 {
     mediator.SendNotification <CancelParams>("$/cancelRequest", @params);
 }
 public void SendNotification(string method)
 {
     _languageServer.SendNotification(method);
 }
Esempio n. 14
0
 public static void CancelRequest(this ILanguageServer mediator, CancelParams @params)
 {
     mediator.SendNotification(GeneralNames.CancelRequest, @params);
 }
Esempio n. 15
0
 public static void SendNotificationToClient(string method)
 {
     server.SendNotification(method);
 }
Esempio n. 16
0
 public static void LogMessage(this ILanguageServer mediator, LogMessageParams @params)
 {
     mediator.SendNotification("window/logMessage", @params);
 }
Esempio n. 17
0
 public static void PublishDiagnostics(this ILanguageServer mediator, PublishDiagnosticsParams @params)
 {
     mediator.SendNotification("textDocument/publishDiagnostics", @params);
 }
 public void ClearTerminal()
 {
     _languageServer.SendNotification("editor/clearTerminal");
 }