internal async Task CreateAsync()
 {
     await languageServer.SendRequest(
         NewCustomViewRequest.Method,
         new NewCustomViewRequest
     {
         Id       = this.Id,
         Title    = this.Title,
         ViewType = this.ViewType,
     }
         );
 }
Esempio n. 2
0
 public static async Task UnregisterCapability(this ILanguageServer mediator, UnregistrationParams @params)
 {
     try
     {
         await mediator.SendRequest("client/unregisterCapability", @params);
     }
     catch (Exception e)
     {
         // VsCode today does not implement LSP properly.
         await mediator.SendRequest("client/unregisterFeature", @params);
     }
 }
Esempio n. 3
0
        public async Task <string> PromptInputAsync(string message)
        {
            // The VSCode client currently doesn't use the Label field, so we ignore it
            ShowInputPromptResponse response = await _languageServer.SendRequest <ShowInputPromptRequest, ShowInputPromptResponse>(
                "powerShell/showInputPrompt",
                new ShowInputPromptRequest
            {
                Name = message,
            });

            if (response.PromptCancelled)
            {
                return(null);
            }

            return(response.ResponseText);
        }
        public async Task InitializeAsync(ILanguageServer server)
        {
            var documents = await server.SendRequest <IEnumerable <TextDocumentItem> >(GetAllDocumentsMethod);

            foreach (var doc in documents)
            {
                this.DocumentAdded(doc.Uri.AbsolutePath, new ThrowTextLoader());
            }
        }
        public async Task <ILspCurrentFileContext> GetCurrentLspFileContextAsync()
        {
            ClientEditorContext clientContext =
                await _languageServer.SendRequest <GetEditorContextRequest, ClientEditorContext>(
                    "editor/getEditorContext",
                    new GetEditorContextRequest()).ConfigureAwait(false);

            return(new LspCurrentFileContext(clientContext));
        }
Esempio n. 6
0
        protected override void ShowFieldPrompt(FieldDetails fieldDetails)
        {
            base.ShowFieldPrompt(fieldDetails);

            _languageServer.SendRequest <ShowInputPromptRequest, ShowInputPromptResponse>(
                "powerShell/showInputPrompt",
                new ShowInputPromptRequest
            {
                Name  = fieldDetails.Name,
                Label = fieldDetails.Label
            }).ContinueWith(HandlePromptResponse)
            .ConfigureAwait(false);
        }
Esempio n. 7
0
        protected override void ShowPrompt(PromptStyle promptStyle)
        {
            base.ShowPrompt(promptStyle);

            _languageServer.SendRequest <ShowChoicePromptRequest, ShowChoicePromptResponse>(
                "powerShell/showChoicePrompt",
                new ShowChoicePromptRequest
            {
                IsMultiChoice  = this.IsMultiChoice,
                Caption        = this.Caption,
                Message        = this.Message,
                Choices        = this.Choices,
                DefaultChoices = this.DefaultChoices
            })
            .ContinueWith(HandlePromptResponse)
            .ConfigureAwait(false);
        }
Esempio n. 8
0
        public Task <Unit> Handle(DidChangeTextDocumentParams request,
                                  CancellationToken cancellationToken)
        {
            var documentPath = request.TextDocument.Uri.ToString();
            var text         = request.ContentChanges.FirstOrDefault()?.Text;

            _bufferManager.UpdateBuffer(documentPath, text);

            _languageServer.SendRequest(
                new PublishDiagnosticsParams()
            {
                Uri = request.TextDocument.Uri
            }, cancellationToken);

            _languageServer.Window.LogInfo(
                $"Updated buffer for document: {documentPath}");

            return(Unit.Task);
        }
Esempio n. 9
0
        public async Task <EditorContext> GetEditorContextAsync()
        {
            if (!TestHasLanguageServer())
            {
                return(null);
            }
            ;

            ClientEditorContext clientContext =
                await _languageServer.SendRequest <GetEditorContextRequest, ClientEditorContext>(
                    "editor/getEditorContext",
                    new GetEditorContextRequest()).ConfigureAwait(false);

            return(this.ConvertClientEditorContext(clientContext));
        }
        public async Task <EditorContext> GetEditorContextAsync()
        {
            ClientEditorContext clientContext =
                await _languageServer.SendRequest <GetEditorContextRequest, ClientEditorContext>(
                    "editor/getEditorContext",
                    new GetEditorContextRequest());

            return(this.ConvertClientEditorContext(clientContext));
        }
Esempio n. 11
0
 public static Task <MessageActionItem> ShowMessage(this ILanguageServer mediator, ShowMessageRequestParams @params)
 {
     return(mediator.SendRequest <ShowMessageRequestParams, MessageActionItem>("window/showMessageRequest", @params));
 }
Esempio n. 12
0
 public static Task <ApplyWorkspaceEditResponse> ApplyEdit(this ILanguageServer mediator, ApplyWorkspaceEditParams @params)
 {
     return(mediator.SendRequest <ApplyWorkspaceEditParams, ApplyWorkspaceEditResponse>("workspace/applyEdit", @params));
 }
 public Task SendRequestAsync(string method)
 {
     return(_languageServer.SendRequest(method).ReturningVoid(CancellationToken.None));
 }
Esempio n. 14
0
 public Task SendRequestAsync(string method)
 {
     return(_languageServer.SendRequest <Unit>(method));
 }